Jump to content
Sign in to follow this  

Trouble with "variables"

Recommended Posts

;example of constants

; "1BYTE" each constant




Func makeMsg1($task,$param1,$param2)

;0x 00 (task) (param1) (param2)

return $task*(0x100*0x100) + $param1*0x100 + $param2


Func makeMsg2($task,$param1,$param2)

;0x 00 (task) (param1) (param2)

return $task*0x100^2 + $param1*0x100 + $param2


$MSG1 = 2147483647;2^31-1

$MSG2 = $MSG1 + 1

MsgBox(0,"size of return from makeMsg1",BinaryLen(makeMsg1($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING)))

MsgBox(0,"size of return from makeMsg2",BinaryLen(makeMsg2($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING)))

MsgBox(0,"size of $MSG1",BinaryLen($MSG1))

MsgBox(0,"size of $MSG2",BinaryLen($MSG2))

;now just for you check, try show the data in hexdecimal base...

;the 8 bytes should look like that 0x 00 00 00 00 00 01 01 01

;but look yourself the result oO

MsgBox(0,"makeMsg2 data",hex(makeMsg2($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING))); =o

MsgBox(0,"makeMsg2 data",hex(binarymid(makeMsg2($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING),1,8)));can you see the 3 bytes with 0x01? i guess no =(

;ok other function work fine

MsgBox(0,"makeMsg1 data",hex(makeMsg1($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING))); =o

MsgBox(0,"makeMsg1 data",hex(binarymid(makeMsg1($TASK_SOMETHING,$PARAM1_SOMETHING,$PARAM2_SOMETHING),1,4)))

here we have a simple example of something that is very confused, after some days working with bytes in autoit i got big troubles in some "implicit casts"

i need to know the exact size of data that my functions return, without it i cant parse bytes in another end...

the question is, there is a way to specify the size of variables or tell the compiler "hey don't touch that ok?" ?

thank you for anything im just wondering... the autoit is a great language anyway, i did a lot of things in the last weeks just joking

uhh, i keep with my little/bad English, sorry if you don't understand :)

Share this post

Link to post
Share on other sites


the question is, there is a way to specify the size of variables or tell the compiler "hey don't touch that ok?" ?


No, there isn't a way to specify the size of a variable. All variables in autoit are variants and are therefore completely dynamic. A variant is by very definition dynamic because it can hold any datatype without specification.

From the help file:

In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings.

I hope that answers your question.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...