Author Topic: Asking Don Ferguson  (Read 2821 times)

joe90

  • Newbie
  • *
  • Posts: 10
    • View Profile
Asking Don Ferguson
« on: October 29, 2003, 05:42:51 am »
Mr Ferguson

I am asking if you could expand on larry's answer to me (see below) regarding this question. I know he called you Don, but here in england it takes a while before we call each other by our first names, ( quaint I know,) or maybe I am of an age that still has old fashioned ways. I can see from your website your time is valuable, but any help would be appreciated.
Thank you for any help.

Best wishes Joe Fowler

Hi. Being no programmer,I have downloaded some ready made scripts (thanks to all) and have inserted my first:(If Instr(1, UserSentence, "Say hello to Greg", vbTextCompare) > 0 Then
GetResponse = "Hello Greg!"
End If)
into Hal's brain in a free? line. i.e. line 0391 has an End If, line 0392 is empty. After placing the script there, I edited the script by changing the name and adding "nice to meet you" The script insert and editing work fine. Does this mean I can insert any script no matter how large it is, into an empty line and it will work and not cause any damage?
This may sound simple and basic, but I am new to all this.
I have owned a previous version of Hal for some time, but never really understood it's capabilities or potential. (What a waste I know)but I am now really trying to get into it.

Thanks for all the help I have already received so far.

joe90
 
 
Larry
Average Member


USA
178 Posts
 Posted - 10/28/2003 :  15:56:58          
--------------------------------------------------------------------------------
 
Actually the simple answer is no... usually it's a matter of trial and error...

For example, if you put your scripts too near the top, then things after it will "over-write" your desired responses...

Don probably can better explain this than I can...
 
 
 

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Asking Don Ferguson
« Reply #1 on: October 29, 2003, 11:38:48 am »
Hello,

Please call me "Don."  That is my preference for everyone on this forum.  You can't be much older or more quaint than me... I'm still in shock because Dean Martin and Jerry Lewis split up!

Now, for your question:

For the most part, it's possible to insert code anywhere in the script, and if the code is written properly, it will run.

Examine the "brain" VBS .uhp script, and you will see a place where it says "Function GetResponse."  This is the official start of the GetResponse function.  Much later in the script, but not at the end, there is a statement "End Function."  The code between those two markers is the "function."  There are a couple of other functions at the end of the script, and a function can "call" another function as needed.

As Larry mentioned, inserting code, especially test code, LATER in the Hal script usually makes it more certain that you'll see the results on every exchange.  Why?  Well, the goal of the GetResponse function is to produce a line for Hal to speak, in the form of a variant named "GetResponse."  (Yes, the function and the variant have the same name, but they're two different things.)

Since Hal has many routines to produce possible responses, most of them have a statement in them something like this:

If Len(GetResponse)<4 Then

In English, this line of code is saying this:  "Check the length of the string of characters you have at this point in the script for the variant called GetResponse.  If the memory-bank-variant named GetResponse is empty so far, or consists of less than 4 letters in length, then proceed with the following routine.  Otherwise, skip it."

If GetResponse already has something in it, but a new routine "saves" information to GetResponse, it over-writes the previous contents.  Look at this:

GetResponse = "Hi there."
GetResponse = "Goodbye."

These two lines of code would result in GetResponse containing "Goodbye" only, since it would over-write whatever was there previously.

However, look at this:

GetResponse = " Hi there. "
GetResponse = GetResponse & " Goodbye. "

Those two lines of code would result in GetResponse containing "Hi there.  Goodbye."  This is because you can "concatenate" (couple together like railroad cars) character strings using the ampersand.

Some of the response routines have logic that overrides what was there before.  They will "override" whatever is in GetResponse if they come up with something for Hal to say.

The net result is that experimental code placed early in the script has a high chance of being over-written.  Late in the script, it isn't so likely to be over-written.

When you get more advanced, of course, you will probably want to put that "If Len(GetResponse)<4" conditional statement in there, and place your routine strategically in your preferred place in "priority order."

I know that there are thousands of postings on this forum, so it's hard to catch up on everything at once, but I do suggest that you go to the "search" function and check out some of my older postings on what the code means and how to program.  It may be helpful.  And you're always welcome to post more questions, whatever they may be.

I hope this helps a bit.  Take care and write again!

Sincerely,

Don
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