KurogamineNox 0 Posted June 20, 2010 Not sure if this is simple or not. Let me scale this down. Variable's $Text $Array(because I think ill be needing array's for this) ok say my $Text = NoxTal: /open http://google.com I think ill need an array part but im stuck on that. What I need is it to see if $Text contains ": /open "(without quotations, all spaces included) Get rid of the ": /open " and everything on the left side, that way $Text only contains http://google.com Is this possible? Share this post Link to post Share on other sites
Yoriz 6 Posted June 20, 2010 This should do it. $Text = "NoxTal: /open http://google.com" $sRemoveString = ": /open " MsgBox(0, "changed string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "NoxTal: /Notopen http://google.com" MsgBox(0, "showing it wont change this string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "Banana: /open http://www.autoitscript.com" MsgBox(0, "Another changed string", _RemoveLeftOfString($Text, $sRemoveString)) Func _RemoveLeftOfString($sString, $sRemoveString) Local $iStringPos = StringInStr($sString, $sRemoveString) If $iStringPos Then Return StringTrimLeft($sString, $iStringPos + StringLen($sRemoveString) - 1) EndIf Return $sString EndFunc ;==>_RemoveLeftOfString GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Share this post Link to post Share on other sites
KurogamineNox 0 Posted June 20, 2010 This should do it. $Text = "NoxTal: /open http://google.com" $sRemoveString = ": /open " MsgBox(0, "changed string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "NoxTal: /Notopen http://google.com" MsgBox(0, "showing it wont change this string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "Banana: /open http://www.autoitscript.com" MsgBox(0, "Another changed string", _RemoveLeftOfString($Text, $sRemoveString)) Func _RemoveLeftOfString($sString, $sRemoveString) Local $iStringPos = StringInStr($sString, $sRemoveString) If $iStringPos Then Return StringTrimLeft($sString, $iStringPos + StringLen($sRemoveString) - 1) EndIf Return $sString EndFunc ;==>_RemoveLeftOfString Ty, this worked very well. I love how this community is helpful. I do hope I can be experienced enough like you guys. Share this post Link to post Share on other sites
KurogamineNox 0 Posted June 20, 2010 (edited) This should do it. $Text = "NoxTal: /open http://google.com" $sRemoveString = ": /open " MsgBox(0, "changed string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "NoxTal: /Notopen http://google.com" MsgBox(0, "showing it wont change this string", _RemoveLeftOfString($Text, $sRemoveString)) $Text = "Banana: /open http://www.autoitscript.com" MsgBox(0, "Another changed string", _RemoveLeftOfString($Text, $sRemoveString)) Func _RemoveLeftOfString($sString, $sRemoveString) Local $iStringPos = StringInStr($sString, $sRemoveString) If $iStringPos Then Return StringTrimLeft($sString, $iStringPos + StringLen($sRemoveString) - 1) EndIf Return $sString EndFunc ;==>_RemoveLeftOfString Ok, ive run into another problem, I try to work on the coding before I ask another question(Didnt want to be lazy and just keep asking without trying). so I tried to implament your code to work with multiple values. Example. say the original $Text = "NoxTal: /open http://google.com" it got the $text = http://google.com Now say i wanted multiple conditions. /open /calc /notepad just for a use of examples. say it catches the ": /open ", i want it to go to a function that activates ShellExecute($Text)(since $text = http://www.google.com) now say it catches ": /calc ", "NoxTal: /calc", I tried to get it to a code that calls the Func Calc() and have it open calc.exe I failed to do that. What would I need to edit to have this run with multiple values? if at all possible. Edit: I dont know, maybe case could work? using the case function. case ": /open " Call("Website") i dont know. It came into my mind while looking at another coding I had. Edited June 20, 2010 by KurogamineNox Share this post Link to post Share on other sites
Yoriz 6 Posted June 20, 2010 Something like this ? $sRemoveString = ": /open " $Text = "NoxTal: /open http://google.co.uk" MsgBox(0, "", _RemoveLeftOfString($Text, $sRemoveString)) _DoSomething($Text) $Text = "NoxTal: /calc" _DoSomething($Text) $Text = "NoxTal: /notepad" _DoSomething($Text) Func _DoSomething($sString) Select Case StringInStr($sString, ": /open ") ShellExecute(_RemoveLeftOfString($sString, ": /open ")) Case StringInStr($sString, ": /calc") ShellExecute("Calc") Case StringInStr($sString, ": /notepad") ShellExecute("notepad") EndSelect EndFunc ;==>_DoSomething Func _RemoveLeftOfString($sString, $sRemoveString) Local $iStringPos = StringInStr($sString, $sRemoveString) If $iStringPos Then Return StringTrimLeft($sString, $iStringPos + StringLen($sRemoveString) - 1) EndIf Return "" EndFunc ;==>_RemoveLeftOfString GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Share this post Link to post Share on other sites
KurogamineNox 0 Posted June 20, 2010 Something like this ? $sRemoveString = ": /open " $Text = "NoxTal: /open http://google.co.uk" MsgBox(0, "", _RemoveLeftOfString($Text, $sRemoveString)) _DoSomething($Text) $Text = "NoxTal: /calc" _DoSomething($Text) $Text = "NoxTal: /notepad" _DoSomething($Text) Func _DoSomething($sString) Select Case StringInStr($sString, ": /open ") ShellExecute(_RemoveLeftOfString($sString, ": /open ")) Case StringInStr($sString, ": /calc") ShellExecute("Calc") Case StringInStr($sString, ": /notepad") ShellExecute("notepad") EndSelect EndFunc ;==>_DoSomething Func _RemoveLeftOfString($sString, $sRemoveString) Local $iStringPos = StringInStr($sString, $sRemoveString) If $iStringPos Then Return StringTrimLeft($sString, $iStringPos + StringLen($sRemoveString) - 1) EndIf Return "" EndFunc ;==>_RemoveLeftOfString Yes, I think this works exactly as I needed. The Case structure works well. Everything is based off the StringInStr command. Thank you. Im sure I can implement this. Thank you Yoriz. Share this post Link to post Share on other sites