1. simple question
Please bear with me, as I'm a brand spankin' new user
of Euphoria.
All I'm trying to do is read a text file into a
sequence, and then turn around and print the sequence
onscreen. I'm using the following code:
sequence buffer
object line
integer fn
fn = open("c:\\filename.txt","r")
if fn = -1 then
puts(1,"Couldn't open file\n")
abort(1)
end if
while 1 do
line = gets(fn)
if atom(line) then
exit
end if
buffer = append(buffer,line)
end while
printf(1,"%s",{buffer})
When I try to run the above, I get the following error
message:
"sequence found inside character string"
What am I doing wrong?
2. Re: simple question
There are actually 2 problems here. First, buffer is never initialized.
You should have a line near the beginning that reads buffer = "" or
buffer = {}. As for the second problem that you stated, the solution
depends on whether you want one long string or a sequence of strings.
If you want one long string, you should be using buffer = buffer & line.
If you want a sequence of strings, you should have a loop to print
them:
for ctr = 1 to length(buffer) do
printf(1,"%s\n",{buffer[ctr]})
end for
HTH,
Mike Sabal
>>> csaik2002 at yahoo.com 12/19/02 02:01PM >>>
Please bear with me, as I'm a brand spankin' new user
of Euphoria.
All I'm trying to do is read a text file into a
sequence, and then turn around and print the sequence
onscreen. I'm using the following code:
sequence buffer
object line
integer fn
fn = open("c:\\filename.txt","r")
if fn = -1 then
puts(1,"Couldn't open file\n")
abort(1)
end if
while 1 do
line = gets(fn)
if atom(line) then
exit
end if
buffer = append(buffer,line)
end while
printf(1,"%s",{buffer})
When I try to run the above, I get the following error
message:
"sequence found inside character string"
What am I doing wrong?
3. Re: simple question
Chris,
The buffer contains a sequence of text strings. You can get a single text
string by using the &= operator instead of append:
buffer &= line
Another solution is to print out the buffer one line at a time:
for i = 1 to length buffer do
printf(1,"%s",{buffer[i]})
end for
- Colin Taylor
----- Original Message -----
From: "Chris Saik" <csaik2002 at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, December 19, 2002 2:01 PM
Subject: simple question
>
>
> Please bear with me, as I'm a brand spankin' new user
> of Euphoria.
>
> All I'm trying to do is read a text file into a
> sequence, and then turn around and print the sequence
> onscreen. I'm using the following code:
>
> sequence buffer
> object line
> integer fn
>
> fn = open("c:\\filename.txt","r")
> if fn = -1 then
> puts(1,"Couldn't open file\n")
> abort(1)
> end if
>
> while 1 do
> line = gets(fn)
> if atom(line) then
> exit
> end if
> buffer = append(buffer,line)
> end while
>
> printf(1,"%s",{buffer})
>
> When I try to run the above, I get the following error
> message:
>
> "sequence found inside character string"
>
> What am I doing wrong?
>
>
>
>
4. Re: simple question
> printf(1,"%s",{buffer})
>
> When I try to run the above, I get the following error
> message:
>
> "sequence found inside character string"
At this point, buffer is actually a sequence of sequences.
To see this, use the following:
? buffer
What you'll need to do is either loop through length( buffer ) and print
each...
for t=1 to length(buffer) do
printf(1, "%s", {buffer[t]} )
end for
OR
when you create buffer, use
buffer &= line
instead of
buffer = append(buffer, line)
Then you can use
printf(1, "%s", {buffer})
I think. :)
-ck
5. Re: simple question
Thank you Mike! That worked perfectly. I'll get a
grip on the language sooner or later... =)
--- Sabal.Mike at notations.com wrote:
>
> There are actually 2 problems here. First, buffer
> is never initialized.
> You should have a line near the beginning that
> reads buffer = "" or
> buffer = {}. As for the second problem that you
> stated, the solution
> depends on whether you want one long string or a
> sequence of strings.
> If you want one long string, you should be using
> buffer = buffer & line.
> If you want a sequence of strings, you should have
> a loop to print
> them:
>
> for ctr = 1 to length(buffer) do
> printf(1,"%s\n",{buffer[ctr]})
> end for
>
> HTH,
> Mike Sabal
>
> >>> csaik2002 at yahoo.com 12/19/02 02:01PM >>>
>
> Please bear with me, as I'm a brand spankin' new
> user
> of Euphoria.
>
> All I'm trying to do is read a text file into a
> sequence, and then turn around and print the
> sequence
> onscreen. I'm using the following code:
>
> sequence buffer
> object line
> integer fn
>
> fn = open("c:\\filename.txt","r")
> if fn = -1 then
> puts(1,"Couldn't open file\n")
> abort(1)
> end if
>
> while 1 do
> line = gets(fn)
> if atom(line) then
> exit
> end if
> buffer = append(buffer,line)
> end while
>
> printf(1,"%s",{buffer})
>
> When I try to run the above, I get the following
> error
> message:
>
> "sequence found inside character string"
>
> What am I doing wrong?
>
>
>
>
>
>
6. Re: simple question
Thanks to you and all who responded!
Chris
--- "C. K. Lester" <cklester at yahoo.com> wrote:
>
> > printf(1,"%s",{buffer})
> >
> > When I try to run the above, I get the following
> error
> > message:
> >
> > "sequence found inside character string"
>
> At this point, buffer is actually a sequence of
> sequences.
>
> To see this, use the following:
>
> ? buffer
>
> What you'll need to do is either loop through
> length( buffer ) and print
> each...
>
> for t=1 to length(buffer) do
> printf(1, "%s", {buffer[t]} )
> end for
>
> OR
>
> when you create buffer, use
>
> buffer &= line
>
> instead of
>
> buffer = append(buffer, line)
>
> Then you can use
>
> printf(1, "%s", {buffer})
>
> I think. :)
>
> -ck
>
>
>
>
>
>
7. Re: simple question
- Posted by rubis at fem.unicamp.br
Dec 19, 2002
Hey Cris;
I'm just doing the same for a cgi routine. Try this:
give buffer a first value: buffer={}
I holpe this solve your problem.
Rubens
At 16:01 19/12/2002, you wrote:
>
>Please bear with me, as I'm a brand spankin' new user
>of Euphoria.
>
>All I'm trying to do is read a text file into a
>sequence, and then turn around and print the sequence
>onscreen. I'm using the following code:
>
>sequence buffer
>object line
>integer fn
>
>fn = open("c:\\filename.txt","r")
>if fn = -1 then
> puts(1,"Couldn't open file\n")
> abort(1)
>end if
>
>while 1 do
> line = gets(fn)
> if atom(line) then
> exit
> end if
> buffer = append(buffer,line)
>end while
>
>printf(1,"%s",{buffer})
>
>When I try to run the above, I get the following error
>message:
>
>"sequence found inside character string"
>
>What am I doing wrong?
>
>
>
8. Re: simple question
Hello Cris and Rubens,
If your working on a CGI orientated scheme then you may (or may not) find
my CGI-Online phone book in the RDS archives worth at least a quick look.
Search on "intphone". The eucgi.e include file has a couple of handy
routines. I'm sure they could be improved upon
Regards,
Andy Cranston.
At 06:09 PM 12/19/02 -0300, you wrote:
>
>Hey Cris;
>
>I'm just doing the same for a cgi routine. Try this:
>
>give buffer a first value: buffer={}
>
>
>I holpe this solve your problem.
>Rubens
>
>At 16:01 19/12/2002, you wrote:
>>
>>Please bear with me, as I'm a brand spankin' new user
>>of Euphoria.
>>
>>All I'm trying to do is read a text file into a
>>sequence, and then turn around and print the sequence
>>onscreen. I'm using the following code:
>>
>>sequence buffer
>>object line
>>integer fn
>>
>>fn = open("c:\\filename.txt","r")
>>if fn = -1 then
>> puts(1,"Couldn't open file\n")
>> abort(1)
>>end if
>>
>>while 1 do
>> line = gets(fn)
>> if atom(line) then
>> exit
>> end if
>> buffer = append(buffer,line)
>>end while
>>
>>printf(1,"%s",{buffer})
>>
>>When I try to run the above, I get the following error
>>message:
>>
>>"sequence found inside character string"
>>
>>What am I doing wrong?
>>
>>
>
>
>
9. Re: simple question
- Posted by rubis at fem.unicamp.br
Dec 21, 2002
Hey Andy;
This file was the first I have download to learn a bit about cgi. :>) !
Rubens
At 22:27 19/12/2002, you wrote:
>
>Hello Cris and Rubens,
>
>If your working on a CGI orientated scheme then you may (or may not) find
>my CGI-Online phone book in the RDS archives worth at least a quick look.
>Search on "intphone". The eucgi.e include file has a couple of handy
>routines. I'm sure they could be improved upon
>
>Regards,
>
>Andy Cranston.
>
>At 06:09 PM 12/19/02 -0300, you wrote:
> >
> >Hey Cris;
> >
> >I'm just doing the same for a cgi routine. Try this:
> >
> >give buffer a first value: buffer={}
> >
> >
> >I holpe this solve your problem.
> >Rubens
> >
> >At 16:01 19/12/2002, you wrote:
> >>
> >>Please bear with me, as I'm a brand spankin' new user
> >>of Euphoria.
> >>
> >>All I'm trying to do is read a text file into a
> >>sequence, and then turn around and print the sequence
> >>onscreen. I'm using the following code:
> >>
> >>sequence buffer
> >>object line
> >>integer fn
> >>
> >>fn = open("c:\\filename.txt","r")
> >>if fn = -1 then
> >> puts(1,"Couldn't open file\n")
> >> abort(1)
> >>end if
> >>
> >>while 1 do
> >> line = gets(fn)
> >> if atom(line) then
> >> exit
> >> end if
> >> buffer = append(buffer,line)
> >>end while
> >>
> >>printf(1,"%s",{buffer})
> >>
> >>When I try to run the above, I get the following error
> >>message:
> >>
> >>"sequence found inside character string"
> >>
> >>What am I doing wrong?
> >>
> >>
>
>
10. simple question
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C241FE.EE9ADBA0
charset="iso-8859-1"
Hi,
This should be an easy question for someone who has
been coding in euphoria for a while:
How can I make sure my bitmaps are in a supported format?
I get error 3-unsupported format when I try to read my
bitmaps in,yet I read in bitmaps that I got from the archive
and they work fine.I don't know how to make my bitmaps
256 colors.I am using windows pro(NT) "paintbrush" application.
I found a way to trick the interpreter into taking my bitmaps,
I save an image as a bitmap,then go paint on it.But this is
the long route.I want to just:
x=3Dread_bitmap(st)
Once again,I am able to bring bitmaps in easily that I
got from programs I downloaded from the archive.So I
know that it is not the way Im coding it.Its just that
my bitmaps from my windows paint program have an
unsupported format(maybe they use too many colors)
Does anyone know?
------=_NextPart_000_0005_01C241FE.EE9ADBA0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This should be an easy question for =
someone who=20
has</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>been coding in euphoria for a =
while:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>How can I make sure my bitmaps are in a =
supported=20
format?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I get error 3-unsupported format when I =
try to read=20
my</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>bitmaps in,yet I read in bitmaps that I =
got from=20
the archive</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and they work fine.I don't know how to =
make my=20
bitmaps</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>256 colors.I am using windows pro(NT)=20
"paintbrush"</FONT> <FONT face=3DArial size=3D2> =
application.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> I found a way to trick the =
interpreter into=20
taking my bitmaps,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I save an image as a bitmap,then go =
paint on it.But=20
this is</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the long route.I want to =
just:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>x=3Dread_bitmap(st)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> Once again,I am able to bring =
bitmaps in=20
easily that I</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>got from programs I downloaded from the =
archive.So=20
I</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>know that it is not the way Im coding =
it.Its just=20
that</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my bitmaps from my windows paint =
program have=20
an</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>unsupported format(maybe they use too =
many=20
colors)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Does anyone know?</FONT></DIV>
<DIV> </DIV>
------=_NextPart_000_0005_01C241FE.EE9ADBA0--