how to init static structured variable ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 345
Joined: Sat Dec 25, 2004 2:37 pm

how to init static structured variable ?

Post 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
User avatar
Fig
Enthusiast
Enthusiast
Posts: 352
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: how to init static structured variable ?

Post 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}
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 345
Joined: Sat Dec 25, 2004 2:37 pm

Re: how to init static structured variable ?

Post 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:
Post Reply