News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

How to make Arrays GLOBAL

Started by basil99, April 02, 2008, 02:33:18 AM

Previous topic - Next topic

basil99

Hi !

A bit stuck with it.

Say, I declas Array in the beginning of the prg, like

dim MyArray( ElementsNumber )

Then, I need to make it visible from any Function  and/or Psub, like this

Fuction MyFunc( param )

             ...........

             ; Sample operation
              var1 - Myarray( param )

             .............

EndFunction


Is it possible ?
Free Games Site - http://vespacrabro.com

Adaz

Yes, that array is global because you declared it outside the function.

Ádáz

Hungary

kevin

#2
 PlayBASIC is top -> down compiler.   Items such as arrays/variables need to be declared prior to their use.  

In this sample the Names$() array is visible to all of the code bellow this declaration.

PlayBASIC Code: [Select]
   Dim Name$(100)

SetName(1,"Bill")

Function SetName(Pos,Name$)
Name$(pos)=Name$
EndFunction





In this sample names$() isn't visible and will error.


PlayBASIC Code: [Select]
Function SetName(Pos,Name$)
Name$(pos)=Name$
EndFunction


Dim Name$(100)

SetName(1,"Bill")







More Reading See   HELP -> ABOUT -> PROGRAMLAYOUT