Jump to content

How to define pointer variable in AutoIt


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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  

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...