No subject

Frank D. Engel, Jr. fde101 at fjrhome.net
Fri Apr 1 13:59:09 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, like I said, it was untested ;-)

Also, that last char (the CR which you said is needed to separate the 
lines) is separating the last line from a blank line which was not in 
the original field.  That CR should indeed be removed before sorting in 
order to avoid the blank line being misplaced in the new material, the 
mistake then is in not adding it back in in the next line (after the 
sort).

I'm trying to address the possibility that the sort might move that 
blank line to an earlier line in the string, which would result in the 
string not ending with a CR anyway.  Even if the current version of Rev 
does not do this, I haven't seen any doctumentation that this will 
always be the case, since it is difficult to quantify how an empty 
string fits into a list when sorted numerically.  (personally, I'd 
likely either put it in the beginning or consider it as zero, but 
again, Rev may have stuck it at the end, but is it documented that this 
will always be the case?)

Similarly, the last char (another "original" CR) should be removed from 
the final output when it is placed into the field.

One final note:  all of this assumes unformatted (plain) text.  That 
seems to be the case, so likely not an issue.  Using any of these 
algorithms as presented will result in text formatting being lost if 
there was any.

Thank you for catching those mistakes.  I must be more tired than I 
thought...

on mouseUp
     put empty into sorter
     put empty into sorteddata

     repeat for each line x in field "data"
         if word 1 of x = word 1 of line 1 of sorter then
             put x & cr after sorter
         else
             delete the last char of sorter
             sort lines of sorter numeric by word 2 of each
             put sorter & cr after sorteddata
             put x & cr into sorter
         end if
     end repeat
    delete the last char of sorter
    sort lines of sorter numeric by word 2 of each
    put sorteddata & sorter into field "data"
end mouseUp



On Apr 1, 2005, at 1:46 PM, Howard Bornstein wrote:

> On Apr 1, 2005 12:55 PM, Frank D. Engel, Jr. <fde101 at fjrhome.net> 
> wrote:
>>
>> Untested clean-up of that code:
>>
>
>
> Your clean-up code needed a little cleaning up. :-)
>
> on mouseUp
>     put empty into sorter -- these two lines are mainly to make me
> feel a little better,
>     put empty into sorteddata -- coming from a background in
> lower-level languages like Pascal
>
>     repeat for each line x in field "data"
>         if word 1 of x = word 1 of line 1 of sorter then
>             put x & cr after sorter
>         else
>             --delete the last char of sorter -- you need this CR to
> separate the lines
>             sort lines of sorter numeric by word 2 of each
>             put sorter after sorteddata
>             put x & cr into sorter -- added "& cr"
>         end if
>     end repeat
>    sort lines of sorter numeric by word 2 of each --otherwise the
> final sort never happens
>
>     put sorteddata & sorter into field "data"
> end mouseUp
>
> -- 
> Regards,
>
> Howard Bornstein
> -----------------------
> www.designeq.com
>
>
- -----------------------------------------------------------
Frank D. Engel, Jr.  <fde101 at fjrhome.net>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCTZn97aqtWrR9cZoRAs9mAJ43ETinCdJe8E0oqs9vtSgps0qYVwCeMV8x
+hQqW0Jm4+aJltFWtSH19MU=
=037b
-----END PGP SIGNATURE-----



___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com



More information about the use-livecode mailing list