Page 1 of 1

[Implemented] #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 7:14 pm
by Psych
Had a quick look, couldn't find it.

I'd like #PB_Integer added to FillMemory, if possible, I use this quite alot, but I've had to make my own routine for X64.

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:15 pm
by xorc1zt
i found #PB_Integer with the tool "structure viewer" which is showing every predefined constants (alt+S)

#PB_Byte = 0
#PB_Word = 1
#PB_Integer = 2
#PB_Long = 2
#PB_Float = 3
#PB_Quad = 4
#PB_Double = 6
#PB_Character = 7
#PB_Ascii = 8
#PB_Unicode = 9

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:21 pm
by Psych
It way well be defined for other functions, but according to the documentation it isn't available for the Fillmemory function. Which is what I would like. At the moment you can only fill bytes, words or longs.

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:28 pm
by xorc1zt

Code: Select all

#intsize = 4

Define *my_memory = AllocateMemory(100*#intsize)

FillMemory( *my_memory, 100*#intsize, 8, #PB_Integer)

Define counter.i

For counter=0 To 100*#intsize
  Debug Hex( PeekB(*my_memory+counter) )
Next counter
memory is correctly filled with int ( 0008,0008,0008,... )

edit : nevermind, i tried on 32 bits and as you can see integer and long have the same value so this code is not thrue :x

#PB_Integer = 2
#PB_Long = 2

edit 2: tried with quad and got the error

"[20:32:47] [ERROR] Invalid type for FillMemory(), should be either #PB_Byte, #PB_Word or #PB_Long."

so you definitively right

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:33 pm
by STARGĂ…TE
not on x64!, there i get an error!
under x64 ist #PB_Integer = 4 (Quad) and not 2


Only Byte, Word and Long can be used!

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:43 pm
by xorc1zt
they should add #PB_Quad too for 32 bits users

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 8:58 pm
by Psych
I just think it would make porting code to and from 64 bit mode easier, since the #PB_Integer would always reflect the correct size.

You can make your own routine, like I had to, using SizeOf(Integer) to get the size of a pointer, which works on either OS.

I just think it would be nice to have this included in the FillMemory function.

Re: #PB_Integer with FillMemory

Posted: Wed Dec 21, 2011 9:39 pm
by MachineCode
Psych wrote:Commenting your own code is admitting you don't understand it.
I like! :) But, it's not always true: sometimes a comment explains something other than code.