Powerbasic Museum 2020-B

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Chris Chancellor on May 02, 2018, 05:48:57 PM

Title: How to create dynamic arrays
Post by: Chris Chancellor on May 02, 2018, 05:48:57 PM
Hello Charles

i would like to create a dynamic array rez() with a variable size as below
where ste is a string of variable length


    Long  LengSt = LEN(ste)

    DIM rez( LengSt) AS BYTE


but i  can't compile it as the error is  at the  line
    DIM rez( LengSt) AS BYTE

and that LengSt is a variable


your Oxygen_help.chm states for  creating dynamic arrays as
  dim as long a at getmemory(10*sizeof(long))

but i'm not sure how to do this in my code above


appreciate all your help




Title: Re: How to create dynamic arrays
Post by: Charles Pegge on May 02, 2018, 07:13:53 PM

O2 standard arrays are static, so you have to create a dynamic array with the redim macro. Then you can resize it, up or down.


Long  LengSt = LEN(ste)

redim byte rez( LengSt)
Title: Re: How to create dynamic arrays
Post by: Chris Chancellor on May 03, 2018, 05:25:13 AM
Thanxx a lot Charles

very compact