Jump to content

Removing a charcter from the end of a variable.


Recommended Posts

$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 :unsure:

I know there is probably a better way to do it but i am a beginner.

Link to comment
Share on other sites

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 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...