Re: Converting string to numerical data - regardless of errors
Posted in 1994
In article <39bniu$kci@emory.mathcs.emory.edu> kestnb!mdk@uunet.uu.net "Michael Kastler" writes: > Hi, > > I'm trying to take user inputted string data in Informix 4GL and use > parts of it in an integer variable. > > Unfortunately, if the user does not enter a number in the area that I > take my data out of the string from, trying to assign it to the > variable crashes the program. I really, really don't want to turn on > error trapping for the program - does anyone know of any way to check > if specific data is numerical or text or a way to convert any text to a > form that is handleable by an integer variable (such as turning all > text into 0's or even their ascii codes would be acceptable)? > > I appreciate your time. > You could turn on trapping just for the one assign statement perhaps ? whenever error continue let numvar=numstr[1,3] whenever error stop if status=0 then display numvar else display "Error converting" end if Mike Aubury