markyrocks Posted January 9, 2020 Share Posted January 9, 2020 I'm trying to figure out the autoit representation of the following c++ code Int a=6; Int& ref_a=a So then if ref_a changes a would change aswell. I'm essentially interested in taking an unknown variable passed into my function be an alias to a element inside of an array lol. So that if the variable value passed into my function changes after the function is exited the value inside of the array element would change aswell. So in short $a=3 Func($a) Array[1]=$a End func Then if the value of $a changed after the function so would the value in the element in the array.... I know it's a longshot but I figured it's worth a post. I've used byref and that works great inside functions but I'm talking about outside of a function. Or possibly some other function. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
jdelaney Posted January 10, 2020 Share Posted January 10, 2020 (edited) Something like this I guess $a = 3 Local $aArray[1] = ["a"] ConsoleWrite(Eval($aArray[0]) & @CRLF) $a = 6 ConsoleWrite(Eval($aArray[0]) & @CRLF) setAVariable($a, 25) ConsoleWrite(Eval($aArray[0]) & @CRLF) Func setAVariable(ByRef $a, $i) $a = $i EndFunc output 3 6 25 Edited January 10, 2020 by jdelaney markyrocks 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
markyrocks Posted January 10, 2020 Author Share Posted January 10, 2020 (edited) 3 hours ago, jdelaney said: Something like this I guess $a = 3 Local $aArray[1] = ["a"] ConsoleWrite(Eval($aArray[0]) & @CRLF) $a = 6 ConsoleWrite(Eval($aArray[0]) & @CRLF) setAVariable($a, 25) ConsoleWrite(Eval($aArray[0]) & @CRLF) Func setAVariable(ByRef $a, $i) $a = $i EndFunc output 3 6 25 this is working, its definitely a move in the right direction. Thankyou its very tricky. #include <Array.au3> Global $array[1]=['temp'] , $UnknownVariable="random value", $temp _aFunction($UnknownVariable) ConsoleWrite(eval($array[0])) ;~ _ArrayDisplay($array) $UnknownVariable=4456 _aFunction($UnknownVariable) ;~ _ArrayDisplay($array) ConsoleWrite(eval($array[0])) _aFunction("34235") ConsoleWrite(eval($array[0])) ;~ _ArrayDisplay($array) func _aFunction($var) $temp=$var EndFunc this technique is sweet and I appreciate it for what it is but it still doesn't off the implicit connection im looking for. I'm basically looking for this int a=5; int* b=&a; *b=10; at this point int a would also be =10. This is part of the downside of not having access to variable pointers bc theres no way to monitor if a variable has changed without adding in some kinda constant loop that the whole point was to just monitor variables that had been passed into a previous function. An the only way to make the connection is by forcing the user to pass the original variable without any value except for the string of its name. I've seen the question asked about turning a variable name into a string b4 and apparently thats not possible? Edited January 10, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Gianni Posted January 11, 2020 Share Posted January 11, 2020 (edited) I don't know if the following is an appropriate way of using @genius257's "AutoItObject Pure AutoIt", and if this way can be useful to you, but this script shows how to "clone" "mirror" a variable (or better, an object) ; https://www.autoitscript.com/forum/topic/185720-autoitobject-pure-autoit/ #include <AutoItObject_Internal.au3> $a = IDispatch() $b = $a $a.value = 1 MsgBox(0, '', $b.value) $b.value = 0 MsgBox(0, '', $a.value) Edited January 11, 2020 by Chimp markyrocks and genius257 1 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
argumentum Posted January 11, 2020 Share Posted January 11, 2020 On 1/9/2020 at 5:55 PM, markyrocks said: the autoit representation of the following c++ code Well, this is all linear, so.., anything that changes, will change in chronological order ( unless is Adlib or a registered call, but then use flags/globals ). So don't get too caught up in the ways of C++ while scripting AutoIt. My 2 cents Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now