Question about dict() and $MAXDICTEXTEND

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:smile: :sad: :eek: :shock: :cool: :-x :razz: :oops: :evil: :twisted: :wink: :idea: :arrow: :neutral: :mrgreen:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Question about dict() and $MAXDICTEXTEND

by Merk » Sun Jun 05, 2005 10:46 am

Well, I found the answer to one question in The Hugo Book (page 288 -- not sure why I missed it before). It says if the string is already in the dictionary, its location is returned. That's good news. Now, I'm looking to see if there is some way I can reset the beginning of dictionary extensions, so that new entries don't actually need new space.

Question about dict() and $MAXDICTEXTEND

by Merk » Sun Jun 05, 2005 10:44 am

When creating new dictionary entries at run-time, if the same entry is created multiple times, will it actually appear in memory multiple times, or will it check to see if it already exists, and just return that entry instead?

I ask, because my graphic names include four attributes -- Map X position, Map Y position, Dir Facing, and Time of Day character. For instance, PIC111a.jpg, PIC325c.jpg, etc. What I have planned to do is just take stats about the player's current position, build the appropriate "PIC" string, and display that file from the resource.

What I've found is, resource management works with dictionary entries, not string arrays. So, if I create a string array, I can't use it for the picture display unless I turn it into a dictionary entry first.

I was trying to test this by messing with the $MAXDICTEXTEND setting, but even if I have it set to just 1 byte, I'm able to create multiple dictionary entries at run-time without an error. I was hoping I could watch it in action, to observe whether or not it's creating new dictionary entries for the exact same string array, or if dict() simply returns the existing entry by checking for duplicates.

Or is there a way to delete a dictionary entry at run-time, so that it can be re-used? That would probably solve it, and I'd just keep creating a new dictionary entry over the old one, whenever the graphic needs changing.

The alternative would be to create a big list of all the possibilities, instead of trying to do it at runtime. I was hoping for a better solution. :)

Top