Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → The Heap Verbs
The Heap Verbs
2002-05-18, 7:22 AM #1
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:

Code:
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.

Code:
HeapSet(pointer, value);

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

Code:
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.

Code:
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.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-05-18, 8:48 AM #2
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.
And when the moment is right, I'm gonna fly a kite.
2002-05-18, 1:07 PM #3
...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.
And when the moment is right, I'm gonna fly a kite.
2002-05-18, 1:54 PM #4
I didn't get what that's better than

int abc = 100;

------------------
http://millennium.massassi.net - Millennium
JK Mods : Sniper Arena! - Enhancement Pack!
2002-05-18, 3:12 PM #5
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.
And when the moment is right, I'm gonna fly a kite.
2002-05-19, 12:45 AM #6
GBK, as for your earlier question, if you haven't already realised:

Quote:
<font face="Verdana, Arial" size="2">
HeapSet() gives a flex value to one of the storage slots created by HeapNew().</font>
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-05-19, 4:40 AM #7
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.
And when the moment is right, I'm gonna fly a kite.
2002-05-19, 5:49 AM #8
Quote:
<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.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-05-19, 10:10 AM #9
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, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-05-20, 12:21 PM #10
Hey SaberMaster, thanks a heap! [http://forums.massassi.net/html/smile.gif]

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton

↑ Up to the top!