• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] null local variables? "uses" and "requires" in librarys - what for?

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
1. do you have to null local handle variables to avoid memory leaks?

2. what exactly do "uses" and "requires" at a library head do?

3. what exactly is an integer? afaik it can be either a whole number or a short "string" with ' instead of " (max. 4 characters?)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
1. do you have to null local handle variables to avoid memory leaks?
Only locals declared with the "local" keyword (not argument defined locals) and only at the end of the function if they still have a handle value associated with them.

2. what exactly do "uses" and "requires" at a library head do?
3
Specifies a tree of dependiencies. This is then used by the compiler to organize the code as JASS can only call functions declared above the call site.

3. what exactly is an integer? afaik it can be either a whole number or a short "string" with ' instead of " (max. 4 characters?)
A interface to a 32 bit numeric signed field. You can encode 4 8bit characters into 1 single integer but doing so is inefficient.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
3. what exactly is an integer? afaik it can be either a whole number or a short "string" with ' instead of " (max. 4 characters?)
Things like 'A001' are still integers (whole numbers). They use the ASCII table to convert them from "strings" to integers.
Though they're never really strings. Just like A8 is also in integer in hexadecimal, 'A001' is an integer in ASCII.
Therefore, inputting '1' will return 49 (as ALT + 49 equals "1" - the ASCII character).

So there are no short strings, there are only integers in another base.

Edit: for objects, the minimum (and maximum) is indeed 4 characters, but you can still convert those codes to decimal numbers by setting an integer variable to the code (can be things like 'hpea', can also be 'a') and then displaying it.

Edit 2: finding out which integer it is was actually pretty easy.
So you've got a 4-character code ( 'n1 n2 n3 n4' ), you look up the ASCII code of those values (you can see that 2 equals 50 for example, use 50 as the number)
256³ * n1
+ 256² * n2
+ 256 * n3
+ 256° * n4 (this is just n4, as 256° equals 1)
= (integer)

An example: 'v9!s'
v = 118; 9 = 57; ! = 33; s = 115
(256³ * 118) + (256² * 57) + (256 * 33) + (115) = 1983455603.
So 'v9!s' will return that integer.
 
Last edited:
Status
Not open for further replies.
Top