Returning the Keys
janschenkel at yahoo.com
Sun Dec 7 11:53:12 CST 2008
--- Marcus Lindley <lindley8 at telus.net> wrote:
> How do I put a lineOffset into an array and return
> them with other keys?
> I've tried this:
> function myFunction myVariable
> repeat for each line thisLine in myVariable
> put lineOffset(myline,myVariable) & return
> into myArray[linenumber] -- trying to return the
> lineOffset for the unique line in the text
> add 1 to myArray[thewords] -- returns the
> unique lines in the text
> end repeat
> return the keys of myArray
> end myFunction
> I've tried several variations, but the only thing
> that is ever returned from the [lineNumber] key is
> "lineNumber" (in stead of,
> for instance "line 4 of fld 22")
> How do I return the lineOffset in this array
I have to say I'm a little confused by your question.
None of the variables myLine, linenumber and thewords
are initialized anywhere.
When you use the 'repeat for each line' loop, you can
easily track the line number you're on by incrementing
a separate variable.
put 0 into theLineNumber
repeat for each line theLine in theVariable
add 1 to theLineNumber
-- now do whatever you need with the current line
But other than that, it's easiest if you give us a
short example of input data and what the output should
look like. Then we can help you find the best
algorithm for the job at hand.
Quartam Reports & PDF Library for Revolution
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
More information about the use-livecode