Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using On Key Label
Message
 
To
29/06/2001 04:19:48
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00525060
Message ID:
00525074
Views:
17
>>Hello everyone,
>>
>>I have a procedure to be run when using press the keyboard, my code is like:
>
>on key label 0 MyFunction("0")
>on key label 1 MyFunction("1")
>.
>.
>on key label Z MyFunction("Z")
>
>>of course I dont want to repeat the code 36 times, so I tried this:
>>
>>for-loop(i)
>>  Chk=transform(i)
>>  on key label &Chk MyFunction("&Chk")
>>endfor
>>
>>
>>but there is syntax error with it, is it possible to do it in a simpler form? or must I repeat the code 36 times?
>>
>>Thanks a lot!


ehh,

That loop with for-loop(i) is not correct.
A for loop goes like:
FOR i IS 1 to 36
   ...
ENDFOR
The next problem is that TRANFORM() does not give you characters.
You can choose between two ways.
FOR i = 1 to 9
   Chk=transform(i)
   on key label &Chk MyFunction("&Chk")
ENDFOR
FOR i = ASC('A') to ASC('Z')
   Chk=CHR(i)
   on key label &Chk MyFunction("&Chk")
ENDFOR
or:
x = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
FOR i = 1 to LEN(x)
   Chk = SUBSTR(x,i,1)
   on key label &Chk MyFunction("&Chk")
ENDFOR
hth,
Previous
Reply
Map
View

Click here to load this message in the networking platform