Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

4gl string parsing

 
   Database Forums (Home) -> Informix RSS
Next:  Tracking events  
Author Message
monkeys paw

External


Since: Jan 26, 2011
Posts: 1



(Msg. 1) Posted: Wed Jan 26, 2011 1:01 pm
Post subject: 4gl string parsing
Archived from groups: comp>databases>informix (more info?)

I need to parse a comma separated list of strings
in 4gl. If there is a number less than 290000 in the
list i need to return a true value, otherwise false.
I have something like:

let topix = "300000,310010,420011,650934,280000"
let top_loop = 0

while (top_loop < length(topic))
if (topix[top_loop, top_loop + 6] < 290000) then
return 1
end if
end while
return 0

 >> Stay informed about: 4gl string parsing 
Back to top
Login to vote
mpruet

External


Since: Jan 27, 2011
Posts: 2



(Msg. 2) Posted: Thu Jan 27, 2011 4:25 pm
Post subject: Re: 4gl string parsing [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jan 26, 12:01 pm, monkeys paw wrote:
> I need to parse a comma separated list of strings
> in 4gl. If there is a number less than 290000 in the
> list i need to return a true value, otherwise false.
> I have something like:
>
> let topix = "300000,310010,420011,650934,280000"
> let top_loop = 0
>
>   while (top_loop < length(topic))
>         if (topix[top_loop, top_loop + 6] < 290000) then
>             return 1
>         end if
>   end while
>   return 0

Converting my prior suggestion into a stored procedure...

This will let you do something like

execute function tst_string(100,"400,800,-1,50000");

--------------------------------------------------------------------------------------------

create function tst_string(maxnum int, str lvarchar) returns int
define tnum int;
define len int;
define sign int;
define sub int;
define tchar char(1);

let len = length(trim(str));
let sub = 1;

while sub < len
let tnum = 0;
let sign = 1;
let tchar = substring(str from sub for 1);
if tchar = '-' then
let sign = -1;
let sub = sub + 1;
let tchar = substring(str from sub for 1);
end if;

while ((sub < len) and (tchar != ','))
if (tchar != ',') then
let tnum = (tnum * 10) || tchar;
end if;
let sub = sub + 1;
let tchar = substring(str from sub for 1);
end while;
let sub = sub + 1;
if (tnum * sign) < maxnum then
return 1;
end if;
end while;

return 0;
end function;

 >> Stay informed about: 4gl string parsing 
Back to top
Login to vote
mpruet

External


Since: Jan 27, 2011
Posts: 2



(Msg. 3) Posted: Thu Jan 27, 2011 4:33 pm
Post subject: Re: 4gl string parsing [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jan 26, 12:01 pm, monkeys paw wrote:
> I need to parse a comma separated list of strings
> in 4gl. If there is a number less than 290000 in the
> list i need to return a true value, otherwise false.
> I have something like:
>
> let topix = "300000,310010,420011,650934,280000"
> let top_loop = 0
>
>   while (top_loop < length(topic))
>         if (topix[top_loop, top_loop + 6] < 290000) then
>             return 1
>         end if
>   end while
>   return 0

Opps - minor correction. the || should have been +

drop function tst_string(int, lvarchar);
create function tst_string(maxnum int, str lvarchar) returns int
define tnum int;
define len int;
define sign int;
define sub int;
define tchar char(1);

let len = length(trim(str));
let sub = 1;

while sub < len
let tnum = 0;
let sign = 1;
let tchar = substring(str from sub for 1);
if tchar = '-' then
let sign = -1;
let sub = sub + 1;
let tchar = substring(str from sub for 1);
end if;

while ((sub < len) and (tchar != ','))
if (tchar != ',') then
let tnum = (tnum * 10) + tchar;
end if;
let sub = sub + 1;
let tchar = substring(str from sub for 1);
end while;
let sub = sub + 1;
if (tnum * sign) < maxnum then
return 1;
end if;
end while;

return 0;
end function;
 >> Stay informed about: 4gl string parsing 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
onbar -r / 760 Error parsing bootfile ixbar.0 - Hi guys, we want to restore a backup (Legato Networker 7.1) of a IDS 9.40 to another server. On 9.20 we copied the ixbar.0 and oncfg...-files to this server and started the restore with 'onbar -r' But now we get this error: 2005-10-20 15:38:00 760 ....

Finding the Position of a String Within a String - Hello All, IDS version 9.40FC6. Does anyone know of a function that will return the position of the first occurrence of a value within a string? For example, something that would return '3' if searching for 'C' in string 'ABCD'. Thanks in advance for...

Need help to empty data in chunk before drop it. - Hello all, I've located one bad chunk in my database. I tried to drop it, but I can't drop chunk#26 because some tables extent still in this chunk. Since, most of the data in this chunk are related to system tables, I am not sure if it is safe to unload...

ontape vs onbar - IDS 10.0FC3 on Solaris 9 I'm doing some backups to disk. An ontape backup of the 30G database with a 768k TAPEBLK takes about 25 mins, but an onbar -b -L 0 takes over twice as long. I wonder if it's that the block size being used is much smaller? ..

Restore (ontape -r) problems - Hi We have two SPARC machines running Solaris 8 & IDS 7.31.UD6. One is a Sun (test), the other a Futjitsu(live). The test box has an instance of online running, with an exact copy of the onconfig from the live box. All that has been changed is..
   Database Forums (Home) -> Informix All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]