Jump to content

Recommended Posts

Posted (edited)

Hello experts,

I want to know how to define pointer variable in AutoIt. Or How to get a variable's memory address?

C directive could be

int* mode;
  function(mode);

or

int mode;
  function(&mode);

What's the counterpart in AutoIt?

Thanks in advance!

BRs,

bittware

Edited by bittware
Posted (edited)

Use an Dll-structure:

Local $tMode = DllStructCreate('int')
Local $pMode = DllStructGetPtr($tMode)

; set value with
DllStructSetData($tMode, 1, 'value')

; get value with
Local $getValue = DllStructGetData($tMode, 1)

Func _function($pMode)
    ; ...
EndFunc

Do I have to use DllStruct? It seems overkill for such simple task. Any native directive that can get variable's pointer(address) directly? Edited by bittware
Posted (edited)

I don't know another way. AutoIt is an easy to use scripting language and so it's required sometimes to make a compromise. :blink:

Edit:

But if you only want to have acces to your source-variable with possibility to change it, than use it ByRef. It give access with an Pointer to your variable.

Local $var

_MyFunc($var)

Func _MyFunc(ByRef $myVar)

; ... changes on $myVar inside Func has effect on $var

EndFunc

Edited by BugFix

Best Regards BugFix  

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
×
×
  • Create New...