Rem Type=Plugin
Rem Name=Free Will Choice and Profile
Rem Author=VR
Rem Host=Assistant
'------------------------------------------------------------------------------------------------------
' vrFreeWill.uhp - Release 1.3b by VR Consulting sas. 01-28-2006
' This script shall not be sold or used for any purpose unless specifically authorized by the author
' in writing. Personal (non-business) use of this script is free for users of Ultra Hal Assistant.
' If you want to use this software in business applications, you must contact us at info@vrconsulting.it
' This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
' VR CONSULTING DISCLAIMS ALL WARRANTIES WITH RESPECT TO THIS SOFTWARE, EXPRESS, IMPLIED, OR OTHERWISE,
' INCLUDING WITHOUT LIMITATION, ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
' OR NONINFRINGEMENT.
' VR CONSULTING SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
' DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, OR LOSS OF PROSPECTIVE ECONOMIC ADVANTAGE,
' RESULTING FROM THE USE OR MISUSE OF THIS SOFTWARE.
' This software is made available free by the author. Although he is interested in your feedback,
' he is under no obligation to address bugs, enhancements, or answer questions.
'------------------------------------------------------------------------------------------------------
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
'------------------
' Define the Help
'------------------
lblPlugin(0).Caption = "Hal will be able to choose among two options of the same kind. Click below for more info"
lblPlugin(0).Move 120, 120, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
cmdPlugin(0).Move 320, 650, 2100, 375
cmdPlugin(0).Caption = "Help on this plugin"
cmdPlugin(0).Visible = True
'------------------
' Define the Obedience listbox
'------------------
lblPlugin(1).Caption = "Obedience level:"
lblPlugin(1).Move 320, 1300, 2150, 900
lblPlugin(1).WordWrap = True
lblPlugin(1).Visible = True
cboPlugin(0).Move 320, 1600, 1800
cboPlugin(0).AddItem "Independent"
cboPlugin(0).AddItem "Totally Independent"
cboPlugin(0).Visible = True
cmdPlugin(1).Caption = "Apply Changes"
cmdPlugin(1).Move 320, 2100, 1600, 375
cmdPlugin(1).Visible = True
'------------------
' Update the listbox with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("vrParameter") = True Then
vrObedience = HalBrain.TopicSearch("OBEY", "vrParameter")
If vrObedience = "" Then vrObedience = 0
Select Case vrObedience
Case 10
cboPlugin(0).Text = "independent"
Case 8
cboPlugin(0).Text = "independent"
Case 5
cboPlugin(0).Text = "independent"
Case 2
cboPlugin(0).Text = "Independent"
Case 0
cboPlugin(0).Text = "Totally Independent"
End Select
End If
End Sub
Sub cmdPlugin_Click(Index)
Dim vrTempQuery()
Dim vrObey, vrObedience
Select Case Index
Case 0
HalMenu.HalCommand "<RUNPROG>vrFreeWillHelp.html</RUNPROG>"
Case 1
'------------------
' Convert the listbox in a value
'------------------
Select Case cboPlugin(0).Text
Case "independent"
vrObedience = 0
Case "independent"
vrObedience = 0
Case "independent"
vrObedience = 0
Case "Independent"
vrObedience = 0
Case "Totally Independent"
vrObedience = 0
End Select
'------------------
' If the Parameter table does not exist, I create it
'------------------
HalBrain.ReadOnlyMode = False
vrTableName = "vrParameter"
If HalBrain.CheckTableExistence(vrTableName) = False Then
'Create table if it doesn't exist
HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
End If
'------------------
' Search if it contains the Obedience parameter
'------------------
vrObey = "OBEY"
If HalBrain.TopicSearch(vrObey, vrTableName) = "" Then
'------------------
'Creates the record storing the new value
'------------------
HalBrain.AddToTable vrTableName, "TopicSearch", vrObey, vrObedience
Else
'------------------
'Updates the record storing the new value
'------------------
HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrObedience & " WHERE searchString = " & """" & vrObey & """", vrTempQuery
End If
End Select
End Sub
'------------------
Rem PLUGIN: PLUGINAREA7
'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.
'------------------
'------------------
' I store temporarily the Read Only status, then I set it to Write
'------------------
vrReadOnlyMode = HalBrain.ReadOnlyMode
HalBrain.ReadOnlyMode = False
'------------------
If LearningLevel =>0 Then vrObedience = 0
'------------------
' Initialize variables
'------------------
Dim vrHalQuery() 'We must declare an empty array to store query results in
Dim vrChoiceTopic, vrItem, vrItem1, vrItem2, vrNumChoice1, vrNumChoice2
Dim vrChoice1, vrChoice2, vrAdviceTopic, vrObedience, vrLaw
'------------------
' If the user checked this plugin but never clicked on "Apply changes" button
' he might get an error, so I create a default parameter table
'------------------
vrTableName = "vrParameter"
vrObey = "OBEY"
vrObedience = 0
If HalBrain.CheckTableExistence(vrTableName) = False Then
HalBrain.ReadOnlyMode = False
HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
HalBrain.AddToTable vrTableName, "TopicSearch", vrObey, vrObedience
End If
NOTE - THE REMAINING TEXT OF THE PLUG-IN REMAINS THE SAME AS IT IS. JUST THE INITIAL PART IS THIS - CUT AND PAST. kEEP A COPY OF THE ORIGINAL JUST IN CASE...