1. Appending to a "sequence"

This code errors on the "append(line, '{')"  statement
Can we not append an atom to a sequence ?

sequence line
sequence recd 	
   fn=open("tml_extract.txt","r")
   if fn < 1 then
  	puts(1, "Unable to open the disk file\n")
        abort(fn)
   else 
     while 1 do 
        line = {}
        append(line, '{')
        recd = gets(fn)
        if atom(recd) then exit
        else  
          if equal(recd[2..5], "%HDR") or equal(recd[2..5], "%TRL") then
          	 a = 0
          else
            append(line, recd) 
            append(line, '}')
            ---puts(1, recd[1] recd[2] & "\n") 
            puts(1, line[2]  & "\n")
          end if
        end if
     end while
   end if     


new topic     » topic index » view message » categorize

2. Re: Appending to a "sequence"

On Wed, 17 Nov 2004 17:35:42 -0800, John F Dutcher
<guest at RapidEuphoria.com> wrote:

>This code errors on the "append(line, '{')"  statement
>Can we not append an atom to a sequence ?
Presumably you meant
	line=append(line,'{')

append is a function, its result must be assigned somewhere,
Euphoria is optimised for the case where the result of append is
assigned to the same variable as the first parameter.

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: Appending to a "sequence"

What's the error?


On Wed, 17 Nov 2004 17:35:42 -0800, John F Dutcher
<guest at rapideuphoria.com> wrote:
> 
> posted by: John F Dutcher <John_Dutcher at urmc.rochester.edu>
> 
> This code errors on the "append(line, '{')"  statement
> Can we not append an atom to a sequence ?
> 
> }}}
<eucode>
> sequence line
> sequence recd
>    fn=open("tml_extract.txt","r")
>    if fn < 1 then
>         puts(1, "Unable to open the disk file\n")
>         abort(fn)
>    else
>      while 1 do
>         line = {}
>         append(line, '{')
>         recd = gets(fn)
>         if atom(recd) then exit
>         else
>           if equal(recd[2..5], "%HDR") or equal(recd[2..5], "%TRL") then
>                  a = 0
>           else
>             append(line, recd)
>             append(line, '}')
>             ---puts(1, recd[1] recd[2] & "\n")
>             puts(1, line[2]  & "\n")
>           end if
>         end if
>      end while
>    end if
> </eucode>
{{{

> 
> 
> 
> 


-- 
MrTrick

new topic     » goto parent     » topic index » view message » categorize

4. Re: Appending to a "sequence"

The format of the Append() command is as a function - ie, it returns a value.

fred = append(fred, '{')

would work ok.  probably :)


>      while 1 do
>         line = {}
>         append(line, '{')
>         recd = gets(fn)
>         if atom(recd) then exit


. .. : :: = == == = :: : .. .
Server-Side DB driven web sites,
Software Development
and part-time games developer

contact dave_p at purpletiger dot com
. .. : :: = == == = :: : .. .

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu