Re: HELP!!!

new topic     » goto parent     » topic index » view thread      » older message » newer message

EU>Thanks for the Help!
EU>I tried that and it produced this error

EU>edi.ex:10
EU>type_check failure, line is -1

EU>Global & Local Variables

EU> edi.ex:
EU>    line = -1
EU>    data = <no value>
EU>    f = 3

EU>Did I do something obviously wrong here?
No. I didn't put in anything to handle an ecxception.

EU>Bryan

>By The Way,
>    The Text file contains more than one record.  There are 40 records in this
>file which means there are 40 ST and 40 SE all in the same file.  Thats why
>I'm trying to pull them out into their own file.

Ok. How about this:

>Bryan

constant START = "ST\n"
constant END = "SE\n"
function GetRecord(integer f)
        object line -- In case it gets to the end of the file
        sequence data
        line = gets(f)
        while not equal(line,START) and sequence(line) do
                line = gets(f)
        end while
        if integer(line) then -- It got to the end of the file
                return -1
        end if
        data = {}
        line = gets(f)
        while not equal(line,END) and sequence(line) do
                data &= line
                line = gets(f)
        end while
        return data
end function

Now just call GetRecord(f) for each record. Example:

integer in, out, n
object r
in = open("infile.txt","r")
n = 1
r = GetRecord(in)
while r

Just a sec. I'll finish this in another e-mail.


Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu