Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Lcase, mid and trim


kirill.emko
 Share

Recommended Posts

Hello. I'm just a begginer in scripting and i have 1 question. Could somebody explain what this two subjects mean. Not they all, but operators Lcase and mid in thise line:
If LCase(Mid(textsay, 1, 3)) = "/g " Then
and operator trim and Mid here:
TextSay = trim(Mid(TextSay, 3, Len(TextSay) - 2))
thise code fragments are from here: http://www.touchofdeathforums.com/smf/index.php?topic=27767.0
I searched all forum but couldn't find any information on this.
thanks before.
Link to comment
Share on other sites

@FS:CG :

> link=topic=33355.msg305913#msg305913 date=1225675201]
> Lcase will force the string to be lowercase…
> so if you types /G or /g it will still work and you dont have to code the whole thing twice.
>
> Trim I beleive will create something if it doesnt already exist... i think, may be wrong there.
>
> Mid, no clue.

lcase, right

trim wrong.

trim makes this: hi guys how are you

into this: higuyshowareyou

don't remember mid
Link to comment
Share on other sites

I see LCase and Trim have already been covered, so I'll finish up with Mid.
Mid returns a substring of, or part of the string, you put into it (presumably the middle [hence the name], but it's whatever you tell it to), and works like this:
Mid(text, start, length)
Text is the text you want to parse (basically, modify), start is the character that you want to start returning the substring from, and length is the length of the substring it returns. 

Examples:
Mid("I want an apple", 11, 5) will return "apple". 
Mid("Example", 3, 2) will return "am". 
Mid(TextSay, 7, Len(TextSay) - 6) will return everything from the 9th character of TextSay to the end.  If TextSay was "/jail randomnoob", it'll return "randomnoob". 

Anyways, if it interests you, the reason you couldn't find the answer to these questions in other places on the forum is because these are functions that exist in VBScript and not just in SadScript.
Link to comment
Share on other sites

Trim() removes spaces from the beginning and end.

Trim("            this text            ") becomes simply "this text"

As a side note, the third parameter of Mid() is optional. Mid(TextSay, 7) returns the rest of the text after the 7th character.
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

×
×
  • Create New...