Returning the Keys

Jan Schenkel janschenkel at yahoo.com
Sun Dec 7 12:53:12 EST 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
> properly?
> 

Hi Marcus,

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
number
end repeat
##

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.

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list