Line Numbers
D.Rothe
drothe at optusnet.com.au
Sun Jan 2 18:29:08 EST 2005
Message: 17
Date: Sat, 01 Jan 2005 02:25:00 +0000
From: Alex Tweedly <alex at tweedly.net>
Subject: Re: Line Numbers
To: How to use Revolution <use-revolution at lists.runrev.com>
Message-ID: <41D609FC.9090903 at tweedly.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Thanx for the help Alex the code worked great, I just changed the line;
put tCounter && L & cr after tDisplayData -- shows line numbers and data in field.
to
put tCounter & cr after tDisplayData -- shows only line numbers.
and thanx to Ken Ray & Wilhelm Sanke for the following line!!
on scrollBarDrag
set the scroll of fld 1 to the scroll of me
end scrollBarDrag
It's often the simplest code that gets the job done!
Cheers and thanx again...Dwayne.R
--------------
D.Rothe wrote:
>G'Day and Happy New Year to all!!!!!!!!
>
>I am hoping someone could guide me with the following prob.
>I have two fields (field 1 & field 2), field 2 is for loading and displaying a txt file and field 1
>is for displaying each corresponding line number of field 2.
>The line numbers must be in a seperate field otherwise they will show when printing field 2.
>
>Obviously field 2 is a scrolling field so the problem is getting field 1 to scroll in unison with field 2 so the line numbers match the correct line.
>
>Any ideas on the code or maybe a different solution!!!!
>
>
put URL "file:temp.txt" into tData
put empty into tDisplayData
put 0 into tCounter
repeat for each line L in tData
put tCounter && L & cr after tDisplayData
add 1 to tCounter
end repeat
put tDisplayData into field "Field"
It may look clumsy to scan through each line like this - but Rev is very
fast at doing that. This did my 6000 line, 1 Mb file in about 80
millisecs - so you don't need to worry about speed.
You could also do it by some variation of setting the vscroll of field
1 to the thumbpos of field 2
but I just find it easier to do it this way.
You could also do it by putting the two fields into a group and
scrolling the group (I think - haven't tried that way myself).
Happy New Year !!
-- Alex.
-----------------------------------------------------------
More information about the use-livecode
mailing list