Page 1 of 1

Posted: Mon Oct 14, 2002 10:29 pm
by BackupUser
Restored from previous forum. Originally posted by Yam.

How to make a gobal array?

Posted: Mon Oct 14, 2002 10:37 pm
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

Posted: Mon Oct 14, 2002 10:47 pm
by BackupUser
Restored from previous forum. Originally posted by Yam.

Sorry unable to delete it.

Posted: Mon Oct 14, 2002 10:49 pm
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?

Posted: Mon Oct 14, 2002 10:57 pm
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

Posted: Mon Oct 14, 2002 11:10 pm
by BackupUser
Restored from previous forum. Originally posted by Yam.

Thank you Franco!

Posted: Tue Oct 15, 2002 2:07 pm
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.

Posted: Tue Oct 15, 2002 2:53 pm
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.

Posted: Tue Oct 15, 2002 4:06 pm
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

Posted: Tue Oct 15, 2002 4:09 pm
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

Posted: Tue Oct 15, 2002 10:57 pm
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.

Posted: Wed Oct 16, 2002 6:34 am
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

Posted: Wed Oct 16, 2002 12:04 pm
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