Page 1 of 1

the line number in a variable

Posted: Sat Jul 11, 2015 5:59 am
by scotttyang
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

Re: the line number in a variable

Posted: Sat Jul 11, 2015 8:07 am
by jmburnod
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

Re: the line number in a variable

Posted: Sat Jul 11, 2015 2:02 pm
by Randy Hengst
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