[REBOL] Re: files out of order
From: ryanc:iesco-dms at: 29-Mar-2001 15:55
Use this before you pass the files to your read-directory-messages function:
sort-function: func [a b] [
a: info? a
b: info? b
a/date < b/date
]
sort/compare message-directory :sort-function
This function will only work if the files are referenced to the current working directory
(what-dir). Keep in mind the function passed to sort/compare can only take two arguments,
so use
inheritence to enhance it, such as with a path.
--Ryan Cole
[ryan--christiansen--intellisol--com] wrote:
> sort/reverse message-block
>
> Did not work. Look at this page to see what I'm talking about. The messages
> should be appearing based on time of creation, with the last created
> message at the top of the list. Something is wrong.
>
> http://www.fargonews.com/cgi-bin/messages.cgi?actionType=display&messageType=news&messageID=none
>
> Ryan C. Christiansen
> Web Developer
>
> Intellisol International
> 4733 Amber Valley Parkway
> Fargo, ND 58104
> 701-235-3390 ext. 6671
> FAX: 701-235-9940
> http://www.intellisol.com
>
> Global Leader in People Performance Software
>
> _____________________________________
>
> Confidentiality Notice
> This message may contain privileged and confidential information. If you
> think, for any reason, that this message may have been addressed to you in
> error, you must not disseminate, copy or take any action in reliance on it,
> and we would ask you to notify us immediately by return email to
> [ryan--christiansen--intellisol--com]
>
> "GS Jones"
> <[gjones05--mail]. To: <[rebol-list--rebol--com]>
> orion.org> cc:
> Sent by: Subject: [REBOL] Re: files out of order
> [rebol-bounce--re]
> bol.com
>
> 03/29/2001
> 02:07 PM
> Please respond
> to rebol-list
>
> From: <[ryan--christiansen--intellisol--com]>
> > I have a directory of XML-formatted messages,
> > each saved with a numeric
> > filename based on the time of creation, for example
> >
> > /news/20010329105032.txt
> > /news/20010329105033.txt
> > /news/20010329105034.txt
> >
> > I use the following function to read the directory
> > and to create a block of file names, with the
> > intention of placing the newest files first in the
> > block (in other words, the files with the highest
> > number first in the block.)
> >
> > read-directory-messages: func [
> > "Read a directory of XML-formatted standard messages with the
> directory
> > determined by messageType."
> > message-directory [block!] "A block of file names corresponding to a
> > directory of XML-formatted standard messages."
> > ][
> > message-block: copy []
> > foreach file-name message-directory [
> > file-contents: read file-name
> > insert message-block file-contents
> > ]
> > ]
> >
> > But using the above function, I get files showing up in the block out of
> > order. Am I doing something wrong?
> >
> > Ryan C. Christiansen
>
> If I understand your intention correctly (which is a big assumption for me
> on some days :-), then I would suggest reverse sorting the file names
> before
> using the foreach block. For example, add this line before the foreach:
> sort/reverse message-block
> The file names should then be sorted largest first, therefore allowing the
> foreach to iterate through the block in this order. Worth a try anyway.
>
> Regards,
> --Scott Jones
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
I am enough of an artist to draw freely upon my imagination.
Imagination is more important than knowledge. Knowledge is
limited. Imagination encircles the world.
-Einstein