Checking datatype of CHAR variable in 4GL
Posted in 1998
Feel free to use this if you want it: function is_number( wstr ) define wstr char( 30 ) define i, n smallint if wstr = ' ' or wstr is null then return FALSE end if let n = length( wstr ) for i = 1 to n if wstr[ i ] <> ' ' then exit for end if end for if i < n then if wstr[ i ] = '-' or wstr[ i ] = '+' then let i = i + 1 end if end if for i = i to n if not is_numeric( wstr[ i ] ) then return FALSE end if end for return TRUE end function function is_numeric( c ) define c char( 1 ) if ( c >= '0' and c <= '9' ) or c = '.' then return TRUE end if return FALSE end function The only thing that it doesn't see are multiple decimal points. Carlos. --- Carlos Costa e Silva <ccs@minimal.pt> Minimal - Forma''o e Consultoria R. Prof. Vitor Fontes 10 A/B 1600 Lisboa Portugal -----Original Message----- From: Ben Knox [mailto:ben@dircon.net] Posted At: Quinta-feira, 12 de Fevereiro de 1998 13:00 Posted To: informix Conversation: Checking datatype of CHAR variable in 4GL Subject: Checking datatype of CHAR variable in 4GL Does anyone if there a function in Informix 4gl (version 4) which will let you check the contents of a CHAR variable to see whether or not it is a valid number, without causing a numeric conversion error? ... Regards, Ben