![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
If i have a string CSV and want to loop through the elements how would i do so? e.g. let topix = "300000,310010,420011,650934" I need to parse this string and determine if it contains a number less than 290000. I,m doing something like: while (top_loop < length(topic)) if (topix[top_loop, top_loop + 6] < 290000) then return 1 end if end while return 0 |
#3
| |||
| |||
|
| On 26/01/11 13:56, monkeys paw wrote: If i have a string CSV and want to loop through the elements how would i do so? e.g. let topix = "300000,310010,420011,650934" I need to parse this string and determine if it contains a number less than 290000. I,m doing something like: while (top_loop< length(topic)) if (topix[top_loop, top_loop + 6]< 290000) then return 1 end if end while return 0 BRAG that can be easily achieved through my scripting language SQSL (see sig), and you don't even need to go through that clumsy type conversion! /BRAG |
#4
| |||
| |||
|
|
If i have a string CSV and want to loop through the elements how would i do so? e.g. let topix = "300000,310010,420011,650934" I need to parse this string and determine if it contains a number less than 290000. I,m doing something like: while (top_loop < length(topic)) * * * if (topix[top_loop, top_loop + 6] < 290000) then * * * * * return 1 * * * end if end while return 0 |
#5
| |||
| |||
|
|
On 1/26/2011 9:50 AM, Marco Greco wrote: On 26/01/11 13:56, monkeys paw wrote: If i have a string CSV and want to loop through the elements how would i do so? e.g. let topix = "300000,310010,420011,650934" I need to parse this string and determine if it contains a number less than 290000. I,m doing something like: while (top_loop< length(topic)) if (topix[top_loop, top_loop + 6]< 290000) then return 1 end if end while return 0 BRAG that can be easily achieved through my scripting language SQSL (see sig), and you don't even need to go through that clumsy type conversion! /BRAG I'm using Informix. I need the language hoop to parse a CSV and compare the individual components to a particular value. |
#6
| |||
| |||
|
|
Date: Wed, 26 Jan 2011 16:21:35 +0000 From: marco (AT) 4glworks (DOT) com To: informix-list (AT) iiug (DOT) org Subject: Re: looping through CSV list As others have pointed out, the question is - do you want to do it frominside the engine, or do you want to do it from a client? If you want to do itfrom a client - ie read the file, parse it and then do something with it, like insert values into a database, then you have many options. SQSL could easily do that for you: let topix = "300000,310010,420011,650934" for top_loop in <+ get topix +>; if (top_loop< 290000) then; # do something end if; end for; # do something else |
#7
| |||
| |||
|
|
On Jan 26, 7:56 am, monkeys paw<mon... (AT) joemoney (DOT) net> wrote: If i have a string CSV and want to loop through the elements how would i do so? e.g. let topix = "300000,310010,420011,650934" I need to parse this string and determine if it contains a number less than 290000. I,m doing something like: while (top_loop< length(topic)) if (topix[top_loop, top_loop + 6]< 290000) then return 1 end if end while return 0 I'm guessing that you are using 'c' so here's how I would do it. int parce(char **tpntParm) { int tnum = 0; int sign = 1; char *tpnt = *tpntParm; if (*tpnt == '-') { sign = -1; tpnt++; } while (*tpnt&& (*tpnt != ',')) { tnum *= 10; tnum += (*tpnt - '0'); } *tpntParm = tpnt; if ((tnum * sign)< 290000) return 1; else return 0; } |
#8
| |||
| |||
|
|
Date: Wed, 26 Jan 2011 12:52:05 -0500 From: monkey (AT) joemoney (DOT) net Subject: Re: looping through CSV list To: informix-list (AT) iiug (DOT) org No, i was referring to 4gl. I don't think i have to interface with C in order to do this. Would 4gl handle this on it's own? |
![]() |
| Thread Tools | |
| Display Modes | |
| |