PDA

View Full Version : The Heap Verbs



SaberMaster
05-18-2002, 10:22 AM
I spent this morning researching JK's Heap verbs. Here's what I found:

The Heap verbs are used to create an array of storage slots in memory to hold variable values. The important thing is that the amount of storage is dynamic - meaning that you don't have to know in advance how much storage you'll need. A description of each verb:



start_pointer=HeapNew(start_num, end_num);

HeapNew() creates numbered memory slots beginning at start_num and ending and end_num. The last slot in the array cannot be used. start_pointer will have the same value as start_num.



HeapSet(pointer, value);

HeapSet() gives a flex value to one of the storage slots created by HeapNew().



HeapGet(pointer);

HeapGet() returns the value given to the storage slot by HeapSet(). If the slot does not have a value, HeapGet() will crash. If there is no heap, HeapGet() will return 0.



HeapFree();

HeapFree() removes a cog's heap. Because each cog has its own heap, HeapFree() does not need parameters.

I have already updated the verb info in the DataMaster, and when Geocities finishes its "maintenance," I'll upload the new version.

So what do you think? http://forums.massassi.net/html/smile.gif

------------------
Author of the Jedi Knight DataMaster (http://www.geocities.com/sabersdomain/fileframe.html).
Visit Saber's Domain (http://www.geocities.com/sabersdomain).

gbk
05-18-2002, 11:48 AM
Sounds interesting . . . but are the values limited to Ints?

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources (http://www.tbns.net/GBK/ol/index.htm).

gbk
05-18-2002, 04:07 PM
...or could one use flex values?

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources (http://www.tbns.net/GBK/ol/index.htm).

Hideki
05-18-2002, 04:54 PM
I didn't get what that's better than

int abc = 100;

------------------
http://millennium.massassi.net - Millennium
JK Mods : Sniper Arena! (http://www.sfc.keio.ac.jp/~t00214ho/millennium/projects/?SA) - Enhancement Pack! (http://www.sfc.keio.ac.jp/~t00214ho/millennium/projects/?EP21)

gbk
05-18-2002, 06:12 PM
Isnt there a set limit on the amount of variables one can declare in the symbols section?

If you used all of your allowed variables, this might be the only viable solution left...

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources (http://www.tbns.net/GBK/ol/index.htm).

Lord_Grismath
05-19-2002, 03:45 AM
GBK, as for your earlier question, if you haven't already realised:


<font face="Verdana, Arial" size="2">
HeapSet() gives a flex value to one of the storage slots created by HeapNew().</font>

gbk
05-19-2002, 07:40 AM
Oops.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources (http://www.tbns.net/GBK/ol/index.htm).

SaberMaster
05-19-2002, 08:49 AM
<font face="Verdana, Arial" size="2">
I didn't get what that's better than
int abc = 100;
</font>

The heap allows you to create storage space as you need it, and also to store many more values than would be possible with variables. So you could create a slot to store the lighting of each sector in a level.

Admittedly, you don't often need to do something like this, but the heap is a useful tool.

------------------
Author of the Jedi Knight DataMaster (http://www.geocities.com/sabersdomain/fileframe.html).
Visit Saber's Domain (http://www.geocities.com/sabersdomain).

SaberMaster
05-19-2002, 01:10 PM
I just updated the DataMaster with the heap verb information. Take a look. http://forums.massassi.net/html/smile.gif

------------------
Author of the JK DataMaster (http://www.geocities.com/sabersdomain/fileframe.html), Parsec (http://www.geocities.com/sabersdomain/fileframe.html), and the EditPlus Cog Files (http://www.geocities.com/sabersdomain/fileframe.html).
Visit Saber's Domain (http://www.geocities.com/sabersdomain).

Sylvicolus
05-20-2002, 03:21 PM
Hey SaberMaster, thanks a heap! http://forums.massassi.net/html/smile.gif

------------------
Sylvicolus JK homepage (http://www.lactarius.com/sylvicolus/jk/)
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton