dupa

Author Topic: Back to the basics...a Primer perhaps  (Read 4375 times)

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
Back to the basics...a Primer perhaps
« on: December 07, 2003, 08:49:37 pm »
Well, Harry Callahan said "its a good man who knows his limitations". I confess before getting HAL I had never really done much programming. A few DOS batch files notwithstanding. That has changed. I envision so many incredible possibilites with this program. So, I am asking anyone who is interested to help me get started. I have gone to the bookstore and the texts I have found are definitley not neophite friendly. With my looking for experimenting and a little free time, I think the questions below can take me a long way...probably to a lot more questions but nothing wrong with that either I don't think :-)
Here they are. I hope they make sense, and you get what I am trying to say in my questions [:)]
Thanks!!:

1. `ByVal` {any Hal function} UserSentence {as an example}

2. How do you define a condition as a global variant?

3. What this a `Global String` and how do you set them?

4. `AddPrev`

5. `Instr`

6. `Array`

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?

8. `Sub`

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?

10. Why are no numbers associated with each line of code?

11. `variable`

12. `If Learninglevel >x`  what condition am I setting? based on what?

13. How does a higher learning level affect intellegence (implemtation) vs. just "learning"

14. `If Len` - is this short for learninglevel?

15. `Trim` - example would be - Trim(GetResponse)

16. `Exit Funtion` vs. `End If`

17. `vbCrLf `

18. "stated Hal command or condition" (1, {any HAL command}  UserSentence {as exmple}, "", 1) another example would be - (Int(Rnd * x) + 1)

19. Int(((Learninglevel - 25) * 0.8)) - what is being said here?

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?

Thanks for any and all help!! Got any other critical commands or functions I should know?

Ponnfar

« Last Edit: December 07, 2003, 09:00:34 pm by Ponnfar »
One Person can summon the future...

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Back to the basics...a Primer perhaps
« Reply #1 on: December 08, 2003, 03:59:49 pm »
Hi Ponnfar,

I just saw your post above, and I'll try to get back to you with as many answers as soon as I can.  

In the meantime, try looking up my previous posts, where I've answered some (but not all) of your questions.  Look up "Basics of Ultra Hal Programming" and "Basics of Ultra Hal Programming II" and "Brain 216 Plugin" among others.  You can conveniently choose these from a list if you go to the "search" function on the menu above, then choose "all forums" and search for "Ferguson."

I recommend the book "VBScripting in a Nutshell" and I give full details about its publisher in earlier postings.  It is NOT an easy book, but the second half of the book lists every possible command and function that's built into the VBS language.

Take care, and I'll get back to you soon.

Sincerely,

Don
« Last Edit: February 23, 2004, 10:39:09 pm by Don Ferguson »
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274

Bill819

  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
Back to the basics...a Primer perhaps
« Reply #2 on: December 08, 2003, 05:50:36 pm »
You have so many questions that are normally covered by basic knowledge of programming in general that I think you need to buy a couple of books and start reading. Even if someone here were able to answer all your questions I think that it would only lead to a couple dozen more in the future. I am not trying to sound harse but most of what you asked are covered in basic programming manuals. Get the book that Don recommends and if that is not enough then get a book or two in programming in QBasic or Visual Basic. Line numbers have not been used for at least 15 years now. You could call them 'labels' as they tell a program where to go next. Now labels are 'words' or strings which give the name of the place where you want a program to go.
Please don't be offended, but this is not a place to learn how to do basic programming. If you already have a good knowledge of programming then you will find lots of good programming advice to make and improve Hal.
Bill [8]
 

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
Back to the basics...a Primer perhaps
« Reply #3 on: December 09, 2003, 12:33:11 am »
Thanks for your  response. I find my purchase of the new Hal Program to be a continusously rewarding one, as it appears many of us have. The community forum  reads " if you have questions, or suggestions about our products, post them here".  The "For Devlopers" section did not mention a particular level or expertise. It appeared to be an invitation to those who have purchased Hal and intend to develop the program, share their knowledge/experiences and get assistance.
Not to have a sense of inclusion in this,  process, may not be considered "harsh" but may indeed be an antiquated way of looking at the future. It seems regardless of our collective current programming expertise through this forum, we are able to share of common link where the questions become not quite as relevant as is the process of discovery as a shared and enriching experience.    

As we  ... mature... we may find that the  sense of adventure and discovery rather than that of the elite can only add to our knowledge and enhance our enjoyment of this now commercial product, of its evolution, and our individual uses for it. I hope there is plenty of room for everyone here [:)]

We may find that Hal or programs like it are very likely to be the norm in our everyday lives and may be as commonplace as the keyboard, in our lifetime!
Like the first of the masses who are the buying, intellegent consumers of the future, this program and others like it will undoubtedly  spark a whole new interest in programming and other endeavors and in sharing that interest in an active and  freindly learning enviornment. Like this one. I am truely a non programmer,at the moment. I am also one of those first!
"A couple dozen more" (questions) Wow!...what more fitting compliment could be made to the brilliance of this Hal Program and especially to its creator!
Again thanks for your answers.
Well.... anybody got any more? [:D]

Thanks

Ponnfar
« Last Edit: December 09, 2003, 12:58:49 am by Ponnfar »
One Person can summon the future...

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Back to the basics...a Primer perhaps
« Reply #4 on: December 09, 2003, 01:44:14 am »
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.8)) - 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
« Last Edit: December 09, 2003, 02:02:08 am by Don Ferguson »
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
Back to the basics...a Primer perhaps
« Reply #5 on: December 09, 2003, 07:13:41 am »
Don! Thanks so much for taking the time to give me those answers. [:)]
I sense you put some effort into that! You really have gone above and beyond!! Kudos and cool points to you Sir!
I am off to the bookstore again today.
Ponnfar
« Last Edit: December 09, 2003, 07:25:18 am by Ponnfar »
One Person can summon the future...