asgarcymed Posted October 6, 2007 Share Posted October 6, 2007 The mathematical operators are easy to use and everybody knows:$a=10$b=1$a + $b = 11$a - $b = 9 However, if variables are strings rather than numbers, sometimes is confusing...$a = "AAAAAAAZZZZZZZZZZZZZZZ"$b = "ZZZZZZZZZZZZZZZ"$a & $b (the correct; not $a + $b because no numbers!) = "AAAAAAAZZZZZZZZZZZZZZZAAAAAAAZZZZZZZZZZZZZZZ"My question is -How to subtract characters using string variables?:«$a -$b» = "AAAAAAA" (what is the correct expression, instead of «$a -$b»?)Regards. MLMK - my blogging craziness... Link to comment Share on other sites More sharing options...
BrettF Posted October 6, 2007 Share Posted October 6, 2007 (edited) Maybe... MsgBox (0, "", _StringLikeMath ("aaaaaaaaaaaaaaaaxxxxxxxxxxxxxxxx", "*", 10)) Func _StringLikeMath ($a, $op, $b) Local $ret If $op = "-" Then $ret = StringReplace ($a, $b, "", 1, 1) ElseIf $op = "+" Then $ret = $a & $b ElseIf $op = "*" Then For $i = 1 to $b $ret &= $a Next ElseIf $op = "/" Then $ret = "Not sure what to do... ERROR! EEP! =P" EndIf Return $ret EndFunc Edited October 6, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
asgarcymed Posted October 6, 2007 Author Share Posted October 6, 2007 Thanks! MLMK - my blogging craziness... Link to comment Share on other sites More sharing options...
BrettF Posted October 6, 2007 Share Posted October 6, 2007 Thanks! Just use the part you need in the actual function I created... The rest was a bit of fun, so you could get the general idea Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
asgarcymed Posted October 6, 2007 Author Share Posted October 6, 2007 Your code made me to learn what I was looking for and much more! A big thank you! MLMK - my blogging craziness... 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