Re: upper() - NOT the usual FAQ :-)
Posted in 1997
If only! :-( >From: Douglas Wilson <dgwilson@gte.net> >Date: 15 May 1997 16:20:16 GMT >X-Informix-List-Id: <news.37944> > >Richard Thomas wrote: > >> FOR i = 1 TO l >> IF str[1,1] BETWEEN "a" AND "z" THEN >> IF str[1,1] = 'a' THEN >> LET retstr = retstr || 'A'; >> ELIF str[1,1] = 'b' THEN >> LET retstr = retstr || 'B'; > >I'm not an expert on stored procedures, but shouldn't the >str[] variables be 'str[i,1]', not 'str[1,1]'? No, on two counts. First, the substring notation uses [start,end=1] not [start,len], so the more correct notation would be str[i,i] or, preferably, just str[i]. Secondly, SPL is brain-dead. It does not allow variables in substring expressions. So the notation using [i] doesn't work at all -- syntax error. Why else do you think these functions are so utterly ghastly? If we could do arbitrary substringing with variables, then life would be one heck of a lot easier: LET lower = "abcdefghijklmnopqrstuvwxyz"; LET upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; FOR i = 1 TO LENGTH(str) LET n = index(lower, str[i]); IF n != 0 THEN LET str[i] = upper[n]; END IF END FOR If only!!! :-((( Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>