[ List Archives Home ] [ Thread index for 2008 ] [ Date index for 2008 ] [ Author index for 2008 ]


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Someone should make a t-shirt that says "You can't do that in Create Lists."

I insert the date x days ago into Create Lists using an Expect script. Expect scripts are things that run on some other computer that log into your character-based system and do things that you script; The NOBLE Swap Shop is one place that explains this further:

http://www.noblenet.org/swapshop/expect/

Some people who use Expect have asked me for the details of inserting a past date so here they are:

I have the past date procedure set up in a separate file (definitions.tcl) that gets included in the expect scripts where it's needed using this line in the expect script:

source /yourpath/definitions.tcl

I call my procedure "findpastdate", and it takes one argument, which is the number of days ago. It returns that date in the right format for Create Lists. Here's an example of how I use it in an expect script. The first two lines are provided for context; the third line inserts the date 15 days ago.

expect "ODUE DATE" {send "w"}
expect "ODUE DATE between" {send "090606"}
expect "&" {send [findpastdate 15]}

Below is the definitions.tcl file that makes it work. I seem to remember that it has limitations--it doesn't take leap year into account so it will be a day off if the calculation involves Feb 29; also, it's not designed to change the year unless the current month is January, so daysago should be less than 31; there may be some other limitations. I would welcome any suggestions for cleaning up the code or otherwise improving this.

Phil

here is definitions.tcl ************************************************

# definitions of functions for other scripts to use
#
# proc findpastdate
# sets the date "daysago" days ago into $newday $newmonth $newyear
# written for daysago = 10; not designed to change the year unless
# current month is january, so daysago should be less than 31
#
proc findpastdate daysago {
# get the day month and year
set day [exec date +%d]
scan $day %d day
set month [exec date +%m]
scan $month %d month
set year [exec date +%y]
scan $year %d year
if {$day >= [expr $daysago +1]} {
set newday [expr $day - $daysago];
set newmonth $month;
set newyear $year;
} else {
if {$month == 1} {
set newday [expr 31 - $daysago + $day];
set newmonth 12;
set newyear [expr $year - 1];
} else {
set newmonth [expr $month - 1];
set newyear $year;
if {$newmonth == 2} {
# let's not worry about leap year
set newday [expr 28 - $daysago + $day];
} elseif {($month == 9)||($month == 4)||($month == 6)||($month == 11)}
{
set newday [expr 30 - $daysago + $day];
} else {
set newday [expr 31 - $daysago + $day];
}
}
}
# if anything is one digit, append a zero at the beginning
if [expr $newday < 10] {set newday 0$newday}
if [expr $newmonth < 10] {set newmonth 0$newmonth}
if [expr $newyear < 10] {set newyear 0$newyear}
set pastdate $newmonth$newday$newyear
return $pastdate
}

that was definitions.tcl ************************************************




Randy Norwood wrote:
I would like to create a featured list that would display recent
acquisitions within, say, the past 60 days. I can create a review file that
produces a result list that is valid as of today, but that would require
updating the review file every week or month to capture the subsequent
acquisitions. Or, alternatively, I could create a new review file for each
new month. What I would prefer to do is have a dynamic query that is always
valid and doesn't require continued intervention.
In the Create Lists "Boolean Search" window, I don't see how to specify a
date as a variable. You can type "t", but that's just a macro or shortcut
for today's date. It doesn't change.
Any other techniques to accomplish the same goal would be welcome.
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Randy Norwood
Sr Programmer Analyst
Texas Tech Law School Library
Office: 806-742-3990 x350
Support: 806-742-3990 x318, computersupport dot law at ttu dot edu
E-mail: randy dot norwood at ttu dot edu










--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
--
This message was distributed through the Innovative Users Group INNOPAC list
Public replies: INNOPAC at innopacusers dot org
Update your subscription options: http://innopacusers.org/mailman/listinfo/innopac

--

Phil Shirley
Technology Services Coordinator
Cuyahoga Falls Library
Cuyahoga Falls, Ohio
330-928-2117, ext. 109
pshirley at CuyahogaFallsLibrary dot org