Page 2 of 2
Posted: Sun Jan 02, 2005 2:37 pm
by The_CodeMaster
Than i can't convert this Source from Powerbasic to Purebasic.
euhm, if you have an array in PowerBasic from ex. (30 to 90) then just convert it to (0 to 60) or just 'dim variable(60)'. You'll have to make sure that the starting-index is 0 and in this case you'll have to substract 30 to get THAT 0.
So it's possible to convert, but proberly a lot of work

.
Tried to read your german post, but don't understand German.
Posted: Sun Jan 02, 2005 2:55 pm
by Falko
Thanks for your tip. I will see to convert the Powerbasic Code to Purebasic.
I hope this do funtionary in Purebasic to write an XLS-Sheet.
Sorry, but i can't translate all german Thread with my little english.
Best regards from germany
Falko
Posted: Sun Jan 02, 2005 3:08 pm
by Psychophanta
freak wrote:Code: Select all
Procedure.l ArrayMemorySize(*Array)
!sub [esp], dword 8
!push dword [esp]
!push dword 0
!push dword [PB_MemoryBase]
!call _HeapSize@12
ProcedureReturn
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
EndProcedure
Procedure ArraySize(*Array)
ProcedureReturn PeekL(*Array-8)
EndProcedure
Dim Array.l(50)
Debug ArrayMemorySize(@Array())
Debug ArraySize(@Array())
ArrayMemorySize() shows the real size in memory.
ArraySize() shows the total number of elements.
Timo
Hey guys, have you seen that?
That's the Power of PureBasic

Posted: Wed Mar 14, 2007 8:59 pm
by Psychophanta
Code: Select all
Procedure.l ArrayMemorySize(*Array)
!sub [p.p_Array], dword 8
!push dword [p.p_Array]
!push dword 0
!push dword [PB_MemoryBase]
!call _HeapSize@12
ProcedureReturn
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
EndProcedure
Procedure ArraySize(*Array)
ProcedureReturn PeekL(*Array-8)
EndProcedure
Dim Array.l(50)
array(8)=45
Debug ArrayMemorySize(@Array())
Debug ArraySize(@Array())
ArrayMemorySize() doesn't work in PB 4.02
And 2nd: what about SizeOf(linkedlist())

Posted: Fri Sep 21, 2007 6:12 am
by Mistrel
This code gives me the size of the array +1. Is it safe to assume that in PB4 the correct value is PeekL(*Array-8)-1?
Code: Select all
Procedure ArraySize(*Array)
ProcedureReturn PeekL(*Array-8)
EndProcedure
Dim Array.l(50)
Debug ArraySize(@Array())
Posted: Sun Sep 23, 2007 8:21 pm
by Ollivier
There is no problem:
Dim x(3)
=
x(0) 1 element
x(1) 2 elements
x(2) 3 elements
x(3) 4 elements
In an array dimed like that "Dim x(50)", there's fifty one elements

Posted: Sun Sep 23, 2007 8:38 pm
by Kaeru Gaman
in other words, it does not give you the size of the array +1,
but precisely the size of the Array.
remember, in PB you Dim an Array withe the index of the last element,
not with the numer of elements, and an array always starts at index 0.
so, with Dim x(50) you Dim 51 elements as Olli said.
if you want 50 Elements, you'll need index 0-49, then use Dim x(49)
...this is different to other BASIC languages, but it's a known issue in PB.
Posted: Sun Sep 23, 2007 9:33 pm
by Ollivier
Updated
Code: Select all
Procedure.l ArrayMemorySize(*Array)
!sub [p.p_Array], dword 20
!push dword [p.p_Array]
!push dword 0
!push dword [PB_MemoryBase]
!call _HeapSize@12
ProcedureReturn
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
EndProcedure
Posted: Sun Sep 23, 2007 10:00 pm
by Ollivier