Hi Kryton,
this is what I put together from what I could find, it's not very much and most of it is not self-explanatory.
I know there was a time when there was a place on this form where somebody tried to start a location to accumulate information on how to write scripting for ultra Hal.
But I was unable to find it, I don't remember exactly what was mentioned in the forum, so it makes it difficult to do a search with the search engine on this forum.
I hope this is of help to someone, but it is intended to be just where I can organize some notes as I learn how to make plugins for UltraHal. Any mistakes, ommissions and just random text should be viewed with that in mind.
•How to write scripts for Ultra-Hal
•Working with Hal Tables
•Text manipulation commands
•The Ultra Hal Function
•Get Response Function
•Plugin basics
•Plugins under construction
•HalBrainCommands raw
•A whole help file I didn't know about
•Enumerating the hal6uhp file
•New Hal Commands
•Notes and blog
•A short tutorial
•WebRep
--------------------------------------------------------------------------
•How to write scripts for Ultra-Hal
As far as I can tell from here, UltraHal is written in Visual Basic (VB), and has functions that can be used in Visual Basic Script (VBS). The main Hal6.exe will listen to the selected *.uhp files when they say the right things.
Using this script you can create, write to and search database tables contained in the selected *.db file. You can access text manipulation functions to fix, change, dress up or cut down input and output sentences that Hal uses in conversation.
The main Hal script (which ever one you are using), has several places that you can make PlugIns insert themselves into the process. They are marked in REM statments and are positioned so as to allow access before and after main program functions like the one that fixes pronouns.
If you make your PlugIns right, they will slip in, do what you want and leave no trace if the user unchecks them some day.
Otherwise you can edit the main brain itself. Either by adding script, or deleting script, or changing script. This has the disadvantage of requiring you to re-edit it if you change your mind. Also if someone else wants to use your changes, they have to try to mess with their script.
The advantage is that straight editing is faster and easier.
I will be fixing these pages a little in preparation of ending my edits. I will continue to develop a Tutorial, bringing in the changes for version 6.1, but I won't post it until it is complete.
---------------------------------------------------------------------------------
•Working with Hal Tables
Command Syntax
Each entry will have it's own page as well, for usage, tricks, ideas etc.
I have just put these in here temporarily and will fix them as I become more sure what they do.
--------------------------------------------------------------------------------
CheckTableExistence HalBrain.CheckTableExistence("Tablename")=True/False
CheckTableExistence
This command is similar to SQL and just returns a true or false depending on if it can find the table you specify.
The specified table can be anywhere in the table folder structure, there is no need to define a path for it. For instance, if you make a table under autoLearningBrain called _stuff (it seems to be a tradition to prefix an underscore), you don't have to write "autoLearningBrain/_stuff", just use the table name in the function.
'Check to see if table exists
Bob = HalBrain.CheckTableExistence("_stuff")
'If the table exists, then variable "Bob" should now = 1
Ususally this would be used in a conditional statement like:
'Check to see if table exists
'Your function "LoadTable()" is called if table exists,
'but "MakeTable()" is called if not.
If (HalBrain.CheckTableExistence("_stuff")) Then
LoadTable(_stuff)
Else
MakeTable(_stuff)
End If
CheckTableExistence Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
----------------------------------------------------------------------------------
ReadOnlyMode HalBrain.ReadOnlyMode = True/False
ReadOnlyMode turns on and off your ability to create or edit tables in the database. You want to make it false (so it's NOT read only) before you change things, then perhaps change it back when you are done. You might want to leave it open, but not usually.
----------------------------------------------------------------------------------
CreateTable HalBrain.CreateTable "TableName", "TableType", "Where it's at(miscData)"
CreateTable
HalBrain.CreateTable "TableName", "TableType", "Unclear (subset?)"
HalBrain is set by your options to refer to the DB you want to use with this Hal personality.(?)
CreateTable makes a new table in the current database.
'Make a new Table called "_stuff"
'The type is "TopicSearch" (one of the types)
'create it under "autoLearningBrain"
HalBrain.CreateTable "_stuff", "TopicSearch", "autoLearningBrain
Usually you would double check to make sure the table does not already exist. I usually make a small function which takes the three parameters and does all that.
Function MakeTable(Name,Type,Location)
If (HalBrain.CheckTableExistence(Name))= 0 Then
HalBrain.CreateTable(Name,Type,Location)
Else
MsgBox "Table "&Name&" already exists"
End If
CreateTable Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
---------------------------------------------------------------------------------
AddToTable HalBrain.AddToTable "TableName", "TableType", "Unclear (mask?)", Source
--------------------------------------------------------------------------------
SearchPattern HalBrain.SearchPattern(EmailBook, "*<RUN>*</RUN>", 1)
SearchPattern
SearchPattern(Input String, * Search * Pattern *, Asterisk) searches your Input String for words in a certain pattern and returns the string represented by the asterisk you set numerically.
Str1 = SearchPattern("This is a test", "This * * Test, 1)
Str2 = SearchPattern("This is a test", "This * * Test, 2)
Result:
Str1 = "is"
Str2 = "a"
You can see that by asking for the first asterisk, you get the word "is", and by asking for the second you get the word "a".
This can be used to provide a parameter for functions when you are fairly certain that a phrase will be structured in a certain way.
Name = SearchPattern(OriginalSentence, "My name is *",1)
Often you will want to search a few patterns which are similar. OriginalSentence is the user supplied sentence, so you check to see if the pattern has already been found and if not, you try another pattern.
If Name = "" Then Name = SearchPattern(OriginalSentence, "My name is *",1)
If Name = "" Then Name = SearchPattern(OriginalSentence, "* is my Name",1)
If Name = "" Then Name = SearchPattern(OriginalSentence, "Call me *",1)
Use this instead of InStr if you know the pattern of the sentence, but cannot guess what the target word might be.
SearchPattern Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
--------------------------------------------------------------------------------------
PatternDb PhoneBook = HalBrain.PatternDB(UserSentence, "PhoneBook")
---------------------------------------------------------------------------------------
TopicSearch AddressBook = HalBrain.TopicSearch(UserSentence, "AddressBook")
--------------------------------------------------------------------------------------
Types of Tables
•Brain
•Sentence
•Topic Search
•Substitution
•Patternmatch
If I understand it correctly, almost everything in Hal is databases. "Pattern Match" finds things like "Open Notebook" in the user sentence, matches it to the pattern in the halCommands table, "Open *", then runs the attendant command <runprog><1></runprog>, this finds the program (1==notebook) in the startmenu index and sends the command to Windows.
To account for variables in how you may phrase it, if you look at the table you will see several methods you could use, and you can add your own if you want. I rewrote most of them to use the word "Please" in the sentence. So I have "Open *" and "Please open *"
There are more complex ones, that find more involved patterns, but it's all in the database. There's "Who* program* me*" which would find, after switching "you" to "me" earlier in the script, "Who was the first person to write the programming that led to you?"
Very clearcut way of going around the barn, the barn being "Having Hal actually understand words". With pattern match, he doesn't need to understand the words, Robert already did the understanding. Hal just needs to apply patterns of text and wildcards to an incoming sentence, then reply as Robert (or someone else) told him to...
See, this is why I have the wiki. Explaining that made me understand it much more completely. (Unless I have it wrong, in which case it just ingrained my mistakes deeper into my brain)8-(
Patternmatch Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
•Folder
-----------------------------------------------------------------------------------
•Text manipulation commands
How to change the sentences as they are used.
Trim(LCase(UserName)) Trim(LCase(UserName))
Replace(String?,string,string,1,-1,vbTextCompare
---------------------------------------------------------------------------------
•The Ultra Hal Function
From the Hal6.uhp, I quote:
"The UltraHal function is called by Ultra Hal Assistant 6.0 or a compatible host application. It passes an unformated string of the user's input as well as all remembered variables. The UltraHal function splits the user's input into seperate sentences and then calls GetResponse to get a response for each user sentence. The UltraHal function performs all the initialization functions required for GetResponse so that GetResponse doesn't have to initialize several times if a user inputs more than 1 sentence."
Function UltraHal
ByVal sets the type of connection Hal makes to the variable.
When you use ByVal, the procedure is passed a copy of the argument variable and not a reference to the argument variable itself. Code in the procedure cannot change the variable's value.
The default in VB is ByRef, IIRC.
ByRef When an argument is passed by reference, the procedure is passed the address of the argument variable (in other words, a reference to the variable) so that the procedure can make changes in the value of the variable.
VB's default is to pass arguments by reference. You can include the ByRef keyword in an argument list if desired but, because this is the default, it has no effect. ByVal must be invoked to be used.
ByVal InputString
InputString is the raw text from the input box on the Hal application GUI. This is what I messed with to make the spellchecker work. By the time the first plugin area is reached, this string is already partially parsed and cleaned up. It is then transfered into "OriginalSentence" at a point I have not yet reached.
I am concerned that this description is wrong. When I got to the auto-idle process and found that InputString was set to "Auto-Idle" I began to have doubts. I don't want to go forward in the file to see what happens to it yet, because I will get distracted, but check back with this subject for updates...
ByVal UserName
UserName is the name you specified in the setup or the General Options menu dialog.
ByVal ComputerName
ByVal LearningLevel
LearningLevel is the slider control in General Options - Brain. If all the way off, the DB is closed. Otherwise there is a variable that changes to reflect the amount the db is consulted.
ByVal DatabaseFile
ByRef Hate
ByRef Swear
ByRef Insults
ByRef Compliment
ByRef PrevSent
ByRef LastResponseTime
ByRef PrevUserSent
ByRef CustomMem
ByRef GainControl
ByRef LastTopicList
The Ultra Hal Function Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
------------------------------------------------------------------------------
•Get Response Function
I quote from hal6.uhp:
RESPOND: GETRESPONSE
Get a response from Hal's brain for each sentence individually.
If a response from a sentence indicates a special flag, then Hal
will give only the response to that sentence, and not process
any other sentences. Otherwise Hal will respond to each sentence.
Hal will respond to a max of 3 sentences at once.
I'll fix this later.