QUESTION: I am using foxpro 2.6 for DOS. There are few @ say.. get variable have been placed on the screen. Suppose user is in the get region of var1 then I wish to have a message like "You are in the var1" as he enters in the var1 variable. As he press enter or tab key, the respective message should be displayed like "You are in the var<N>".
Problem is @ get valid(myfunc(varread()) is only executed when user exits from the get variable, I need it to be executed as he enters in the get region.
Kindly help me with an example of action code please.
ANSWER: Good morning, well - here it is...
You are correct about the VALID clause - it executes as control passes out of the variable. The WHEN clause executes as control passes into the variable. Usage is the same, only execution time is different.
I don't have time (at the moment) to give you detailed code, but if you need additional help, please post a follow-up question and I'll assist in any way I can. I wanted to give you an answer quickly and, since you are familiar with VALID, you should be okay.
---------- FOLLOW-UP ----------
QUESTION: I am thankful to you for your fast and helpful reply. Yes, I need additional help by viewing the WHEN clause so that I may get it into my .PRG file. Here it is more details of my current work:
I have below code :
set talk off
set status off
set order to rollno
@ 5,5 say 'Enter Rollno:-' get rol default space(7) pict "@K"
@ 7,5 get mark1 valid myfunc(varread())
@ 7,10 get mark2 valid myfunc(varread())
@ 7,15 get mark3 valid myfunc(varread())
@ 7,20 get mark4 valid myfunc(varread())
@ 7,25 get mark5 valid myfunc(varread())
@20,20 say 'You are in Mark1'
@20,20 say 'You are in Mark2'
@20,20 say space(20)
I need to display and/or process some more other code as and when user navigates in the different get variables.
Kindly help me.
Thanks and Regards
Although the WHEN clause was not strictly designed for this, if you change your code by replacing "VALID" with "WHEN" it will do what you want. The original purpose of WHEN was to programmatically control if an object should be allowed to work. If the result of the WHEN clause returns 0 (zero) or .F. (false), the field cannot be entered. IF the result returns non-zero (usually a 1 [one]) or .T. (true), then entry into the field is permitted. However, since the code is executed as soon as entry into the field is attempted (via a click, tab, arrows, etc.) you should see the desired behavior.
The subject of your question "GOTFOCUS FUNCTIONALITY" threw me a curve, since the GOTFOCUS method does not exist in FoxPro versions prior to Visual FoxPro. But, with the WHEN clause, the concept is the same.
Just remember to RETURN .T. at the end of your WHEN clause so entry into the field is allowed.
Best of luck,