luddenm Posted May 12, 2011 Share Posted May 12, 2011 $Var1 = "C:\" Func Formatc() @comspec Format $Var1 endFunc I want to be able to remove the slash at the end of C:\ so that Var1 = C: in Formatc Function. Thanks I know there is probably a better way to do it but i am a beginner. Link to comment Share on other sites More sharing options...
wakillon Posted May 12, 2011 Share Posted May 12, 2011 you can use a basic StringReplace : $Var1 = "C:\" $Var1 = StringReplace ( $Var1, ":\", ":") AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
hannes08 Posted May 12, 2011 Share Posted May 12, 2011 Or StringTrimRight() $Var1 = StringTrimRight($Var1, 1) Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
smartee Posted May 12, 2011 Share Posted May 12, 2011 hi luddenm, Search the help-file for StringTrimRight(). Example:$result = StringTrimRight("C:\", 1) MsgBox(0, "String without rightmost character is:", $result) Hope this helps -smartee Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 12, 2011 Share Posted May 12, 2011 (edited) This function could be used too probably, http://www.autoitscript.com/autoit3/docs/functions/StringTrimRight.htm Edited May 12, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
wakillon Posted May 12, 2011 Share Posted May 12, 2011 A bit slow guys ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
UEZ Posted May 12, 2011 Share Posted May 12, 2011 (edited) Or the StringTrimRight() function: $Var1 = "C:\" Formatc($Var1) Func Formatc($drive) MsgBox(0, "Test", "@comspec format " & StringTrimRight($drive, 1)) EndFunc Or StringLeft() function: $Var1 = "C:\" Formatc($Var1) Func Formatc($drive) MsgBox(0, "Test", "@comspec format " & StringLeft($drive, 2)) EndFunc Br, UEZ Edited May 12, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
luddenm Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks guys, went with the StringTrimRight and worked. Link to comment Share on other sites More sharing options...
UEZ Posted May 12, 2011 Share Posted May 12, 2011 It will fail if your string is not c:\ In my opinion StringLeft() is the best choice here because it doesn't care about the string behing the 2nd character. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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