AllocateMemory
AllocateMemory
I see AllocateMemory has changed. How do we use length or should I say Lof now?
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
You need to use the GlobalSize API command to do it, like so:
However, I guess PureBasic should have a native command to do this... 
(@J.Baker: Lof is used for file lengths only, and not for memory lengths).
Code: Select all
a=Random(999)
b=AllocateMemory(a)
Debug a
Debug GlobalSize_(b)

(@J.Baker: Lof is used for file lengths only, and not for memory lengths).
Yeah but you can't do this anymore: AllocateMemory(0, len, 0)
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
> Yeah but you can't do this anymore: AllocateMemory(0, len, 0)
Yes you can, like so: adr=AllocateMemory(len)
You don't reference memory blocks with an ID number anymore, but by the
return value. So to free the memory block above: FreeMemory(adr).
Show me what you're trying to do, and I'll show you the new way to do it.
Yes you can, like so: adr=AllocateMemory(len)
You don't reference memory blocks with an ID number anymore, but by the
return value. So to free the memory block above: FreeMemory(adr).
Show me what you're trying to do, and I'll show you the new way to do it.

Last edited by PB on Mon Jul 19, 2004 7:00 am, edited 1 time in total.
Well, i've been playing with the installer code for some time now, learning from it. Here's a little snippet of what I mean.
If ReadFile(0, windir + "\nstall.bulk")
len = Lof()
AllocateMemory(0, len, 0)
*mem = MemoryID()
ReadData(*mem, len)
CloseFile(0)
EndIf
If ReadFile(0, windir + "\nstall.bulk")
len = Lof()
AllocateMemory(0, len, 0)
*mem = MemoryID()
ReadData(*mem, len)
CloseFile(0)
EndIf
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
> Here's a little snippet of what I mean
The new way to use that snippet is as follows:
Note that MemoryID() isn't used anymore, since the return value ("mem" in
this example) is the equivalent of MemoryID() and it's also the reference to
the memory block (ie. instead of using a memory number). This method is
better than before because it's far less typing and more practical.
The new way to use that snippet is as follows:
Code: Select all
If ReadFile(0, windir + "\nstall.bulk")
len = Lof()
mem = AllocateMemory(len)
ReadData(mem, len)
CloseFile(0)
EndIf
this example) is the equivalent of MemoryID() and it's also the reference to
the memory block (ie. instead of using a memory number). This method is
better than before because it's far less typing and more practical.
Thanks alot, that had me stumped for a couple of hours. 

www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
> Buffer=AllocateMemory(0,512,0)
This is now: Buffer=AllocateMemory(512)
"Buffer" now is the start of the memory block, and also the identifier for it,
instead of 0 being the identifier (as it was in the old version of the command).
> memory=AllocateMemory(1,lang+1)
This is now: memory=AllocateMemory(lang+1)
"memory" is now the start of the memory block, and also the identifier for it,
instead of 1 being the identifier (as it was in the old version of the command).
As I said for J.Baker: show me some code that you're having trouble with, and
I'll convert it to the new format for you, to show you how it's now done.
This is now: Buffer=AllocateMemory(512)
"Buffer" now is the start of the memory block, and also the identifier for it,
instead of 0 being the identifier (as it was in the old version of the command).
> memory=AllocateMemory(1,lang+1)
This is now: memory=AllocateMemory(lang+1)
"memory" is now the start of the memory block, and also the identifier for it,
instead of 1 being the identifier (as it was in the old version of the command).
As I said for J.Baker: show me some code that you're having trouble with, and
I'll convert it to the new format for you, to show you how it's now done.

The new function of the old function UseMemory
Dear Developer
Can somebody help me for translated or witch new function in PureBASIC 3.90 can I used instead of the old function
"*Mem0 = UseMemory(0)"
Thanks
Stefke
Can somebody help me for translated or witch new function in PureBASIC 3.90 can I used instead of the old function
"*Mem0 = UseMemory(0)"
Thanks
Stefke
Re: The new function of the old function UseMemory
> Can somebody help me
UseMemory isn't used anymore because you just access the memory block
directly now. I asked you to post some of your old code so that I can show
you the new way to do it. If you're not willing to do that, then I can't help.
UseMemory isn't used anymore because you just access the memory block
directly now. I asked you to post some of your old code so that I can show
you the new way to do it. If you're not willing to do that, then I can't help.
The biggest downfall of PureBasic is the use of crappy ID numbers. I don't mean the actually handle to stuff, I mean the little parameter at the start of most functions where I am forced to use #PB_Any because I don't want to use the little kiddy ID number. It was a very BASIC idea, but I think the majority of PureBasic users aren't really beginners to programming. I use PureBasic for pretty much just a more effecient alternative to C++. It doesn't use such daunting syntax, yet still gives me all the power I need. Newbies to the programming world should go play with Blitz before knocking on PureBasic's door.
PureBasic puts ease into the GUI part of the API but adds stress with those ID numbers. Its 3D and 2D libraries aren't all that fascinating, either. They don't match my programming style. I use external calls to OpenGL and DirectX if I want to do some fast multimedia. Another thing I don't like is the prefix of constants. I'd much rather have something like "Const" to define constants versus "#". It's also a little annoying that PureBasic doesn't have all of the structures.
But PureBasic more than makes up for everything with it's small, fast executables, syntax that doesn't give a headache to newbies but is suitable for very advanced jobs, pointers and other excellent memory manipulation routines, and more. It was definately worth the money.
PureBasic puts ease into the GUI part of the API but adds stress with those ID numbers. Its 3D and 2D libraries aren't all that fascinating, either. They don't match my programming style. I use external calls to OpenGL and DirectX if I want to do some fast multimedia. Another thing I don't like is the prefix of constants. I'd much rather have something like "Const" to define constants versus "#". It's also a little annoying that PureBasic doesn't have all of the structures.
But PureBasic more than makes up for everything with it's small, fast executables, syntax that doesn't give a headache to newbies but is suitable for very advanced jobs, pointers and other excellent memory manipulation routines, and more. It was definately worth the money.