1. sequences read from file
hi everybody
i have a file and in that file (referred to as fn_in) there is this:
{{00,10,01},{"ç",3,"text"},{"#",5,"text"}
{"ç",1500,"text3"},{"#",1600,"text4"}
{"ç",1500,"text5"},{"#",1600,"text6"}}
{{00,10,02},{"ç",3,"text"},{"#",5,"text"}
{"ç",1500,"text3"},{"#",1600,"text4"}
{"ç",1500,"text5"},{"#",1600,"text6"}}
now i use
line = gets(fn_in)
if sequence(line) then
puts(fn_out, line[1][1])
end if
i thought this would write this into the output file (referred to as
fn_out)
00
because i thought that line[1] is {00,10,01} and then line[1][1]
should be 00.
but it gives me an error (attempt of subscripting an atom).
what do i do wrong?
thanx in advance
felix
2. Re: sequences read from file
Felix,
To do what you want, you need to convert line from a string of characters into
the sequence the string represents. Then you need to be sure that whatever you're
printing is in the proper representation for printing.
For example (untested),
sequence line
line = value("{0, "howdy", {42}}) -- use the value function!
puts(1, sprint(line[1]) & "\n") -- "0"
puts(1, line[2] & "\n") -- the string "howdy"
puts(1, sprint(line[3]) & "\n") -- the sequence "{42}"
In a nutshell, learn about value and sprint and use them where appropriate.
Does that clarify things any?
George
--
On Thu, 01 Feb 2001 06:24:21
felix geiger wrote:
>hi everybody
>
>i have a file and in that file (referred to as fn_in) there is this:
>
>{{00,10,01},{"g",3,"text"},{"#",5,"text"}
>{"g",1500,"text3"},{"#",1600,"text4"}
>{"g",1500,"text5"},{"#",1600,"text6"}}
>{{00,10,02},{"g",3,"text"},{"#",5,"text"}
>{"g",1500,"text3"},{"#",1600,"text4"}
>{"g",1500,"text5"},{"#",1600,"text6"}}
>
>
>now i use
>
> line = gets(fn_in)
> if sequence(line) then
> puts(fn_out, line[1][1])
> end if
>
>i thought this would write this into the output file (referred to as
>fn_out)
>
>00
>
>because i thought that line[1] is {00,10,01} and then line[1][1]
>should be 00.
>
>but it gives me an error (attempt of subscripting an atom).
>
>what do i do wrong?
>
>thanx in advance
>felix
>
>
>
Get your small business started at Lycos Small Business at
http://www.lycos.com/business/mail.html
3. Re: sequences read from file
felix geiger wrote:
>hi everybody
>
>i have a file and in that file (referred to as fn_in) there is this:
>
>{{00,10,01},{"g",3,"text"},{"#",5,"text"}
> line =3D gets(fn_in)
> if sequence(line) then
> puts(fn_out, line[1][1])
> end if
Besides the lack of commas on split-line sequences,
eg.
{{},{},{}, -- see the comma at the end? This says the line continues.
{},{}}
your real problem is the line that says
line =3D gets(fn_in).
This is where the difference between get, gets, and getc can get a little =
confusing (pardon the pun). =20
Use get when you want to retrieve a list of numbers or sequences.
Use gets when you want to retrieve a string.
Use getc when you need a single character or byte.
If you change that line to
line =3D get(fn_in)
and remember to put commas at the end of sequences that continue
to the next line, your problem should be fixed.
HTH,
Michael J. Sabal
4. Re: sequences read from file
You should use get() instead of gets().
-- example
sequence result
result = get(fn_in)
if result[1] = GET_SUCCESS then
if sequence(result[2]) then
... etc.
- Colin Taylor
----- Original Message -----
From: felix geiger <felix.geiger at GMX.CH>
To: <EUforum at topica.com>
Sent: Thursday, February 01, 2001 9:24 AM
Subject: sequences read from file
hi everybody
i have a file and in that file (referred to as fn_in) there is this:
{{00,10,01},{"ç",3,"text"},{"#",5,"text"}
{"ç",1500,"text3"},{"#",1600,"text4"}
{"ç",1500,"text5"},{"#",1600,"text6"}}
{{00,10,02},{"ç",3,"text"},{"#",5,"text"}
{"ç",1500,"text3"},{"#",1600,"text4"}
{"ç",1500,"text5"},{"#",1600,"text6"}}
now i use
line = gets(fn_in)
if sequence(line) then
puts(fn_out, line[1][1])
end if
i thought this would write this into the output file (referred to as
fn_out)
00
because i thought that line[1] is {00,10,01} and then line[1][1]
should be 00.
but it gives me an error (attempt of subscripting an atom).
what do i do wrong?