Extracting part of a string from a variable

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
stevenwhyte
Posts: 14
Joined: Mon Jan 12, 2015 7:55 pm

Extracting part of a string from a variable

Post by stevenwhyte » Sat Jan 17, 2015 8:57 pm

If I have some text, e.g. "elephant" stored in the variable MyString, how would I extract the last three characters from the variable MyString to get "ant"?

In other languages, the function Right(MyString, 3) would do this but there doesn't seem to be such a function in LiveCode.

Many thanks,

Steven

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Extracting part of a string from a variable

Post by Dixie » Sat Jan 17, 2015 9:05 pm

Code: Select all

on mouseUp
   put char -3 to -1 of myString
end mouseUp

stevenwhyte
Posts: 14
Joined: Mon Jan 12, 2015 7:55 pm

Re: Extracting part of a string from a variable

Post by stevenwhyte » Sat Jan 17, 2015 9:17 pm

Thank you :D

Post Reply