Kevin,
Try
ON KEY LABEL ESC DO vAform.prg
Since you would have to have an active form in _screen, so you might want to create a prg that will handle the validation of your environment, something like vAform.prg. Then youe KEY LABEL statement will call the following prcedure which in its turn will execute the bailout() method, if any.
PROCEDURE vAform
*****************
LOCAL loAForm
IF TYPE("_screen.ActiveForm") = "O"
loAform = _screen.ActiveForm
IF PEMSTATUS(loAform, "bailout", 5)
loAform.bailout()
ENDIF
ENDIF
* End vAform.prg
HTH
>I'm trying to do some "tricky stuff" with an ON KEY statement in the init event of a form. I'd like multiple commands to execute, but can't figure out a way to trick VFP into doing my bidding!
>
>If I use:
>
>ON KEY ESC DO THISFORM.bailout()
>
>and put the commands in a method (named bailout) off the form, then I get the error "THISFORM can only be used within a method." because I'm actually in the "read events handler".
>
>I don't want to have a separate .prg with my procedure in it (because then this nifty little form won't be as portable!), so I tried declaring the bailout() procedure in the init and/or load events of the form - but it won't let me do that either.
>
>So the last straw I'm grasping at is: Can I fake VFP into executing multiple commands as though it were a single command? Kind of like in C++ where you can use the "curly brackets" { and }. Then I could use a line like:
>
>ON KEY ESC {wait window "1"; wait window "2"}
>
>But that doesn't work either!
>
>Any/all ideas appreciated - TIA!
>
>Kevin E. Stroud
>
kestrou@nexlan.com