HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to get the address of a variable

02-16-2007, 09:26 AM#1
my_pkpk
Is it possible in JASS to get the address of a variable ( either global or local ) like it does in C/C++ ?
02-16-2007, 09:35 AM#2
Jazradel
Not like in C/C++. However, we do have the return bug which we can use to get the address of a handle(unit, destructable, lightning, etc). Not the variable address unfortunately(unit[0] and unit[1] would return completely seperate address).

The return bug works like this:
Collapse JASS:
function H2I takes handle h returns integer
      return h
      return 0
endfunction
The syntax checker only checks the last return statement of a function, but only the first one works. If you put in a handle(any non real,integer,string,boolean) it will return an integer code unique to that handle. You can then do it the other way to change the integer back into the handle.

For practical applications of this, look for Kattanas' Handle Variables or Vexorians CS_Cache.
02-16-2007, 12:32 PM#3
Vexorian
Lame solution for non-native ones:

Collapse JASS:
struct pointer
   integer value
endstruct

function err takes nothing returns nothing
 local pointer p=pointer.create()
 local pointer x=p

    set p.value=56

 call BJDebugMsg(I2S(x.value))


endfunction

02-16-2007, 02:05 PM#4
my_pkpk
I got compile errors on this :

Collapse JASS:
struct pointer
   integer value
endstruct

Should I install anything before I can actually use structs on my naked WE ?
02-16-2007, 08:28 PM#5
Alevice
wehelper

edit: whoops, I meant jasshelper. sorry 'bout that.
02-16-2007, 08:30 PM#6
Captain Griffen
Grimoire + JASS helper. More debugging stuff, survives patches. Less a few things though.
02-16-2007, 08:46 PM#7
PipeDream
Nothing stops you from using wehelper on WE and grimoire on war3.
02-17-2007, 03:03 PM#8
my_pkpk
Finally I got wehelper and jasshelper correctly installed on my WE. It works pretty well except that "Access violation" problem after I clicked "Browse Maps". BTW , my WE version is 1.20c ( 6052).
Vex's struct works, but the address seems not the actual variable address, it's an index as I converted it to integer, something strange is each time I convert p to integer, it increased by 1, donno why, maybe I should check the compiled j file.
Hmm.., I've realized maybe there has no way to get the real variable address.
anyway, thanks guys.
02-17-2007, 05:10 PM#9
Ignitedstar
1.20c? You need to update your version of WC3 before going on, I think.
02-17-2007, 05:20 PM#10
Alevice
Quote:
Originally Posted by my_pkpk
Hmm.., I've realized maybe there has no way to get the real variable address.

Why wiould you want to do it anyway?