jlc@atux01.UUCP (J. Collymore) (03/21/89)
I have been trying for several days now to perform a sort of the date (and time) in my HyperCard (HC) stack. Although I can get it to sort the date of my cards properly, I can not seem to get it to also sort those dates according to the proper time, whether in ascending (default) or descending order. For example, I sometimes get an ascending sort showing card #1 as 3/20/89 at 5:39 PM before card #2 which reads 3/20/89 at 5:22 PM! (Please note the times. In this example, the second card should come FIRST.) My sort code reads: sort by dateTime word x of line x of bg field x What am I doing wrong? What should the script look like so that the date is in ascending order, but is also ascending appropriately for the time values also on the card field? Thanks for your help. Jim Collymore
jm7f+@andrew.cmu.edu (Joe Melvin) (03/22/89)
jlc@atux01.UUCP (J. Collymore) writes: (17 Mar 89): >I need help with this scripting problem. >I have two lines on a field. The first line ends with the "abbr date" >(e.g., 3/17/89), and the other ends with the time. THe problem is >that when I do a sort on two cards; one of them saying: 3/17/89, >8:24 AM; and the other card saying 3/17/89, 8:31 AM, the card >with the 8:31 time appears FIRST following the sort, NOT second >as it should! I have tried doing an ascending sort, also to correct >this, but nothing seems to work. and, (20 Mar 89): >I have been trying for several days now to perform a sort of >the date (and time) in my HyperCard (HC) stack. >Although I can get it to sort the date of my cards properly, I >can not seem to get it to also sort those dates according to the >proper time, whether in ascending (default) or descending order. >For example, I sometimes get an ascending sort showing card >#1 as 3/20/89 at 5:39 PM before card #2 which reads 3/20/89 >at 5:22 PM! (Please note the times. In this example, the second >card should come FIRST.) My sort code reads: >sort by dateTime word x of line x of bg field x >What am I doing wrong? What should the script look like so >that the date is in ascending order, but is also ascending >appropriately for the time values also on the card field? The easiest option would be to store the seconds in a hidden field (below I call this hidden field "secnds") whenever you store the date and time in the visible field: example: --************************ --your code for however you get the date and time here --then the following: put the seconds in fld "secnds" --end of this chunk of code --*********************** Then, whenever you do a sort, sort by the "secnds" field. If the stack already has data, the times already in the stack will of course have to be stored in the hidden "secnds" field before you sort. If I interpreted where you have the date and time correctly in the visible field, the following code will work: --************************* --fld "visDayTime" is your field with the day and time put last word of line 1 of fld "visDayTime" into theDay put the number of words of line 2 of fld "visDayTime" into numWds2 put word (numWds2 - 1) to numWds2 of line 2 of fld "visDayTime" into theTime put theDay && theTime into dayAndTime convert dayAndTime to seconds put dayAndTime into fld "secnds" --end of this chunk of code --************************ And that's it. Now if you sort by this hidden bg fld "secnds", your times will be in the correct order. -Joe Melvin jm7f@andrew.cmu.edu (Carnegie Mellon University)
dan@Apple.COM (Dan Allen) (03/23/89)
In article <1030@atux01.UUCP> jlc@atux01.UUCP (J. Collymore) writes: >I have been trying for several days now to perform a sort of the date (and >time) in my HyperCard (HC) stack. > >Although I can get it to sort the date of my cards properly, I can not seem >to get it to also sort those dates according to the proper time, whether in >ascending (default) or descending order. For example, I sometimes get an >ascending sort showing card #1 as 3/20/89 at 5:39 PM before card #2 which >reads 3/20/89 at 5:22 PM! (Please note the times. In this example, the second >card should come FIRST.) My sort code reads: > >sort by dateTime word x of line x of bg field x You are sorting ONLY by the date (word x) rather than all of the line. It sounds like if you said sort by dateTime line x of bg field x that it would then sort the date and time. If it doesn't then you may need to convert the date and time to seconds and then sort on that. Dan Allen