1. Extracting value of variable name of which is stored within another variable
- Posted by Rad <radhx at rediffmail.com> Nov 25, 2006
- 543 views
Hi, I have a variable "hIDB_abc" which is defined as global atom and is used to store a graphic file handle of a bitmap.
atom hIDB_abc hIDB_abc = loadBitmapFromFile("abc.bmp")
For a function, a parameter called "graphic" contains name of this variable "hIDB_abc".
function getGraphic(object graphic) -- where graphic = "hIDB_abc" .. .. end function
How can I get the actual file handle value of "hIDB_abc" using the sequence in "graphic"? I am using following code but without success:
atom memSet1, memSet2, graphicP1, graphicP2, graphicV memSet1 = w32new_memset() graphicP1 = w32acquire_mem(memSet1, graphic) -- address to graphic VOID = message_box("graphic handle : " & w32peek_string(graphicP1), "Msg", 0) memSet2 = w32new_memset() graphicP2 = w32acquire_mem(memSet2, w32peek_string(graphicP1)) -- address to variable held within graphic graphicV = peek4u(graphicP2) -- get the value of hIDB_handlename stored in graphic w32release_mem(memSet1) w32release_mem(memSet2) if equal(lower(graphic), "hidb_save") then VOID = message_box("graphic : " & graphic & "\n" & sprintf("hIDB_save : %d", hIDB_save) & "\n" & sprintf("graphicV :%d", graphicV), "Msg", 0) end if if equal(lower(graphic), "hidb_cancel") then VOID = message_box("graphic : " & graphic & "\n" & sprintf("hIDB_cancel : %d", hIDB_cancel) & "\n" & sprintf("graphicV :%d", graphicV), "Msg", 0) end if
I am always getting the same value of 1111771496 as value of graphicV, where as actual values of hIDB_abc are different. Regards, Rad.