Grabbing X number of characters from the end of a line

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
pink
Posts: 272
Joined: Wed Mar 12, 2014 6:18 pm

Grabbing X number of characters from the end of a line

Post by pink » Fri May 02, 2014 2:03 pm

as the subject says, I'm looking to take the last 7 characters from each line of a field and put them into another field, so I will start with something like this:

ABSD-A234567
LKI:A654321
A987654
BUFA314151

and end up with:

A234567
A654321
A987654
A314151

so, the last 7 bits of info are the only relevant part I want to keep, and the rest of it can vary in size and may or may not have a delimiter

This was my most recent try which didn't work:

Code: Select all

     repeat for each line mmPin in field "input"
          put last 7 char of mmPin & return after the field "output"
     end repeat
Any thoughts?
Thanks,
Greg
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Grabbing X number of characters from the end of a line

Post by LCNeil » Fri May 02, 2014 2:18 pm

Hi Greg,

Try something like this-

Code: Select all

on mouseUp
   repeat for each line mmPin in field 1
                put char -7 to -1 of mmPin & return after  field 2
        end repeat
end mouseUp
nb Replace the field names with your field names :)

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

pink
Posts: 272
Joined: Wed Mar 12, 2014 6:18 pm

Re: Grabbing X number of characters from the end of a line

Post by pink » Fri May 02, 2014 5:07 pm

That did it, THANKS!
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

Post Reply

Return to “idea2app and Coding School”