You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These issues usually aren't detectable with the converter and need to be fixed manually.
If there is any mistakes or something you believe is missing please leave a comment.
Checking if a variable is set or not has changed significantly between V1 and V2, in V1 it was common for scripts to just check for if !var (as unset was treated as false) but now you need to use if !IsSet(var) (as unset variables are no longer allowed in expressions). We can't convert this as the converter can't tell the difference between if this is a check for an unset variable or if it's a boolean check.
Changed variable scopes
The scope of variables have changed between both versions, in V1, most threads created global variables, especially labels, but functions create local variables, and then that makes issues when labels are converted to functions. To fix this you'll need to run the script (or get an IDE with ahk language support) and look for unset variable warnings / errors, (this could be because of Set variable detection, so check what the code is actually doing), then look for where variable is defined, usually the variable is either defined or used in a block (like a function) and placing global at the top will work.
Sometimes scripts use a variable that never get defined on the surface, this means one of two things, either they create the variable dynamically (for example pseudo arrays), or it never gets defined and the script is falling back to the default value.
This code gets converted to ahk v2 just fine, the only issue being an unset variable warning, but the code still works.
In this case the solution is to use #Warn VarUnset, StdOut which allows for unset variables which actually need fixing to still get caught by a debugger, (using off works too but you won't get the above benefit)
arr := ["A", "B", "C"]
for i, v in arr
var%v% := i
MsgBox % varA "`n" varB "`n" varC
Invalid variable names
Many variable names valid in V1 are no longer valid in V2, mostly from variables the start with numbers, or variables that are reserved words in V2. Usually it is safe to prefix the variable with an underscore _, just check to make sure that it's not already in use. (The converter will be able to handle this in the future, it's just a very big task to implement bug-free.)
Gui
Control names incorrect / overlap
Control variable names conversions aren't great, especially with complex or multiple GUI's. The converter tries to handle these, but with how different they are between versions it's difficult. The fix is to check is the variable is in use and if it is to replace with a unique one, and also check if all variable names are replaced.
Stacked GUI labels
See below section for more details, but remember to add GuiName.OnEvent("EventName", EventCB) for each label.
Labels
Stacked labels and falling in
Stacked labels, (that is 2 or more labels in the same thread), still work in V2, but issues occur when GoSub is used. GoSub almost treats labels as functions, but as it's been removed in V2, we need to convert the label to a function. To fix this, each label needs to be converted to a function (not nested), and a call to the next function needs to be placed at the bottom, see below example.
LabelA:
MsgBox A
LabelB:
MsgBox B
; Converted toLabelA() {
MsgBox("A")
LabelB()
}
LabelB() {
MsgBox("B")
}
The converter could handle this, but it's hard to implement bug free.
Deleted functions
Many functions have been deleted between V1 and V2 with no built-in alternative, here are some functions added which are out-of-scope for the converter
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Common post conversion issues
These issues usually aren't detectable with the converter and need to be fixed manually.
If there is any mistakes or something you believe is missing please leave a comment.
Contents
Variables
Set variable detection
Checking if a variable is set or not has changed significantly between V1 and V2, in V1 it was common for scripts to just check for
if !var
(as unset was treated as false) but now you need to useif !IsSet(var)
(as unset variables are no longer allowed in expressions). We can't convert this as the converter can't tell the difference between if this is a check for an unset variable or if it's a boolean check.Changed variable scopes
The scope of variables have changed between both versions, in V1, most threads created global variables, especially labels, but functions create local variables, and then that makes issues when labels are converted to functions. To fix this you'll need to run the script (or get an IDE with ahk language support) and look for unset variable warnings / errors, (this could be because of Set variable detection, so check what the code is actually doing), then look for where variable is defined, usually the variable is either defined or used in a block (like a function) and placing global at the top will work.
Sometimes scripts use a variable that never get defined on the surface, this means one of two things, either they create the variable dynamically (for example pseudo arrays), or it never gets defined and the script is falling back to the default value.
This code gets converted to ahk v2 just fine, the only issue being an unset variable warning, but the code still works.
In this case the solution is to use
#Warn VarUnset, StdOut
which allows for unset variables which actually need fixing to still get caught by a debugger, (using off works too but you won't get the above benefit)Invalid variable names
Many variable names valid in V1 are no longer valid in V2, mostly from variables the start with numbers, or variables that are reserved words in V2. Usually it is safe to prefix the variable with an underscore
_
, just check to make sure that it's not already in use. (The converter will be able to handle this in the future, it's just a very big task to implement bug-free.)Gui
Control names incorrect / overlap
Control variable names conversions aren't great, especially with complex or multiple GUI's. The converter tries to handle these, but with how different they are between versions it's difficult. The fix is to check is the variable is in use and if it is to replace with a unique one, and also check if all variable names are replaced.
Stacked GUI labels
See below section for more details, but remember to add
GuiName.OnEvent("EventName", EventCB)
for each label.Labels
Stacked labels and falling in
Stacked labels, (that is 2 or more labels in the same thread), still work in V2, but issues occur when
GoSub
is used.GoSub
almost treats labels as functions, but as it's been removed in V2, we need to convert the label to a function. To fix this, each label needs to be converted to a function (not nested), and a call to the next function needs to be placed at the bottom, see below example.The converter could handle this, but it's hard to implement bug free.
Deleted functions
Many functions have been deleted between V1 and V2 with no built-in alternative, here are some functions added which are out-of-scope for the converter
IsFunc()
MinIndex() / MaxIndex()
Beta Was this translation helpful? Give feedback.
All reactions