Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!xanth!galaxia!amanpt1!mrr From: mrr@amanpt1.Newport.RI.US (Mark Rinfret) Newsgroups: alt.sources.amiga Subject: Date Requester, Part 1/5 Keywords: date, Intuition, ARexx, source Message-ID: <586@amanpt1.Newport.RI.US> Date: 11 Oct 89 23:19:43 GMT Organization: HyperView Systems Corp. Lines: 1505 This posting is in 5 parts and offers an Amiga date requester module for use in applications where it is appropriate/necessary to solicit dates from the user. Also included is a stand-alone application which can be driven by an ARexx macro. All components of the date can be set/retrieved by an ARexx macro script. See the "test" and "listsince" macro files for examples. Mark Rinfret, 10/11/89 ============================================================================ #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh MRDateReq.h <<'END_OF_MRDateReq.h' X/* MRDateReq.h - definitions of the date requester package. */ X X#ifndef _MRDATEREQ_H X#define _MRDATEREQ_H X#include X#include "MRDates.h" X X/* The following structure defines a packet used to interface with the X * MRDateRequest function. It is highly recommended that objects of this X * type be dynamically allocated using AllocMem() (or equivalent) to X * insure that the base address of the structure is longword-aligned. X * Also note that the pointer to a structure of this type is equivalent X * to a "struct DateTime *" since the first field in this structure is X * an embedded ARP DateTime structure. X */ Xtypedef struct { X /* The following fields are filled in by the caller: */ X struct DateTime ARPDatePacket; X char *prompt; X struct Window *window; X X /* The following fields are filled in by MRDateRequest: */ X struct Requester *requester; /* for local use only! */ X MRDate newDate; /* alternate format date */ X int status; /* result code */ X int myStrings; /* true => strings are mine */ X } MRDatePacket; X Xvoid FreeMRDatePacket(/* MRDatePacket *thePacket */); XMRDatePacket * CreateMRDatePacket(/* struct DateStamp *theDate, X int theFormat, int makeStrings */); Xint MRDateRequest(/* MRDatePacket *datePacket */); X X#endif END_OF_MRDateReq.h echo shar: Missing newline added to \"MRDateReq.h\" if test 1436 -ne `wc -c MRDateReq.pw.uue <<'END_OF_MRDateReq.pw.uue' X Xbegin 644 MRDateReq.pw XM4&]W97)7:6YD;W=S('8R+C5B(*DQ.3@W+"`Q.3@X(&)Y($E.3U9!5%)/3DE#T XM4RP@24Y#+B`@("`@("`@("`@("`@("`@("`@("`@```#[`````(@`8!L````% XM`0`````!``````]-4D1A=&5297$N<' XM=?P````````````;````&P`)````"0``````````````!4IA;@``````$``#J XM``$`*7:``"EVF``I=J@`*7:X`"EVT``I=N`````,;6]N=&A'861G970`````A XM`0`````!``````U-3TY42%]'041'150``````0`````!```I>.``;@`7`!L`# XM"```"`,`!``I=QP`````````````````*7=8````*7>(_____P````4`*7(@`*7B8`"EXJ``I>,``*7C0````"F1A>4=A9&=E=``````!````B XM``$`````"T1!65]'041'150``````0`````!```I>E``H``7`!L`"```"`,`/ XM!``I>0P``````"EY.```````*7F(````*7FX_____P````4`*7D<````````/ XM````'````!P`"0````D```````````(!`0#_[__W```````I>5@`````````L XM%2!(;W5R($UI;G5T92!396-O;F0@``````4P,``@`````!(```@!`"EYX``I, XM>?@`*7H(`"EZ&``I>C``*7I`````"VAO=7)'861G970``````0`````!````D XM``Q(3U527T=!1$=%5``````!``````$``"E[@`#1`!<`&P`(```(`P`$`"EZX XM?``````````````````I>K@````I>NC_____````!0`I>HP````````````S@`*7M(`"E[8``I>W`````-;6EN=71E1V%D9V5T``````$``````0`````.R XM34E.551%7T=!1$=%5``````!``````$``"E\L`$(`!<`&P`(```(`P`$`"E[J XMK``````````````````I>^@````I?!C_____````!0`I>[P````````````!]^Z XM'W^??]]_GWX?>!]@'P`?````"``!``$`*7U0`"E]:``I?7@`*7V(`"E]H``I4 XM?;`````-=7!996%R1V%D9V5T``````$``````0`````/55!?645!4E]'041'T XM150``````0`````!```I?S@`&0`?``L`"P`%``,``0`I?<``````````````X XM````````````*7X(_____P$!``4`*7[,````````````#`````P`#`````P`5 XM```````````+``L``@``J^@"```````````6`!\`WP/?#]\_WW_?/]\/WP/?[ XM`-\`'P````@``0`!`"E]X``I?C``*7[H`"E^^``I?Q@`*7\H````#V1O=VY9# XM96%R1V%D9V5T``````$``````0`````11$]73E]914%27T=!1$=%5``````!K XM``````$``"F`2`!.`!\`"P`+``4``P`!`"E_D```````````````````````V XM```I?[#_____`0``!0`I?W0````````````,````#``,````#```````````F XM``L`"P`"``$U^`(``````````!8`'V`?>!]^'W^??]]_GWX?>!]@'P`?````< XM"``!``$`*7_8`"E_\``I@```*8`0`"F`*``I@#@````.=7!-;VYT:$=A9&=E' XM=``````!``````$`````$%507TU/3E1(7T=!1$=%5``````!``````$``"F!' XM8`!"`!\`"P`+``4``P`!`"F`H``````````````````````````I@,#_____. XM`0``!0`I@(0````````````,````#``,````#`````````````L`"P`"``$VR XM&`(``````````!8`'P#?`]\/WS_??]\_WP_?`]\`WP`?````"``!``$`*8#H! XM`"F!```I@1``*8$@`"F!0``I@5`````09&]W;DUO;G1H1V%D9V5T``````$`M XM`````0`````21$]73E]-3TY42%]'041'150``````0`````!```IA&``=P`?@ XM``L`"P`%``,``0`I@;@`````````````````````````*8'8_____P$```4`% XM*8&<````````````#`````P`#`````P````````````+``L``@`!-C@"````_ XM```````6`!]@'W@??A]_GW_??Y]^'W@?8!\`'P````@``0`!`"F"```I@A@`, XM*8(H`"F".``I@E``*8)@````#'5P1&%Y1V%D9V5T``````$``````0`````.G XM55!?1$%97T=!1$=%5``````!``````$``"F%*`"I`!\`"P`+``4``P`!`"F"7 XM<``````````````````````````I@I#_____`0``!0`IA)P````````````," XM````#``,````#`````````````L`"P`"``$V6`(``````````!8`'V`?>!]^6 XM'W^??]]_GWX?>!]@'P`?````"``!``$`*82X`"F$T``IA.``*83P`"F%"``I` XMA1@````-=7!(;W5R1V%D9V5T``````$``````0`````/55!?2$]54E]'041'^ XM150``````0`````!```IAD``V@`?``L`"P`%``,``0`IA8``````````````0 XM````````````*86@_____P$```4`*85D````````````#`````P`#`````P`2 XM```````````+``L``@`!-G@"```````````6`!]@'W@??A]_GW_??Y]^'W@?_ XM8!\`'P````@``0`!`"F%R``IA>``*87P`"F&```IAB``*88P````#W5P36EN_ XM=71E1V%D9V5T``````$``````0`````155!?34E.551%7T=!1$=%5``````!/ XM``````$``"F'6`$1`!\`"P`+``4``P`!`"F&F```````````````````````@ XM```IAKC_____`0``!0`IAGP````````````,````#``,````#```````````$ XM``L`"P`"``$W$`(``````````!8`'V`?>!]^'W^??]]_GWX?>!]@'P`?````V XM"``!``$`*8;@`"F&^``IAP@`*8<8`"F'.``IAT@````/=7!396-O;F1'861GC XM970``````0`````!`````!%54%]314-/3D1?1T%$1T54``````$``````0``Y XM*8C``&L`'P`+``L`!0`#``$`*8>P`````````````````````````"F'T/__X XM__\!```%`"F'E`````````````P````,``P````,````````````"P`+``(`0 XM`3?``@``````````%@`?`-\#WP_?/]]_WS_?#]\#WP#?`!\````(``$``0`IY XMA_@`*8@0`"F((``IB#``*8A(`"F(6`````YD;W=N1&%Y1V%D9V5T``````$`E XM`````0`````01$]73E]$05E?1T%$1T54``````$``````0``*8GH`)T`'P`+T XM``L`!0`#``$`*8AH`````````````````````````"F(B/____\!```%`"F(9 XM_`````````````P````,``P````,````````````"P`+``(``3B@`@``````? XM````%@`?`-\#WP_?/]]_WS_?#]\#WP#?`!\````(``$``0`IB1@`*8DP`"F)T XM0``IB5``*8EP`"F)@`````]D;W=N2&]U0```'D`"0````D```````````(!`0#_S@`````````J8 XM(\@`````````!R!4:6UE(``````+`"`@("`@("`@(``````0``,````J)$@`5 XM*B1@`"HD<``J)(``*B28`"HDJ`````MT:6UE1V%D9V5T``````$``````0``> XM```,5$E-15]'041'150``````0`````!```J)>``"@!L`$``"``!``,``0`JD XM).0``````"HE$```````````````*B5(_____P,```4`*B3T````````````$ XM00```$$`"0````D```````````(!`0`````````````J)3``````````"2!## XM04Y#14P@``````@``0`'`"HE<``J)8@`*B68`"HEJ``J)<``*B70````#6-A& XM;F-E;$=A9&=E=``````!``````$`````#D-!3D-%3%]'041'150``````0``P XM```!```J)T@`@@!@`%``"``#``,`!``J)@P``````"HF.```````*B:`````2 XM*B:P_____P````4`*B8<````````````40```%$`"0````D```````````(!D XM`0#_U@`````````J)E@`````````!B!$87D@``````L`("`@("`@("`@````- XM`!```P```"HFV``J)O``*B<``"HG$``J)R@`*B4YA;65'861GO XM970``````0`````!``````]$05E.04U%7T=!1$=%5``````!``````$``"HH( XM>``9`#@`0``(``$``P`!`"HG=```````*B>@```````````````J)]C_____Q XM`P``!0`J)X0```````````!!````00`)````"0```````````@$!````````U XM`````"HGP``````````)("T@5T5%2R``````"``!``,`*B@``"HH&``J*"@`5 XM*B@X`"HH6``J*&@````0=V5E:TUI;G5S1V%D9V5T``````$``````0`````26 XM5T5%2U]-24Y54U]'041'150``````0`````!```J*:@`<0`X`$``"``!``,`4 XM`0`J**0``````"HHT```````````````*BD(_____P,```4`*BBT````````^ XM````00```$$`"0````D```````````(!`0`````````````J*/``````````: XM"2`K(%=%14L@``````@``0`#`"HI,``J*4@`*BE8`"HI:``J*8@`*BF8````6 XM#W=E96M0;'5S1V%D9V5T``````$``````0`````15T5%2U]03%537T=!1$=%$ XM5``````!``````$``"HK```+`"T!(P`)`````P`$`"HIU```````````````^ XM```J*C@````J*FC_____````!0`J*>0```````````$D```!)``*````"@``> XM````````````*5-E;&5C="!T:&4@9&%T92!A;F0@9&%T92!F;W)M870Z`"`@< XM(`#+G(0`````"@``````*BJ0`"HJJ``J*K@`*BK(`"HJX``J*O`````-<')OS XM;7!T1V%D9V5T``````$``````0`````.4%)/35!47T=!1$=%5``````!````; XM``$````````!``$!-@!Z``,``P`!`"HK+`````````````````````#__P`JD XM*UC_____`0``!0`J*SP```````````$W```!-P![````>P``````````````\ XM"0`#``$`*6'@`"EA^``I8D@`*6(H`"EB"``I8C@````+;6%I;D)OMRDates.h <<'END_OF_MRDates.h' X/* MRDates.h - Declarations for types and variables used by MRDates. */ X X#ifndef _MRDATES_H X#define _MRDATES_H Xtypedef struct { X int Dyear; /* year AD (e.g. 1987) */ X int Dmonth; /* month of year (0-11) */ X int Dday; /* day in month (1-31) */ X int Dhour; /* 0-23 */ X int Dminute; /* 0-59 */ X int Dsecond; /* 0-59 */ X int Dweekday; /* day of week (Sun=0) */ X} MRDate; X Xtypedef struct { X char *Mname; X int Mdays; X } CalEntry; X X#ifdef MRDATES XCalEntry calendar[12] = { X { "Jan", 31 }, { "Feb", 28 }, { "Mar", 31 }, { "Apr", 30 }, X { "May", 31 }, { "Jun", 30 }, { "Jul", 31 }, { "Aug", 31 }, X { "Sep", 30 }, { "Oct", 31 }, { "Nov", 30 }, { "Dec", 31 } X }; X#else Xextern CalEntry calendar[12]; X#endif X X#ifdef MRDATES Xchar *dayNames[7] = { X "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" X }; X#else Xextern char *dayNames[7]; X#endif X X#endif END_OF_MRDates.h echo shar: Missing newline added to \"MRDates.h\" if test 965 -ne `wc -c MRGadgets.c <<'END_OF_MRGadgets.c' X/* MRGadgets - Miscellaneous gadget support routines. X * Author: Mark R. Rinfret X * Date: 09/02/89 X * X * This package contains a set of routines which assist in the use and X * management of gadgets. Many of these were developed while writing X * MRBackup. X * X * Note that an attempt was made to maintain consistency in the order X * that parameters are passed. For most routines, the parameter list X * will begin with X * (gadget, window, requester, ...) X * followed by any additional required parameters. X */ X X#include X#include "Strings.h" X#include "MRGadgets.h" X X/* FUNCTION X EraseGadgetBox - clear the area inside a gadget's border. X X SYNOPSIS X void EraseGadgetBox(gadget, window, requester) X struct Gadget *gadget; X struct Window *window; X struct Requester *requester; X X DESCRIPTION X EraseGadgetBox must be called with a gadget for which a border X has been defined. It erases the area contained by the border. X This routine supports other routines, such as SetOptionGadget. X If is non-null, the 's RastPort is used. X Otherwise, the 's rastport is used. X X*/ X Xvoid XEraseGadgetBox(gadget, window, requester) X struct Gadget *gadget; X struct Window *window; X struct Requester *requester; X{ X struct RastPort *rp; X ULONG savePen; X ULONG xmin,ymin,xmax,ymax ; X X rp = SelectRastPort(window, requester); X xmin = gadget->LeftEdge; X xmax = xmin + gadget->Width; X ymin = gadget->TopEdge; X ymax = ymin + gadget->Height; X savePen = rp->FgPen; X SetAPen(rp, 0L); X SetDrMd(rp, JAM1); X RectFill(rp, xmin, ymin, xmax, ymax); X SetAPen(rp, savePen); X} X/* FUNCTION X GetGadget - get gadget pointer, given gadget ID. X X SYNOPSIS X struct Gadget *GetGadget(id, window) X int id; X struct Window *window; X X DESCRIPTION X GetGadget attempts to locate a non-system gadget in X that has the specified . If found, a pointer to the gadget X is found. Otherwise, NULL is returned. X*/ Xstruct Gadget * XGetGadget(id, window) X int id; X struct Window *window; X{ X struct Gadget *testGadget; X X for (testGadget = window->FirstGadget; testGadget; X testGadget = testGadget->NextGadget) { X /* All system gadget types have high bit set (I think...). */ X if ( testGadget->GadgetType & 0x8000 ) X continue; X if ( testGadget->GadgetID == id ) X break; X } X return testGadget; X} X X/* FUNCTION X ResetStringInfo - reset information in a StringInfo structure. X X SYNOPSIS X void ResetStringInfo(s) X struct StringInfo *s; X X DESCRIPTION X ResetStringInfo resets certain parameters in the StringInfo X structure pointed to by , including: X X UndoBuffer X DispPos X UndoPos X NumChars X*/ Xvoid XResetStringInfo(s) X struct StringInfo *s; X{ X *(s->UndoBuffer) = '\0'; X s->BufferPos = 0; X s->DispPos = 0; X s->UndoPos = 0; X s->NumChars = strlen(s->Buffer); X} X X/* Indicate that a gadget is selected by turning on its highlight X * and SELECTED flags. X * Called with: X * gadget: pointer to gadget structure X * window: pointer to window containing gadget X * state X */ X/* FUNCTION X SelectGadget - set a gadget to the SELECTED or !SELECTED state. X X SYNOPSIS X void SelectGadget(gadget, window, requester, state) X struct Gadget *gadget; X struct Window *window; X struct Requester *requester; X BOOL state; X X DESCRIPTION X SelectGadget removes the from the gadget list, X sets or clears the SELECTED bit according to , then adds X the gadget back to the gadget list and refreshes list. If the X gadget belongs to a requester, then must be supplied. X Otherwise, it must be NULL. X*/ Xvoid XSelectGadget(gadget, window, requester, state) X struct Gadget *gadget; X struct Window *window; X struct Requester *requester; X BOOL state; X{ X long position; X X position = RemoveGadget(window, gadget); X if (state) X gadget->Flags |= SELECTED; X else X gadget->Flags &= ~SELECTED; X AddGadget(window, gadget, position); X RefreshGList(gadget, window, NULL, 1L); X} X X X/* FUNCTION X SetOptionGadget - set string value for multi-option gadget. X X SYNOPSIS X void SetOptionGadget(gadget, window, requester, option) X struct Gadget *gadget; X struct Window *window; X struct Requester *requester; X char *option; X X DESCRIPTION X SetOptionGadget sets the text string of the -last- IntuiText entry X of the to the string value in