Re: 4GL integer prompt
Posted in 1994
en015@cleveland.Freenet.Edu (David J. Lutz) writes: >Q: I want to prompt for a smallint value using "prompt". If a user >enters a char value I get a character to numeric conversion error. Is >there method to enforce integer values in the prompt statement? I >can write a programatic solution around the prompt but would like 4GL >to handle this if possible. >I am using I-4GL 4.10 on an RS/6000 running AIX 3.2.0. Suggestions? A couple possibilities: DEFINE smint SMALLINT INITIALIZE smint TO NULL WHILE smint IS NULL WHENEVER ERROR CONTINUE PROMPT "Enter a Number between -32,000 and 32,000:" FOR smint IF status < 0 THEN ERROR "Enter a valid number" INITIALIZE smint TO NULL END IF WHENEVER ERROR STOP END WHILE or: DEFINE ans CHAR(6) DEFINE smint,x SMALLINT INITIALIZE ans TO NULL WHILE ans IS NULL PROMPT "Enter a Number between -32,000 and 32,000:" FOR ans IF ans IS NOT NULL THEN FOR x = 1 TO LENGTH(ans) IF ans[x] NOT MATCHES "[0123456789]" AND ans[x] != "-" THEN ERROR "Enter a valid number" INITIALIZE ans TO NULL EXIT FOR END IF END FOR END IF LET smint = ans CLIPPED END WHILE I'm not where I can test the above, but I think I've got it all. ============================================================ Dennis J. Pimple Informix Software Inc Senior Consultant Denver Colorado USA dennisp@informix.com Voice:303-850-0210 Fax:303-779-4025