the line number in 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
scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

the line number in a variable

Post by scotttyang » Sat Jul 11, 2015 5:59 am

I had always used find and foundline, but only in Text fields, but what about finding the line in a variables?

If my variable x has

A
B
C
D
E

how do I find the line where "C' is located in the variable "x"?

Scott

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: the line number in a variable

Post by jmburnod » Sat Jul 11, 2015 8:07 am

Hi Scott,

What about this:

Code: Select all

   put "A,B,C,D,E" & cr into x
   replace "," with cr in x
   put lineoffset(C & cr,x)
Best regards
Jean-Marc
https://alternatic.ch

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Thu Jun 29, 2006 4:16 pm

Re: the line number in a variable

Post by Randy Hengst » Sat Jul 11, 2015 2:02 pm

You could try:

local tVariableWithLines

repeat with x = 1 to the number of lines in tVariableWithLines
if line x of tVariableWithLines = "C" then
answer x
end if
end repeat

be well,
randy

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”