Jump to content

Trouble with "variables"


ask
 Share

Recommended Posts

;example of constants

; "1BYTE" each constant

$TASK_SOMETHING = 0x01

$PARAM1_SOMETHING = 0x01

$PARAM2_SOMETHING = 0x01

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

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

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

EndFunc

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

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

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

EndFunc

$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))

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 :)

Link to comment
Share on other sites

Read the help file under Variables. All integers are 32-bit signed, or FLOATS if too big for that. If you must work in other word sizes, it will have to be with the Binary functions.

AutoIt is an interpreted scripting language, like Perl. Not a programming language like C++. The interpreter (which is a binary written in C++) takes internal variables from your script and auto-magically morphs them into whatever form is required by the Windows API being used at the moment. At least that's my understanding of it, seen as through (dirty) glass, darkly...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks, i just asked because some of my functions that i made to generate messages to send through network were changing their size, and when it arrive in "server" the size was expected to be x, no 2*x, so if the message was expected to has 4 bytes, nothing is read or when read some mistake occur when the message has 8bytes, but sure i could check the size before returning something, but i didn't. :)

I fixed it, but i had to discovery what change the size of variables.

However, how you said i know too, that is an interpreted scripting language, a good one that we can do really fast some common tasks(because of automation), so i think that i am here just for ask or express gratitude for that language that has helped me a lot.

I'm new with AutoIt as you can see, keep with your patience with "noobs" like me, good support we have here, just few hours after i make a question i got an answer, thank you.

=p

Edited by ask
Link to comment
Share on other sites

I left something out, in that there are DLL structs available in AutoIt. Bytes can be worked with directly using DllStruct* functions, but if you want to assemble them into a network stream of some kind, that would probably be the Binary* functions. Check it all out in the help file.

And welcome to AutoIt!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...