F4 Key - Urgent

nate100

Member
Hello,
I have the following code:


def var vtax as char label "Taxable" format "x(1)".
def var v_yn as character INITIAL "y,n".

form
vtax skip(1)
with frame frma with side-label
Title 'Tax Information - Enter y/n' overlay CENTER.

update vtax with frame frma.

if LOOKUP(vtax,v_yn) = 0 THEN DO:
message "Enter either y/n for IC Taxable Field".
next-prompt vtax with frame frma.
undo, retry.
end.

What I need to do is that if the user types in anything else other than y/n and then hits the F1 key, it prompts them with the following message "Enter either y/n for IC Taxable Field" THIS WORKS. But if the user hits the F4 key at anytime, I need to validate that vtax is y/n. Only if it is, then the user can exit by hitting the F4 key.

What i came up with was the following but does not work:



def var vtax as char label "Taxable" format "x(1)".
def var v_yn as character INITIAL "y,n".

form
vtax skip(1)
with frame frma with side-label
Title 'Tax Information - Enter y/n' overlay CENTER.

mainloop:
repeat.

update vtax with frame frma.

if lastkey = keycode("F6") and LOOKUP(vtax,v_yn) = 0 then next mainloop.
else leave.

if LOOKUP(vtax,v_yn) = 0 THEN DO:
message "Enter either y/n for IC Taxable Field".
next-prompt vtax with frame frma.
undo, retry.
end.

end. /* repeat */


I simply cannot this get code to work if the F4 key hit and need to validate that the field has a value of either y or n .

Thanks for the heop
 
Why not make vtax a logical?
Code:
define variable vtax as logical format 'y/n' no-undo.

This way only 'y' or 'n' can be entered. You can always convert this to (any) character after the data is entered.

Casper.
 
Try


Code:
def var vtax as char label "Taxable" format "x(1)".
def var v_yn as character INITIAL "y,n".
 
form
  vtax skip(1)
  with frame frma with side-label
  Title 'Tax Information - Enter y/n' overlay CENTER.
 
on "end-error" of vtax in frame frma do:
  assign vtax.
  if lookup (vtax,v_yn) = 0 then do:
    vtax = "".
    display vtax with frame frma.
    message "Enter either y/n for IC Taxable Field".
    return no-apply.
  end.
end.
 
mainloop:
repeat.
  update vtax with frame frma.
  if LOOKUP(vtax,v_yn) = 0 THEN DO:
    message "Enter either y/n for IC Taxable Field".
    next-prompt vtax with frame frma.
    undo, retry.
  end.
  if lastkey = keycode("F6") and LOOKUP(vtax,v_yn) = 0 then 
    next mainloop.
  else 
    leave mainloop.
end. /* repeat */
 
Back
Top