milad Posted January 9, 2010 Share Posted January 9, 2010 hello my friends. I write an Autoit script for my project . now I have a string in my project and need too check the string length . and if string length is larger than 100 characters, get just 100 characters from 1 too 100 . can anyone help me ? for example : check $data length $length = $data length if $length > 100 -then-> $data = first 100 characters of $data Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 9, 2010 Share Posted January 9, 2010 Function StringLen - 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...
milad Posted January 9, 2010 Author Share Posted January 9, 2010 thanks a lot . now I get the $data length $Ln = StringLen ( $Data ) if $Ln > 100 Then $Data = ... EndIf I need to set $data = first 100 characters of $data if Ln > 100 characters . Link to comment Share on other sites More sharing options...
gkrapp Posted January 9, 2010 Share Posted January 9, 2010 StringLeft Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 9, 2010 Share Posted January 9, 2010 Try this.. If $Ln > 100 Then $Data = StringLeft($Data, 100) - 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...
ResNullius Posted January 10, 2010 Share Posted January 10, 2010 Actually, you don't even need to do the StringLen() check, you can just do $Data = StringLeft($Data, 100) If the string is shorter than 100, it's not altered. 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