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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VERIFY USER INPUT

Status
Not open for further replies.

IncredibleVolk

Technical User
Apr 2, 2004
67
US
Someone showed me this a while ago but I can't seem to find it. I'd like to have the user enter input, ask them to verify the input they entered, and give them the opportunity to correct it if they made a mistake. I know that it looped back if the user selected "no" but I'm not sure how it worked. I'd like to prompt the user to enter an account number and then have a prompt (or dialog box) come up to say "Are you sure this is the account number you meant to enter?" If they choose no it will return them back to the account number input box. Any help would be greatly appreciated.
 
Here is an example I came up with based on one of the sample scripts out of the help file. The way it works is that the value of the edit box (string variable TextStr) is displayed to the user when they click on the Exit button. If they answer Yes to the prompt, then the while loop is exited. If they say no, then the script drops through the rest of the case statement, and the while loop continues executing until the next dialog event.

proc main
string TextStr ; Text from dialog box.
integer Event ; Dialog box event.
integer iChoice
string sPrompt

; Define and display dialog with edit box.
dialogbox 0 0 0 100 70 11 "Edit Box Example"
editbox 1 5 5 90 40 TextStr MULTILINE
pushbutton 2 25 50 50 14 "E&xit"
enddialog
while 1
dlgevent 0 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0 ; No event occurred.
endcase

case 1 ; Edit box was changed.
endcase
case 2 ; Exit event selected.
strfmt sPrompt "You entered %s, is that correct?" TextStr
sdlgmsgbox "Confirm choice" sPrompt QUESTION YESNO iChoice
if iChoice == 6
exitwhile ; Exit the loop.
endif
endcase
endswitch
endwhile
dlgdestroy 0 CANCEL ; Destroy dialog box.
if not nullstr TextStr ; See that TextStr isn't empty.
usermsg "You typed:`r`r%s" TextStr
else
usermsg "No text entered."
endif
endproc

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top