[Implemented] #PB_Integer with FillMemory

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

[Implemented] #PB_Integer with FillMemory

Post 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.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: #PB_Integer with FillMemory

Post 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
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Re: #PB_Integer with FillMemory

Post 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.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: #PB_Integer with FillMemory

Post 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
Last edited by xorc1zt on Wed Dec 21, 2011 8:35 pm, edited 2 times in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #PB_Integer with FillMemory

Post 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!
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: #PB_Integer with FillMemory

Post by xorc1zt »

they should add #PB_Quad too for 32 bits users
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Re: #PB_Integer with FillMemory

Post 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.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: #PB_Integer with FillMemory

Post 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.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply