For Programmers: Free Programming Magazines  


Home > Archive > Cobol > June 2004 > Extract a piece of information from a txt file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Extract a piece of information from a txt file
TekSoft

2004-06-18, 3:55 pm

Hi,
I've a txt file with several lines with not fixed length and I use
PowerCobol v7.
I want to extract a number between this character "@" and "\n" (carriage
return/line feed). For example:

4555599544455.455565@555555
59.214@1.184@60.398 >> this is it
1144@555555@58588888888888888@89898

and I want to extract this number "60.398" from the second line. I can I do
it?

Thanks
JM
Euromercante


Frederico Fonseca

2004-06-18, 8:55 pm

On Fri, 18 Jun 2004 18:07:00 +0100, "TekSoft" <eute@sapo.pt> wrote:

>Hi,
> I've a txt file with several lines with not fixed length and I use
>PowerCobol v7.
> I want to extract a number between this character "@" and "\n" (carriage
>return/line feed). For example:
>
>4555599544455.455565@555555
>59.214@1.184@60.398 >> this is it
>1144@555555@58588888888888888@89898
>
>and I want to extract this number "60.398" from the second line. I can I do
>it?
>
>Thanks
>JM
>Euromercante
>

Use the unstring statement with a delimiter of "@".

e.g.
unstring fieldx delimited by all "@"
into field1, field2, field3, field4

On the above case result would be

line 1
field1 4555599544455.455565
field2 555555

Line 2
field1 59.214@1.184
field2 60.398

Line 3
field1 1144
field2 555555
field3 58588888888888888
field4 89898




Frederico Fonseca
ema il: frederico_fonseca at syssoft-int.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com