Code: Select all
Clipboard=
ClipWait
myvar:=Clipboard ;FN0089
if( RegExMatch(myvar, "(.*?)(\d+)$", splitted) )
splitted2 := splitted2 +1
Sleep 100
MsgBox, %splitted1%%splitted2% ;FN90 (supposed to be FN0090)
Code: Select all
Clipboard=
ClipWait
myvar:=Clipboard ;FN0089
if( RegExMatch(myvar, "(.*?)(\d+)$", splitted) )
splitted2 := splitted2 +1
Sleep 100
MsgBox, %splitted1%%splitted2% ;FN90 (supposed to be FN0090)
Code: Select all
ClipBoard := "FN0089" ; for testing
SetFormat, float, 04.0 ; "reset" zero padding
myVar := SubStr(Clipboard,3) ; extract the number from the (fixed lenght) string
MsgBox % "FN" . myvar += 1.0 ; add 1 to the current number and concatinate it with the string
reliable answer, thank you very muchBoBo wrote:A more sophisticated method: Format ...Code: Select all
ClipBoard := "FN0089" ; for testing SetFormat, float, 04.0 ; "reset" zero padding myVar := SubStr(Clipboard,3) ; extract the number from the (fixed lenght) string MsgBox % "FN" . myvar += 1.0 ; add 1 to the current number and concatinate it with the string
Code: Select all
splitted2:=SubStr("0000" . splitted2+1,-3)
Thanks Joe, your code works handy.JoeWinograd wrote:Hi ivill,
There are often many ways to achieve objectives in AHK. Another way to do it is shown here:
https://autohotkey.com/boards/viewtopic ... 09#p170209
And explained here:
https://autohotkey.com/boards/viewtopic ... 34#p170634
So, in your case, you can leave all of your code as is, except change the splitted2 assignment statement to:
Regards, JoeCode: Select all
splitted2:=SubStr("0000" . splitted2+1,-3)
Thanks for all of you, i took up Joe's suggestion,Helgef wrote:See format. Eg splitted2 := format("{:04}", splitted2 + 1)
Edit: I see now that Bobo mentioned it, my eyes are confused by all that green / yellow stuff.
Code: Select all
splitted2:=SubStr("0000" . splitted2+1,-3)
Code: Select all
q::
vText := "FN0089"
vText := RegExReplace(vText, "\d+$", "|$0")
oTemp := StrSplit(vText, "|")
vText := oTemp.1 Format("{:04}", oTemp.2+1)
oTemp := ""
MsgBox, % vText
return
Code: Select all
q::
vText := "FN0089"
vText := RegExMatch(vText, "O)(.*?)(\d+)$", o)
;vText := o.Value(1) Format("{:04}", o.Value(2)+1)
vText := o.1 Format("{:04}", o.2+1)
o := ""
MsgBox, % vText
return