It is currently Thu May 23, 2013 2:30 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: [DONE] 1.877 / 4.30b4: Static array crash
PostPosted: Mon Nov 10, 2008 2:25 pm 
Offline
User
User

Joined: Sun Sep 10, 2006 3:09 pm
Posts: 33
Any idea about this?

Library:
Code:
ProcedureDLL proc(x)
  Static Dim a(5)
  a(2)=5
   ProcedureReturn x
EndProcedure


This crashes; same result when the static array is declared as global.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 3:21 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Use a global array
Code:
ProcedureDLL MyLib_Init() ; Dim/NewList etc... always in _Init procedure
  Global Dim a(5)
EndProcedure

ProcedureDLL proc(x)
  a(2)=5
  ProcedureReturn x
EndProcedure
or pseudo static array like this
Code:
Structure ArrayLong5
  l.l[5]
EndStructure
ProcedureDLL proc(x)
  Static StaticArray.ArrayLong5
  StaticArray\l[2]=5
  ProcedureReturn x
EndProcedure

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 4:33 pm 
Offline
User
User

Joined: Sun Sep 10, 2006 3:09 pm
Posts: 33
Thanx, it's workin. I understand that I cannot create an array outside a procedure, but why not a static one inside?

The END command also does not seem to work in a library. Is this true?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 5:13 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
Vladi wrote:
The END command also does not seem to work in a library. Is this true?
The END keyword is only usefull in the main program. Imho it's meaningless in a library.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 6:40 pm 
Offline
User
User

Joined: Sun Sep 10, 2006 3:09 pm
Posts: 33
For fatal error handling I find it very useful; otherwise you will have to pass it back through the whole module hierarchy, which might not be possible in case of fatal error.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 7:02 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4715
Location: Berlin - Germany
You can't end a library. A library is never started :wink:
You can only end a program.
This make sense

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Linux Mint 14 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 9:30 pm 
Offline
User
User

Joined: Sun Sep 10, 2006 3:09 pm
Posts: 33
It should not play any role whether a piece of code resides in a previously compiled library or the code actually compiled. As in other languages it makes no difference in which class or *.obj you end the pgm.

With all these restrictions you can never put a portion of a larger system into a library, you always have to recompile the whole bunch.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2008 10:07 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
Thanks, i added a note in the help file.
You can read it online : http://www.tailbite.com/help/Reference/purebasicsyntaxused.html

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye