Page 1 of 1

how to init static structured variable ?

Posted: Sat May 09, 2020 9:19 am
by thyphoon
Hello

How can i init a static structured variable easly ?
i would like A variable is init with A\x=-1 and A\y=-1

Code: Select all

Procedure test()
  Static A.point
  Debug A\x
 Debug A\y
EndProcedure
I use this method but it's not very clean :? do you have another way ?

Code: Select all

Procedure test()
 Static Init.b=#false
  Static A.point
if Init=#false
  Init=#true
  A\x=-1
  A\y=-1
Endif
  Debug A\x
 Debug A\y
EndProcedure

Re: how to init static structured variable ?

Posted: Sat May 09, 2020 10:45 am
by Fig
I always did something like you do in the second exemple.
I wonder if there is an other possibility...

Purebasic lacks something like: (or it may exist but I am not aware of it ??)

Code: Select all

A.point={1,2}

Re: how to init static structured variable ?

Posted: Sat May 09, 2020 10:55 am
by thyphoon
Fig wrote:I always did something like you do in the second exemple.
I wonder if there is an other possibility...

Purebasic lacks something like: (or it may exist but I am not aware of it ??)

Code: Select all

A.point={1,2}
Yes :mrgreen: +1 :idea: