Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable

Status
Not open for further replies.

nguyen12

Technical User
Sep 30, 2001
42
US
I have a question about variable in FoxPro that i need help with. When you assign a variable to 1, and then later on in the program you set condition for variable when it changes to 2 or 3 or more. What will that do? I don't understand what the number stands for like when you change varialbe value from 1 to 2 what will that do? Thank you.
 
HI

The question is not clear ,, but with whatever I understood I am answering...

Let us say.. you initialise a variable in a programme..
myChoice=0 ... or... STORE 0 to myChoice

Based on some condition..user choice.. let us say..This myChoice is varied..

Say you ask..
What you want to order ? 1=Banana 2=Orange 3=Apple etc..

Now user keys in in as answer to the above question 1 or 2 or 3.. and you capture the user input as myChoice

Then... now.. you know..
If myChoice=1
The chosen item is Banana

If myChoice=2
The chosen item is Orange
etc.

Now you have a variable myChoice and know how you want to proceed...

Does this makes sense ?
:)




ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
If I understand your question, nothing unless you test for the value of it. For instatnce, in your code you do something like:

DO CASE
CASE variable = 1
do something1

CASE variable = 2
do something2

CASE variable = 3
do something3

OTHERWISE
do error stuff with 'Bad value'

ENDCASE

Maybe you need to elaborate more on what you mean or need.

Dave S.
 
Thanks for your help. O.K let me make my question clear. First in my application i set some value for my local varibale let say i have variable a =1 , b =1 ect... Let say if i set condition for my variable like if a = 2 then do closing form and return, what will this do? Or if i say if b 1 then do something, b =2 do somethings. Will the value of my variable change that can effect the application when i set the condition for the variables. Thank you.
 
Simple answer... unless you change its value, the values dont change by themselves. The user inputs can be captured by you as value of variable and by this user changes its value to his/her desire.

So if you say A=1.. by checking 'IF A=1' will not change the value of A.

:)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
It sounds to me like you want the code contained in your IF statement to fire as soon as the variable becomes that number. It doesn't work that way.

You need to put this code into an event that will occur after the user has made a selection. This could be in the VALID event of a text box for instance, or the KEYPRESS event of a form. At that time, you would check to see what the user selected and process the selection.

Forgive me if this has nothing to do with what you asked. :eek:(

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top