ESQL-C
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I am currently using Informix 7.31 FC6 and am trying to write an ESQL-C program that works with substrings in a certain way. I am basically trying to reference a substring of a variable in the program. For example if my string was "John Doe" I want to strip out the "Doe". I have tried countless ways and the only way I can think of is using the function "bycopy". This function will work fine but seems very tedious for something so simple. Is there an easier way of doing this?? Any help or suggestions would be greatly appreciated, Benny Lago Alliance Entertainment, Inc. Sent via Deja.com http://www.deja.com/ Before you buy.
benlag@aent.com wrote: I think you need to read a C programming book, either that or you are just thinking too hard. Unless you are defining your host variables as FIXCHAR they are all C strings and NULL terminated (though space padded unless you use host type STRING) so you can use the "C" string library function strtok() to tokenize the string: char $NameString[32]; char lcl_first[16]; char lcl_last[16]; FETCH fullname..... INTO :NameString; strcpy( lcl_first, strtok( NameString, " " ); strcpy( lcl_last, strtok( (char *)NULL, " " ); Art S. Kagel > I am currently using Informix 7.31 FC6 and am trying to write an ESQL-C > program that works with substrings in a certain way. I am basically > trying to reference a substring of a variable in the program. For > example if my string was "John Doe" I want to strip out the "Doe". I > have tried countless ways and the only way I can think of is using the > function "bycopy". > > This function will work fine but seems very tedious for something so > simple. Is there an easier way of doing this?? > > Any help or suggestions would be greatly appreciated, > > Benny Lago > Alliance Entertainment, Inc. > > Sent via Deja.com http://www.deja.com/ > Before you buy.
Thanks for your help everyone. In article <397C5631.BAC19427@bloomberg.net>, kagel@bloomberg.net wrote: > benlag@aent.com wrote: > > I think you need to read a C programming book, either that or you are > just thinking too hard. Unless you are defining your host variables > as FIXCHAR they are all C strings and NULL terminated (though space > padded unless you use host type STRING) so you can use the "C" string > library function strtok() to tokenize the string: > > char $NameString[32]; > char lcl_first[16]; > char lcl_last[16]; > > FETCH fullname..... INTO :NameString; > > strcpy( lcl_first, strtok( NameString, " " ); > strcpy( lcl_last, strtok( (char *)NULL, " " ); > > Art S. Kagel > > > I am currently using Informix 7.31 FC6 and am trying to write an ESQL-C > > program that works with substrings in a certain way. I am basically > > trying to reference a substring of a variable in the program. For > > example if my string was "John Doe" I want to strip out the "Doe". I > > have tried countless ways and the only way I can think of is using the > > function "bycopy". > > > > This function will work fine but seems very tedious for something so > > simple. Is there an easier way of doing this?? > > > > Any help or suggestions would be greatly appreciated, > > > > Benny Lago > > Alliance Entertainment, Inc. > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy.