@just me, I ran into this issue today while trying to use objects, are there any trix here or is this a limitation with objects ?
Code: Select all
PIDs := {vlc:"0"}
run 'vlc.ahk', "D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\",,&PIDs.vlc
@just me, I ran into this issue today while trying to use objects, are there any trix here or is this a limitation with objects ?
Code: Select all
PIDs := {vlc:"0"}
run 'vlc.ahk', "D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\",,&PIDs.vlc
I think you could do that with no issues if the property held a variable reference (VarRef) and then dereferenced it outside after giving it to run, but it looks kinda murky and verbose creating var refs on the spot like that. Going by some post I stumbled years ago from lexikos, the reference count on the VarRef would be decreased properly once the original var goes out of scope from the fat arrow, I haven't checked to see if there are other implications.j46 wrote: ↑30 Dec 2023, 18:09@just me, I ran into this issue today while trying to use objects, are there any trix here or is this a limitation with objects ?i get the error ==> "&" requires a variableCode: Select all
PIDs := {vlc:"0"} run 'vlc.ahk', "D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\",,&PIDs.vlc
Code: Select all
PIDs := { vlc: ((ref?)=>&ref)() }
run 'vlc.ahk', "D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\",, PIDs.vlc ; no "&" here
msgbox(%pids.vlc%)
pids.vlc := %pids.vlc% ; should release the last reference and leave the var ref to be collected.