Gobal array?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Yam.

How to make a gobal array?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

If you mean GLOBAL... all ARRAYS are always GLOBAL.

Example 1 :

Dim MyArray.l(41)
MyArray(0) = 1
MyArray(1) = 2


Example 2 :

Dim MultiArray.b(NbColumns,NbLines)
MultiArray(10,20) = 10
MultiArray(20,30) = 20

Maybe we should mention it in the helpfile :)

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Yam.

Sorry unable to delete it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Yam.

Franco,you mean we don't have to declare it at the
begining of your code. You mean anywere in your code and
it's gobal?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Well you have to DIM it, before you use it...


Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Yam.

Thank you Franco!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Yam.

Sorry Franco, but I do believe that there is a local and
Global array(dim) like in VB or Pascal(delphi) or c/c++.
Still want to know how to do it.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by SoulTaker.

The arrays are all global but you can have static arrays witin structures

the DIM keyword is used to resize an array.

Also take a look at shared and protected keywords.


Abit BD7-II Raid P4 1.9 gHz 384 Ram Xtasy GFroce 3 TI 200 CD-RW DirectX 9.0 Beta 3 Sound Blaster Live! XP Pro, Registered PureBasic version 3.40 For Windows.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

'Dim is used to 'size' the new arrays.
Sure with Dim you can resize an array also,
but keep in mind that all information is lost...

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Shared and Protected have nothing to do with Arrays, only with variables!
Arrays are always global, even if you define them inside a Procedure.

Just test it, you'll see.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by waffle.

i noticed a sorta bug with PB as reguards to this....
Although a LinkedList is global in scope,
you can't define one in a DLL unless its in some kind of
initialization routine. If you use
NewList MyList.MyType()
outside of a procedure, your DLL will not work correctly.
however, since its use is global, everthing is fine if
its in a DLL startup procedure.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

AFAIK, all that's not in a Procedure won't be executed in a Dll.
That's why there are those EntryPoint Procedures.

But maybe i'm wrong here...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Yes, when building a dll, all code outside of a procedure is ignored as stated in the doc: "The DLL code is like a PureBasic code except than no real code should be written outside of procedure."

Fred - AlphaSND
Post Reply