Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Abdulla Rahiman
  Where is Abdulla Rahiman?
 Dubai
 United Arab Emirates
 Abdulla Rahiman
Subject: RE: Executing Error statement without showing error
Thread ID: 97990 Message ID: 97998 # Views: 1 # Ratings: 0
Version: Visual FoxPro 8 Category: Forms
Date: Wednesday, June 7, 2006 4:52:16 PM         
   



> Dear Experts,
>
> I m getting strange error, i have form with command button under the
> click event of the command button i worte code for converting
> dbf files to Excl files and some undefind variable also
> for Example
> if stat = .T.
> messagebox('True')
> else
> messagebox('False')
> endif
>
> while excuting this statement if 'stat' is not declared
> it should display error like varaible 'stat' not found,
> But in this case while clicking the command button
> there is not such error giving and excuting the first statement
> displays 'True' in the message box.
>
> Then i create another button and paste the same command and excute,
> here i m getting the proper error message like variable
> 'stat' not found.
>
> anybody have any idea, pls help me
>
> With thanks and regards
> Abdulla


My guess is that 'stat' is a declared variable - declared somewhere else. Do a search for this variable and you will probably find it. The best way to deal with this is to explicityly declare your variables. Also, STAT is the FoxPro short form for STATUS as in SET STATUS ON (for the status bar). In your command window, type in "Stat" and you will find that it is colored blue. I would be leery of using anything that might remotely resemble a reserved word (even the short form.) Instead, when you use a variable, declare it explicitly:
LOCAL llStat as Boolean && llStat will never show up in blue in the command window
llStat = .f. && always begin by setting the variable's default value

There are a lot of articles about variable naming conventions that you can read, but for the most part, I use the naming conventions to know three things:

1 - The scope of the variable: l = Local, p = Private, g = Public (but the P has already been used so we use g for Global.)

2 - The type of variable: l - Logical, n - Numeric, c - Character, o - Object

3 - Most importantly, I know that anything prefixed with this naming convention is not a reserved word.

In your case though, I believe that you need to look for 'Stat' elsewhere in your app and determine it's scope. It could even be a public variable located in your Main.Prg. Use the naming conventions, declare each variable and give it an initial defalut value and you will avoid this type of issue.

Ken


You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Executing Error statement without showing error Posted by Abdulla Rahiman @ 6/7/2006 3:42:36 PM
RE: Executing Error statement without showing error Posted by Ken Murphy @ 6/7/2006 4:52:16 PM