PDA

View Full Version : Variable not found problem


ABC123

WesOlfert
02-20-2005, 10:53 PM
Why is it that after I have defined a Session variable (e.g vcSearchBy) when I use it in a script it creates an error -- the variable is not seen. What causes a variable to appear as "non-existent" when it is actually defined? I defined it by clicking of the V icon (in Form Design Mode) and defining it there.

I have reviewed Alphasports, all the documentation (Tutorial, Xbasic) and the forum -- found some stuff on variables all right, but so far no real answer to this problem. I actually copied the code from Alphasprots/Customer Form and edited table names. Semms it should work just like in Alphasports!

Any help would be appreciatged. Thanks.

Wes

Bill Warner
02-21-2005, 04:50 AM
I usually define variable as global if I'm going to use them in more than one place. This avoids the problem you're having.

WesOlfert
02-21-2005, 05:58 AM
I am having this problem even when I uses it in only one place -- like in the example attached. Also I have tried using a differently named variable for the second use but still have the same issue. Do I think something else is gong on here?

I have attached a sample this time to, hopefully, make it easier to figure out.

Tom Cone Jr
02-21-2005, 06:37 AM
Wes, not sure where to start. Several things seem to be mixed up in your script.

1) The multistate button in the Customer Information form in AlphaSports doesn't use the "text" property of the variable. There is no such thing. It uses the text property of the field object on the form that displays the variable. There's a huge difference. Study the SearchBy object on the Customer Information form. Notice that its name is different from the name of the variable it displays. Objects you drop on your form have properties. Among them is the "text" property. Variables are NOT objects in your form layout (at least not in the same sense as a text box you drop on the form.)

2) Your form doesn't have an object on the form displaying the variable vcSearchBy.

3) Your form never assigns any values to the variable, vcSearchBy.

Lots to work on.

Question: Do you always want to search by the Name field? i.e. have the multistate button display names that begin with the same letter? If so, I have good news for you, you don't need to fool with vcSearchBy in the first place.

-- tom

Tom Cone Jr
02-21-2005, 06:45 AM
Wes,

Your original question wasn't directly answered in my previous.

Your OnChange script in the multi-state button uses an incorrect syntax sequence in trying to use the variable vcSearchBy. Your syntax,

vcSearchby.text

tells Alpha you want to use the text property of an object called vcSearchBy that's located on the form and of course there is no such object on your form.

-- tom

WesOlfert
02-21-2005, 08:05 AM
Thanks for your prompt reply -- I have tried to digest what you said --and here are the results

1) The multistate button in the Customer Information form in AlphaSports doesn't use the "text" property of the variable....
2) Your form doesn't have an object on the form displaying the variable vcSearchBy.

"b" I thought I setup the same way as AlphaSports -- I still don't see how mine is different -- except that, indeed, I did not have a field object named "SearchBy". I have attached a revised example correcting that. I still have the same problem."/b"

3) Your form never assigns any values to the variable, vcSearchBy.

"b" I thought I did that when I defined the vcSearchBy variable -- I put in the value "Name" --again following the pattern of A.Sports"/b"

Question: Do you always want to search by the Name field? i.e. have the multistate button display names that begin with the same letter?

"b"Basically, yes -- searching for a name field is the purpose to make browsing a long list quicker and easier. What other method do you have in mind?"/b"

"b" Thanks for your help. I think I've learned a lot in the last few months, but still have a LONG way to go!"/b"

WesOlfert
02-21-2005, 08:09 AM
I thought I could use HTML tags so I tried to make my staements in bold to easily distinguish them from yours but that obviously didn't work -- maybed I needed to the "pre" tags along with the "b" tags. Oh well -- try, try, try and learn, learn, learn -- what else to do in my spare time!!

WesOlfert
02-21-2005, 08:13 AM
Just testing the "pre""b"HTML tags"/b""/pre"

WesOlfert
02-21-2005, 09:12 AM
Again, thanks for your help.
Got it working finally using your guidance, I figured out what was referecing a variable and what was referecing a field on the form. I also changed the names so it was easier to tell which was which -- that is, the name of the variable did no look like the name of the field.

Anyway -- Appreciate your help. Many, many thanks.

Tom Cone Jr
02-21-2005, 10:37 AM
Hey, that's good news! Thanks for letting us know.

The approach taken on the Customer Information form permits the user to change the field used for displaying the sorted list of field values. If you're always going to use the Name field you don't need this functionality. You could tie your ONChange script for the multi-state btn to the first character in each Name field value, so that only names that begin with the char on the button just pressed will appear. However, if you have it working with vc_SearchBy, it's prefectly reasonable to leave alone!!

-- tom

Al Buchholz
02-21-2005, 12:04 PM
Just testing the
HTML tags

Wes

Are you clicking the Use HTML check box just above the send message line?

See attached image.

WesOlfert
02-21-2005, 05:17 PM
No I did not check the HTML box at the bottom -- I did not see it till later.

WesOlfert
02-21-2005, 05:19 PM
Good -- now I see how it works!
Thanks for your reply and help.