Page 1 of 1

[DONE] 1.877 / 4.30b4: Static array crash

Posted: Mon Nov 10, 2008 2:25 pm
by Vladi
Any idea about this?

Library:

Code: Select all

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.

Posted: Mon Nov 10, 2008 3:21 pm
by gnozal
Use a global array

Code: Select all

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: Select all

Structure ArrayLong5
  l.l[5]
EndStructure 
ProcedureDLL proc(x) 
  Static StaticArray.ArrayLong5
  StaticArray\l[2]=5 
  ProcedureReturn x 
EndProcedure

Posted: Mon Nov 10, 2008 4:33 pm
by Vladi
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?

Posted: Mon Nov 10, 2008 5:13 pm
by gnozal
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.

Posted: Mon Nov 10, 2008 6:40 pm
by Vladi
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.

Posted: Mon Nov 10, 2008 7:02 pm
by ts-soft
You can't end a library. A library is never started :wink:
You can only end a program.
This make sense

Posted: Mon Nov 10, 2008 9:30 pm
by Vladi
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.

Posted: Tue Nov 11, 2008 10:07 pm
by ABBKlaus
Thanks, i added a note in the help file.
You can read it online : http://www.tailbite.com/help/Reference/ ... xused.html