Hi,
I have a variable named ‘Mobile Number’ I want to setup an if statement. if KM variable starts with the number ‘7’ then add a ‘0’ to the beginning of the variable to make it ‘07…’
i am having difficulty doing this…
can anyone assist?
Thanks
Hi,
I have a variable named ‘Mobile Number’ I want to setup an if statement. if KM variable starts with the number ‘7’ then add a ‘0’ to the beginning of the variable to make it ‘07…’
i am having difficulty doing this…
can anyone assist?
Thanks
@alain’s solution is very good, a probably the best way to do it.
You can also do exactly what you said by using the If Then Else action and a Set Variable to Text action.
Thank you both very much.
Hey Ali,
Just to add some variety let’s do that with AppleScript.
-Chris
------------------------------------------------------------
# Requires Keyboard Maestro 7.0.2 or later.
------------------------------------------------------------
tell application "Keyboard Maestro Engine"
tell variable "Mobile Number"
if it exists then
set myMobileNumber to its value
if myMobileNumber starts with "7" then
set myMobileNumber to "0" & myMobileNumber
end if
end if
end tell
end tell
------------------------------------------------------------