Hi Ponnfar,
I want to encourage you (and all the other readers of your post and this post), so I'll try to give you some brief, highly-focused answers.
Bill819 does make a good point about "hitting the books"; there really aren't any shortcuts to learning programming and various programming languages. I've had my book "VBScripting In A Nutshell" for years now, and I still re-read it and learn from it often!
If a page number in "VBScript In A Nutshell" applies to one of your questions, I'm going to reference the page number in the replies below.
1. `ByVal` {any Hal function} UserSentence {as an example}
Pages 18 and 19: Variants can be passed into and out of a script "by reference" or "by value." As used by Zabaware, the difference has to do with whether they want the script to be able to modify the value when the script finishes with it, or whether they merely want the script to receive a copy of the variant at the beginning of the script. (I have not had to worry about these distinctions in any of the code writing that I've done.)
2. How do you define a condition as a global variant?
Page 62. A variable has "script-level scope" when it is declared outside of any function. This causes the variant to stay in memory between runs of the script. It is the equivalent of "global variable" in the Visual Basic language. In the case of Ultra Hal, this means declaring the variant before the first function begins.
3. What this a `Global String` and how do you set them?
A variant in VBS can be a string or a number. Either can be made script-level (global).
The following line:
Dim MyGlobalVariant
...if made before the first function begins, would declare the existence of "MyGlobalVariant", making it available to all functions and subroutines in the script, and making it be "remembered" in the computer's memory in between conversational exchanges.
4. `AddPrev`
Let me know the context where you saw "AddPrev", and I'll try to answer.
5. `Instr`
Pages 336-338. The Instr command means "in string." The command causes the program to search for a specified string of characters within a larger specified string of characters, and return a number equal to the number-position of the first character where the match begins. If no match is found, "0" is returned. Zabaware uses this function to detect desired words and phrases within sentences. The function can be used with "arguments" that tell the function to work different ways. Zabaware often adds some arguments to make Instr searches case-insensitive, which is very handy.
6. `Array`
Pages 49-61. A variant is an individual number or string of characters. In contrast, an array can contain a set of values, like a little miniature table with any number of rows (and even columns, for a "two dimensional array"!). It is possible to convert a comma-delimited string of characters into an array. For instance, the following string:
blue, green, gold
...could be converted and stored into an array we'll arbitrarily call ColorArray, and you could retrieve the contents as follows:
ColorArray(0) = blue
ColorArray(1) = green
ColorArray(2) = gold
When you use the "Split" function to break a sentence apart at a specified point, the two pieces automatically get returned to you by VBS as an array. So, you have to know about arrays in Ultra Hal to retrieve and use those pieces.
7. `DebugInfo` - I have seen many instances of DebugInfo followed by some comment made by Hal, ie: DebugInfo = DebugInfo & " xxx" . However I have not seen a definition for DebugInfo. Where is that found? What does it call? How does it work?
This is in the Zabaware help documentation and/or annotation within the script. Robert Medeksza created the "DeBugInfo" variant to help test scripts during writing and troubleshooting. When you turn it "on," it collects all the responses from all of Hal's routines, so that Hal reveals what he says, but also all the things that he COULD have said, but didn't. When you use this Zabaware feature, you will tend to get long, long responses from Hal, so you only use it for troubleshooting.
8. `Sub`
Pages 419 to 421. This command declares a "subroutine" or "subprocedure." Hal uses some subroutines. Whether to perform an activity within the main function, or send it off to a subroutine, is somewhat of a programmer's judgment call. If the program might need to do something repeatedly, a subroutine definitely makes sense, since you don't have to write the code over and over.
9. When using command "Randomize", does "Else" have to be included
amongst the variables? How often in a set of given choices. In other words, one "else" for every 2,3 or 4 choices?
"Randomize" merely refreshes the random-number generation capability, prior to calling for a random number. Sometimes it's used with a number called a "seed" to help make it more random. "Timer" makes a good seed, since it's the number of seconds since midnight, and it's always changing.
"Else" is used to declare a condition that includes all possibilities besides the stated cases. Therefore, the following code:
Case 1
MyVariant = "A"
Case 2
MyVariant = "B"
Case 3
MyVariant = "C"
Else
MyVariant = "D"
We are really just saying that if we don't get case 1, 2, or 3, than for all other circumstances, we want what "Else" says.
In many cases, you can write a code-set so that "Else" isn't needed. It's a choice you make.
10. Why are no numbers associated with each line of code?
Error codes do refer to line numbers, but they're dynamic. In other words, the software just counts down the current lines to tell you where trouble is. Line numbers aren't used for navigation within the program by the computer; the computer executes the code in sequence, following any conditions and subroutines written into the code.
Zabaware's Brain Editor assigns line numbers to help find your way around while writing and troubleshooting. You can also make Microsoft Word generate line numbers, although it's very inconvenient.
11. `variable`
A lot of documentation on VBS uses "variable" and "variant" interchangeably. A variant is any alphanumeric string, boolean value, or number that you want to store temporarily or permanently in memory. You can name variants anything you want, as long as you don't use words reserved for functions already in VBS. The convention of form is to name variants in such a way that they help you remember what you created them for.
Unlike some other languages, VBS doesn't require you to tell it whether you intend a variant to be a number or a string in advance; the computer figures it out by context automatically. However, if you create a number variant and treat it like a string variant, or vice-versa, you'll generate a "type mismatch" error.
12. `If Learninglevel >x` what condition am I setting? based on what?
Hal's user control panel can generate values for learning level 0, 1, or 2. At certain places in Hal's script, there are If...Then condition statements that allow certain routines to run or not run if the number is higher or lower than the threshold. Without this conditional, all of Hal's learning routines would be active all the time. This is a feature to give the user some control. Setting the learning level to a super-high number such as 6 or 8 would do nothing extra, since nothing in the script requires a number that high to activate.
13. How does a higher learning level affect intellegence (implemtation) vs. just "learning"
When all of the learning routines are active, Hal is saving words, phrases, and sentences into numerous different databases, parsing and searching for various parts of speech, and adding vocabulary. When all learning routines are "off," Hal continues to use all the resources he's accumulated, but he isn't adding anything new for future use.
14. `If Len` - is this short for learninglevel?
Page 349. "Len" is short for "Length." Here is a code example and a translation:
If Len(UserSentence) > 5 Then
This is a conditional statement telling the computer to execute the next lines of code only if the character-length of the variant UserSentence is longer than 5 characters.
When used to test the length of "GetResponse," the code is actually testing to see whether Hal has found anything to say yet (at that point in script execution). (If Hal has found something to say, "GetResponse" is probably longer than 4 characters.)
15. `Trim` - example would be - Trim(GetResponse)
Page 434. The "trim" function removes all leading and trailing spaces from a string of characters. It's useful for Instr searches to have at least one leading and one trailing space before and after a sentence, in order to detect words accurately at the beginning and end of the sentence. However, at other times, it's convenient to strip away all leading and trailing spaces (for instance, to count characters), and "Trim" does this.
16. `Exit Funtion` vs. `End If`
Page 241. The "End If" statement closes a set of lines of code following a conditional statement such as "If Len(MyVariant)>4 Then". You can nest If...Then statements inside each other, and you need to count the number of If's you have "open," and put the right number of End If's at the end, or you will get error messages and your code won't run.
"Exit" is on pages 20 and 258. If performs a similar function, "closing" sets of instructions following Do, For, Function, Property, or Sub.
17. `vbCrLf `
This is "Visual Basic Carriage Return Line Feed." It's like hitting the "return" lever on a typewriter. Zabaware uses it under certain circumstances to tell Hal where a sentence has ended. It isn't always needed, since Zabaware's routines also recognize some punctuation.
18. "stated Hal command or condition" (1, {any HAL command} UserSentence {as exmple}, "", 1) another example would be - (Int(Rnd * x) + 1)
Here's an example:
(Int(Rnd*5)+1)
would generate the following:
Generate a random number between 0 and 1 and multiply it by five; convert it to an integer by dropping any decimal places; add 1 to the result.
Possibly the answer below will help:
19. Int(((Learninglevel - 25) * 0.

) - what is being said here?
"Take the numerical value of the LearningLevel variant, subtract 25 from it, and multiply the result times 0.8, and make the answer an integer by dropping any decimal places."
20. How do you direct Hal to call a response from a particular .brn? Then how do you randomize those responses? Conversely, how do you make HAL search all ".brn" sets for the best response? Is the later done by defalut?
Check the annotation on the "RESPONSE" routines in the script. When Hal looks in a database, the code refers to the file name for that particular database that is being accessed at that moment.
When Hal saves to a file, you'll see "appendfile" in the code, along with the name of a file, or a little routine to construct the name of the file.
Hal selects from various possible responses in many ways. In some cases, he goes through a list of routines, and takes the first routine that gives him a response. In other cases, the responses are evaluated for "relevance," a scoring system developed by Zabaware, and only accepts a response above a certain threshold. Some databases have the capability of delivering content already randomized from within the database. Other databases are "deterministic," meaning that a given input will always select a particular output according to rules. At still other times, random number generation variants labeled "Roulette" decide what to use, and whether to use it, depending on the number that was randomly generated.
In the code in the script, there are "annotations" attempting to briefly explain the purpose of each set of code that immediately follows in the various routines.
Keep up the good spirits and good interest; what seems mysterious now will seem very clear eventually, but you have to stick with it, study it over a long period of time, and it definitely helps to buy the book!
Sincere Best Regards,
Don