Jump to content
Sign in to follow this  
milad

get length of data ?

Recommended Posts

milad

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

Share this post


Link to post
Share on other sites
milad

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 .

Share this post


Link to post
Share on other sites
ResNullius

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.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.