Hello Baskot,
To check my understanding of your question, I will paraphrase your question as follows:
"How can I trigger TRUE, FALSE, ANGRY, HAPPY, and other various states within Hal, and then pass those states outside of Hal's script so that an I/O board can use the information to trigger external hardware?"
Two ideas for doing this come to mind, as follows:
----------------------
Idea #1: Using Hal's AppendFile function, you can add a new line to an external text file of your choice. Then, you have to figure out a way to get your I/O board and its software to read the LAST LINE of the target file periodically, and pick up the "state." The code within Hal's VBS script would look something like the following:
If Instr(OriginalSentence, "angry") > 0, Then HalBrain.AppendFile WorkingDir & "statefile.txt", "ANGRY"
If Instr(OriginalSentence, "happy") > 0, Then HalBrain.AppendFile WorkingDir & "statefile.txt", "HAPPY"
In everyday language, the above code says: "If the exact string of letters 'happy' is found in the variant called 'OriginalSentence,' then open a file named 'statefile.txt' and write a new line at the end of the file with the letters 'HAPPY' on it.
(HalBrain.AppendFile is a capability provided by Zabaware. You can write files directly using VisualBasicScripting commands also, but unfortunately, doing so usually triggers false warnings from anti-virus software! To my knowledge, Zabaware does not currently provide an easy method to erase a file or replace its contents from within Hal's script. That's why my example uses append, rather than replace.)
Idea #2:
If you know of a way to get your I/O board & software to "read" variants directly from Hal's running script (I DON'T know how, but there might be a way), you can simply create a new variant within the script and change its state with code like the following:
If Instr(OriginalSentence, "angry") > 0, Then MySpecialVariant = "ANGRY"
If Instr(OriginalSentence, "happy") > 0, Then MySpecialVariant = "HAPPY"
In the VBS language, you don't need to declare the existence of a variant before you use it. The code above would create a variant named MySpecialVariant if it didn't already exist, and assign the stated string-value to it.
(Note that due to the way VBS works, the values of all variants are erased each time the script finishes running, UNLESS you declare the variant AT THE TOP OF THE SCRIPT BEFORE THE GETRESPONSE FUNCTION BEGINS, as a GLOBAL VARIANT. The excellent book "VBS in a Nutshell," which I've recommended in many past postings, explains this issue.)
-----------------------------
If it were my project, I would pursue Idea #1. Passing the information-state outside the script to a text file, then "reading" it outside the script, seems like the cleanest way to go. You would need to have your I/O board software read the file every few seconds and respond to the latest "state" corresponding to the last line.
You asked about the best place in the script to add your new code. The code examples I've given would not interfere or interact with anything else in the script, so it should be possible to add it anywhere AFTER the contents of "OriginalSentence" are established, and BEFORE the end of the "GetResponse" function.
I hope this gives you some additional ideas, and I hope that it stimulates further ideas and help from others on the forum. I hope that your project succeeds! Please let us all know!
Sincerely,
Don