String functions help

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lharris
Posts: 20
Joined: Fri May 22, 2009 5:27 pm

String functions help

Post by lharris »

Hi - I'm somewhat embarrassed to ask this but I'm having problems finding this in the docs.
Is there a function similar to "leftstring" in other languages that will return the specified contents of a string. Such as if x="123456" then leftstring(x,3) would return "123"
I know I could probably use find to do the same but was hoping its already there.
Thanks
/leonard
ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Re: String functions help

Post by ibe »

Revolution User Guide chapter 6: 'Processing Text and Data' page 174 onwards.

To get the left 3 characters:
put char 1 to 3 of "123456"
123

To get the right 3 characters
put char -3 to -1 of "123456"
456

Not that obvious but once you take the time to learn this chapter, processing text is really quite simple. And you can always make your own function leftstring that hides how Revolution does it.

Cheers,

Ismo
lharris
Posts: 20
Joined: Fri May 22, 2009 5:27 pm

Re: String functions help

Post by lharris »

Thanks - knew it had to be that simple and somewhere in the docs.
/leonard
Post Reply