Last but one

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Last but one

Post by richmond62 » Mon Sep 02, 2019 1:42 pm

So, here I am trying to analyse a whopping-great text for words with certain
suffixes (= bits that go on the end of words) . . .

Now, it is dead easy to analyse texts for prefixes (= bits that go on the front of words)
using a series of nested loops for char 1, char, char 3 and so on . . .

Now I can ask questions about the last char of a word . . .

But, short of popping that word into a variable and nipping characters of the end
sequentially it seems "a bit of a pain" as I cannot do this sort of thing . . .

pseudoCode

last char
(last -1) char
(last -2) char

nicht?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Last but one

Post by Klaus » Mon Sep 02, 2019 1:49 pm

Maybe you mean:
char -1 of xxx ## = last char
char -2 of xxx ## = last but one char
char -3 of xxx ## = you guess...
?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Last but one

Post by richmond62 » Mon Sep 02, 2019 1:51 pm

Wow, Klaus, you're the man! :D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Last but one

Post by bogs » Mon Sep 02, 2019 2:18 pm

Or if you combined those and cut out the middle, (if your talking about *just* the last 3 characters) why not

char -3 to -1 of xxx ## = last 3 chars

Code: Select all

put "working" into tmpWord; put char -3 to -1 of tmpWord
= "ing"
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Last but one

Post by richmond62 » Mon Sep 02, 2019 7:05 pm

Wow: I could get completely "bogged" down. :D

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Last but one

Post by bogs » Mon Sep 02, 2019 7:10 pm

I know I do :D
Image

Post Reply