Re: 1 little sequence problem

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

On Fri, 17 Mar 2000 21:24:19 +0100, =?iso-8859-2?B?qWtvZGE=?=
<tone.skoda at SIOL.NET> wrote:

>Can you help me out here, I just can't get over this.
>
>when i use this code:
>
>sequence s1
>for i=1 to 10 do
> s1[i]=i
>end for
>
>i get error message: variable s1 has not been assigned a value
>
>And when i add this:
>s1={}
>i get this error message:
>subscript value 1 is out of bounds, assigning to a sequence of length 0



   sequences are dynamic but must be created to a given size

   or be grown by appending a value.


  Your example can be corrected in two ways

  sequence s1
  -- this creates a sequence of 10 zeros
  s1 = {0,0,0,0,0,0,0,0,0,0}
  for i=1 to 10 do
   s1[i]=i
  end for

  or

  sequence s1
  -- this creates an empty sequence and appends to it
  s1 = {}
  for i=1 to 10 do
   s1 &= i
  end for

  the reason you have an error is because Euphoria does not know
  a beginning size of your sequence.

 Bernie

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

Search



Quick Links

User menu

Not signed in.

Misc Menu