REM Description: Automatic templates REM Filename: template.wmc REM Created by: Steven Wylie - 11/08/93 REM Modified by: Mark P. Fishman - 1998-09-02 to use Zeller's congruence for day calculation DECLARE SUB GoToPageFrame() DECLARE SUB ReplaceAll(parm1$, parm2$, page%) DECLARE SUB GetUserInfo(initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$) DECLARE SUB WriteUserInfo(initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$) DECLARE FUNCTION Weekday%(month%, day%, year%, days%) DECLARE FUNCTION GetPrivateProfileString LIB "kernel" (lpApplicationName AS STRING, lpKeyName AS STRING, lpDefault AS STRING, lpReturnedString AS STRING, nSize As WORD, lpFileName AS STRING) As Integer ' We have two arrays: one uses long names for the templates, the other uses the actual file names. CONST MAXTMPL% = 20 DIM templates$(MAXTMPL%), templname$(MAXTMPL%), months$(12) ' Symbolic names for template indexes CONST BRDRART1% = 1 CONST BRDRART2% = 2 CONST BRDRART3% = 3 CONST BRDRART4% = 4 CONST BROCHUR% = 5 CONST CARD% = 6 CONST CAL% = 7 CONST CERT% = 8 CONST CLIPART% = 9 CONST DEFAULT% = 10 CONST ENV% = 11 CONST FAX% = 12 CONST FLY% = 13 CONST LTR% = 14 CONST MEMO% = 15 CONST NEWS% = 16 CONST OVERHD% = 17 CONST REP% = 18 CONST RES% = 19 ' Fill the two arrays. templates$( BRDRART1% ) = "Border 1 (Square corners, flower)" templates$( BRDRART2% ) = "Border 2 (Square corners, weave)" templates$( BRDRART3% ) = "Border 3 (Square corners, classical)" templates$( BRDRART4% ) = "Border 4 (Rounded corners, laurel)" templates$( BROCHUR% ) = "Brochure (Three-fold, two-sided)" templates$( CARD% ) = "Business Card (8-up, vertical)" templates$( CAL% ) = "Calendar (Day, Week, and Month)" templates$( CERT% ) = "Certificate" templates$( CLIPART% ) = "Clip Art" templates$( DEFAULT% ) = "Default Template" templates$( ENV% ) = "Envelope (No. 10 with return address)" templates$( FAX% ) = "Fax Cover" templates$( FLY% ) = "Flyer (Announcement with coupon)" templates$( LTR% ) = "Letterhead" templates$( MEMO% ) = "Memo" templates$( NEWS% ) = "Newsletter" templates$( OVERHD% ) = "Overhead (Landscape)" templates$( REP% ) = "Report (with Numbered Headings)" templates$( RES% ) = "Résumé" templates$( MAXTMPL% ) = "Other..." templname$( BRDRART1% ) = "brdrart1.wst" templname$( BRDRART2% ) = "brdrart2.wst" templname$( BRDRART3% ) = "brdrart3.wst" templname$( BRDRART4% ) = "brdrart4.wst" templname$( BROCHUR% ) = "brochur.wst" templname$( CARD% ) = "card.wst" templname$( CAL% ) = "cal.wst" templname$( CERT% ) = "cert.wst" templname$( CLIPART% ) = "clipart.wst" templname$( DEFAULT% ) = "default.wst" templname$( ENV% ) = "env.wst" templname$( FAX% ) = "fax.wst" templname$( FLY% ) = "fly.wst" templname$( LTR% ) = "ltr.wst" templname$( MEMO% ) = "memo.wst" templname$( NEWS% ) = "news.wst" templname$( OVERHD% ) = "overhd.wst" templname$( REP% ) = "rep.wst" templname$( RES% ) = "res.wst" months$(1) = "January" months$(2) = "February" months$(3) = "March" months$(4) = "April" months$(5) = "May" months$(6) = "June" months$(7) = "July" months$(8) = "August" months$(9) = "September" months$(10) = "October" months$(11) = "November" months$(12) = "December" new% = 0 index% = DEFAULT% 'Number of default template iniFile$ = "wsw.ini" ' If text is selected, save it in case we need it in the template. sel$ = GetSelection$() GetTemplate: BEGIN DIALOG templateDialog 204, 182, "Templates" TEXT 4, 4, 120, 8, "Choose a &Template:" LISTBOX 4, 14, 150, 140, templates$, index% OPTIONGROUP new% OPTIONBUTTON 4, 158, 150, 10, "Open &Copy of Template" OPTIONBUTTON 4, 168, 150, 10, "Open &Original Template" OKBUTTON 160, 4, 40, 14 CANCELBUTTON 160, 20, 40, 14 END DIALOG ' Show the templates that are available and ask the user to pick one. ret% = DIALOG(templateDialog) IF ret% = 2 THEN STOP ' Get the default template directory. ret% = W2I(GetPrivateProfileString("Preferences", "TemplateDirectory", "", dir$, I2W(255), iniFile$)) IF ret% <> 0 THEN IF RIGHT$(dir$, 1) <> "\" THEN dir$ = dir$ + "\" ENDIF ' Construct the filename based on the user's choice. fileName$ = dir$ + templname$(index%) ' If "Other template" is chosen, then clear out the filename so we display the common dialog. IF index% = MAXTMPL% THEN fileName$ = "" ELSE ' Make sure the file exists before trying to open it: IF Access(fileName$, 0) <> 1 THEN cr$ = CHR$(13) + CHR$(13) msg$ = fileName$ + cr$ + "This file does not exist." + cr$ + "Make sure your default template directory in Preferences is correct, or reinstall WSWin." ret% = MESSAGEBOX(fileName$ + cr$ + msg$, "Template Error", 0 + 16) GOTO GetTemplate ENDIF ENDIF ' Either open the original template or a copy of it, depending on the user's choice. IF new% = 0 THEN FileNew fileName$ ELSE FileOpen fileName$ ENDIF ' Let's remember the filename in case the user closes the document. fileName$ = GetDocName$() ' Use the long name for the template as the heading for the dialog. ' Note: we must have a value for the variable before the dialog definition ' in order for it to display. key$ = templates$(index%) ' These are all the dialogs that get used. BEGIN DIALOG Letter 220, 170, key$ TEXT 4, 6, 52, 8, "Logo &Initial:" TEXTBOX 62, 4, 12, 12, initial$ TEXT 4, 22, 52, 8, "&Name:" TEXTBOX 62, 20, 100, 12, name$ TEXT 4, 38, 52, 8, "C&ompany:" TEXTBOX 62, 36, 100, 12, company$ TEXT 4, 52, 52, 8, "&Address:" TEXTBOX 62, 50, 100, 12, address$ TEXT 4, 68, 52, 8, "&City:" TEXTBOX 62, 66, 100, 12, city$ TEXT 4, 84, 52, 8, "&State/Province:" TEXTBOX 62, 82, 100, 12, state$ TEXT 4, 100, 52, 8, "&Zip/Postal Code:" TEXTBOX 62, 98, 100, 12, zip$ TEXT 4, 116, 52, 8, "&Phone:" TEXTBOX 62, 114, 100, 12, phone$ TEXT 4, 132, 52, 8, "&Fax:" TEXTBOX 62, 130, 100, 12, fax$ CHECKBOX 4, 146, 60, 10, "Sa&ve", save% OKBUTTON 172, 4, 40, 14 CANCELBUTTON 172, 20, 40, 14 END DIALOG BEGIN DIALOG Envelope 221, 170, key$ TEXT 4, 4, 94, 8, "Return Address Information:" TEXT 4, 16, 56, 8, "Logo &Initial:" TEXTBOX 65, 14, 12, 12, initial$ TEXT 4, 32, 56, 8, "&Name:" TEXTBOX 65, 30, 100, 12, name$ TEXT 4, 48, 56, 8, "C&ompany:" TEXTBOX 65, 46, 100, 12, company$ TEXT 4, 64, 56, 8, "&Address:" TEXTBOX 65, 62, 100, 12, address$ TEXT 4, 80, 56, 8, "&City:" TEXTBOX 65, 78, 100, 12, city$ TEXT 4, 96, 56, 8, "&State/Province:" TEXTBOX 65, 94, 100, 12, state$ TEXT 4, 112, 56, 8, "&Zip/Postal Code:" TEXTBOX 65, 110, 100, 12, zip$ CHECKBOX 4, 128, 60, 10, "Sa&ve", save% TEXT 4, 142, 160, 24, "If you select text before choosing this command, that text will be used for the addressee on the envelope." OKBUTTON 172, 4, 40, 14 CANCELBUTTON 172, 20, 40, 14 END DIALOG BEGIN DIALOG Resume 218, 114, key$ TEXT 4, 6, 56, 8, "&Name:" TEXTBOX 64, 4, 100, 12, name$ TEXT 4, 22, 56, 8, "&Address:" TEXTBOX 64, 20, 100, 12, address$ TEXT 4, 38, 56, 8, "&City:" TEXTBOX 64, 36, 100, 12, city$ TEXT 4, 54, 56, 8, "&State/Province:" TEXTBOX 64, 52, 100, 12, state$ TEXT 4, 70, 56, 8, "&Zip/Postal Code:" TEXTBOX 64, 68, 100, 12, zip$ TEXT 4, 86, 56, 8, "&Phone:" TEXTBOX 64, 84, 100, 12, phone$ CHECKBOX 4, 100, 60, 10, "Sa&ve", save% OKBUTTON 171, 4, 40, 14 CANCELBUTTON 171, 20, 40, 14 END DIALOG BEGIN DIALOG Memo 204, 52, key$ TEXT 4, 6, 40, 8, "&From:" TEXTBOX 50, 4, 100, 12, name$ TEXT 4, 22, 40, 8, "&To:" TEXTBOX 50, 20, 100, 12, to$ TEXT 4, 38, 40, 8, "&Subject:" TEXTBOX 50, 36, 100, 12, subject$ CHECKBOX 4, 100, 60, 10, "Sa&ve", save% OKBUTTON 160, 4, 40, 14 CANCELBUTTON 160, 20, 40, 14 END DIALOG BEGIN DIALOG Fax 212, 212, key$ GROUPBOX 4, 4, 158, 76, "From:" TEXT 8, 15, 40, 8, "&Name:" TEXTBOX 54, 13, 100, 12, fromName$ TEXT 8, 31, 40, 8, "&Company:" TEXTBOX 54, 29, 100, 12, company$ TEXT 8, 47, 40, 8, "&Phone:" TEXTBOX 54, 45, 100, 12, fromPhone$ TEXT 8, 63, 40, 8, "&Fax:" TEXTBOX 54, 61, 100, 12, fromFax$ GROUPBOX 4, 83, 158, 76, "To:" TEXT 8, 94, 40, 8, "N&ame:" TEXTBOX 54, 92, 100, 12, toName$ TEXT 8, 110, 40, 8, "C&ompany:" TEXTBOX 54, 108, 100, 12, toCompany$ TEXT 8, 126, 40, 8, "P&hone:" TEXTBOX 54, 124, 100, 12, toPhone$ TEXT 8, 142, 40, 8, "Fa&x:" TEXTBOX 54, 140, 100, 12, toFax$ TEXT 8, 166, 40, 8, "&Subject:" TEXTBOX 54, 164, 154, 12, subject$ TEXT 8, 182, 40, 8, "Pag&es:" TEXTBOX 54, 180, 154, 12, pages$ CHECKBOX 4, 198, 60, 10, "Sa&ve", save% OKBUTTON 168, 4, 40, 14 CANCELBUTTON 168, 20, 40, 14 END DIALOG BEGIN DIALOG Certificate 204, 66, key$ TEXT 4, 6, 40, 8, "&Name:" TEXTBOX 50, 4, 100, 12, name$ TEXT 4, 22, 40, 8, "&Title/Award:" TEXTBOX 50, 20, 100, 12, title$ OPTIONGROUP award% OPTIONBUTTON 4, 42, 60, 10, "Titl&e" OPTIONBUTTON 4, 52, 60, 10, "&Award" OKBUTTON 160, 4, 40, 14 CANCELBUTTON 160, 20, 40, 14 END DIALOG BEGIN DIALOG Calendar 114, 40, key$ TEXT 4, 4, 60, 16, "&Enter a date (MM/DD/YY):" TEXTBOX 4, 22, 60, 12, currDate$ OKBUTTON 70, 4, 40, 14 CANCELBUTTON 70, 20, 40, 14 END DIALOG ' All saved information for the templates goes into one place in the wsw.ini file. section$ = "Templates" save% = 1 ' Some templates will have additional processing, for "automatic" templates. Use the ' user's choice to figure out what to do next. SELECT CASE index% CASE CAL% ' Calendar currDate$ = DATE$ DO valid% = 0 ret% = DIALOG(Calendar) IF ret% = 2 THEN STOP month% = VAL(LEFT$(currDate$, INSTR(currDate$, "/")-1)) currDate$ = MID$(currDate$, INSTR(currDate$, "/")+1) day% = VAL(LEFT$(currDate$, INSTR(currDate$, "/")-1)) currDate$ = MID$(currDate$, INSTR(currDate$, "/")+1) year% = VAL(currDate$) IF year% < 80 THEN year% = year% + 2000 ELSEIF year% < 100 THEN year% = year% + 1900 ENDIF IF (month% >= 1) AND (month% <= 12) THEN valid% = 1 ' We won't worry about validating the day, because it can be greater than the days in the month. LOOP UNTIL valid% = 1 ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP dayOfWeek% = Weekday%(month%, day%, year%, days%) ' First time, the month, day, and year get fixed to the actual date, so that if ' the user enters 3/99/93, the routine converts the date to June ' Call it again to get the first day of the month dayOfWeek% = Weekday%(month%, 1, year%, days%) ' The third page is the monthly calendar EditGoto 0, 3, , ' Now put in the days of the month into the monthly calendar freeze% = ViewFreezeScreen(1) StartOfStory EndOfLine 1 TypeText months$(month%) + " " 'IF year% < 80 THEN ' TypeText "20" 'ELSE ' TypeText "19" 'ENDIF TypeText STR$(year%) freeze% = ViewFreezeScreen(0) ' Go to the table frame on the page and go to the next row of cells ChildFrame LineDown 1, freeze% = ViewFreezeScreen(1) ' Go to the cell for the first day of the month FOR i% = 0 to dayOfWeek%-1 Tab NEXT i% ' Put in the days of the month in the correct places FOR i% = 1 to days% TypeText STR$(i%) Tab NEXT i% freeze% = ViewFreezeScreen(0) GoToPageFrame CASE CERT% ' Certificate ' The certificate will save its own information, but get the defaults from the basic user info first. GetUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ ' Now get any saved info from the last certificate that was done. ret% = W2I(GetPrivateProfileString(section$, key$, "", defaults$, I2W(255), iniFile$)) IF defaults$ <> "" THEN name$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) title$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) award% = VAL(defaults$) ENDIF ' Now get the info from the user, showing the defaults from the wsw.ini file. ret% = DIALOG(Certificate) IF ret% = 2 THEN STOP ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP freeze% = ViewFreezeScreen(1) ' Now replace the placeholders with the user's text. ReplaceAll "[Name]", name$, 1 IF award% THEN ReplaceAll " the title of", "", 1 ReplaceAll "[Title]", title$, 1 IF INSTR(name$, " and ") THEN ReplaceAll "has been", "have been", 1 defaults$ = name$ + ";" + title$ + ";" + STR$(award%) ' Save the info into the wsw.ini file. ret% = WritePrivateProfileString(section$, key$, defaults$, iniFile$) freeze% = ViewFreezeScreen(0) CASE ENV% ' Envelope ' Get the user information for the dialog box. GetUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ ' Allow the user to change the defaults in the dialog. ret% = DIALOG(Envelope) IF ret% = 2 THEN STOP ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP initial$ = LEFT$(initial$, 1) freeze% = ViewFreezeScreen(1) ReplaceAll "[I]", initial$, 1 From$ = name$ IF company$ <> "" THEN From$ = From$ + "" + company$ From$ = From$ + "" + address$ From$ = From$ + "" + city$ + ", " + state$ + " " + zip$ ReplaceAll "[From]", From$, 1 IF sel$ <> "" THEN ReplaceAll "[To]", sel$, 1 IF save% THEN WriteUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ freeze% = ViewFreezeScreen(0) EndOfStory CASE FAX% ' Fax Cover GetUserInfo initial$, fromName$, company$, address$, city$, state$, zip$, fromPhone$, fromFax$ ret% = W2I(GetPrivateProfileString(section$, key$, "", defaults$, I2W(255), iniFile$)) IF defaults$ <> "" THEN fromName$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) company$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) fromPhone$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) fromFax$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) toName$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) toCompany$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) toPhone$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) toFax$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) subject$ = defaults$ ENDIF ret% = DIALOG(Fax) IF ret% = 2 THEN STOP ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP freeze% = ViewFreezeScreen(1) ReplaceAll "[To]", toName$, 1 ReplaceAll "[ToCompany]", toCompany$, 1 ReplaceAll "[ToFax]", toFax$, 1 ReplaceAll "[ToPhone]", toPhone$, 1 ReplaceAll "[From]", fromName$, 1 ReplaceAll "[Company]", company$, 1 ReplaceAll "[FromFax]", fromFax$, 1 ReplaceAll "[FromPhone]", fromPhone$, 1 ReplaceAll "[Subject]", subject$, 1 ReplaceAll "[Pages]", pages$, 1 freeze% = ViewFreezeScreen(0) GoToPageFrame EndOfStory defaults$ = fromName$ + ";" + company$ + ";" + fromPhone$ + ";" + fromFax$ + ";" defaults$ = defaults$ + toName$ + ";" + toCompany$ + ";" + toPhone$ + ";" + toFax$ + ";" + subject$ IF save% THEN ret% = WritePrivateProfileString(section$, key$, defaults$, iniFile$) CASE CARD%, LTR% ' Business Card or Letterhead GetUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ ret% = DIALOG(Letter) IF ret% = 2 THEN STOP initial$ = LEFT$(initial$, 1) IF fax$ <> "" THEN fax2$ = "Fax " + fax$ ELSE fax2$ = "" ENDIF ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP freeze% = ViewFreezeScreen(1) ReplaceAll "[I]", initial$, 1 GoToPageFrame ReplaceAll "[Name]", name$, 1 ReplaceAll "[Company]", company$, 1 ReplaceAll "[Address]", address$, 1 ReplaceAll "[City]", city$, 1 ReplaceAll "[State]", state$, 1 ReplaceAll "[Zip]", zip$, 1 ReplaceAll "[Phone]", phone$, 1 ReplaceAll "[Fax]", fax2$, 1 freeze% = ViewFreezeScreen(0) IF save% THEN WriteUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ GoToPageFrame EndOfStory CASE MEMO% ' Memo GetUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ ret% = GetPrivateProfileString(section$, key$, "", defaults$, I2W(255), iniFile$) IF defaults$ <> "" THEN name$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) to$ = LEFT$(defaults$, INSTR(defaults$, ";")-1) defaults$ = MID$(defaults$, INSTR(defaults$, ";")+1) subject$ = defaults$ ENDIF ret% = DIALOG(Memo) IF ret% = 2 THEN STOP ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP freeze% = ViewFreezeScreen(1) ReplaceAll "[To]", to$, 1 ReplaceAll "[From]", name$, 1 ReplaceAll "[Subject]", subject$, 1 freeze% = ViewFreezeScreen(0) GoToPageFrame EndOfStory defaults$ = name$ + ";" + to$ + ";" + subject$ IF save% THEN ret% = WritePrivateProfileString(section$, key$, defaults$, iniFile$) CASE RES% ' Rèsumè GetUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ ret% = DIALOG(Resume) IF ret% = 2 THEN STOP ' Check to make sure that we're still in the same document window. IF GetDocName$() <> fileName$ THEN STOP freeze% = ViewFreezeScreen(1) ReplaceAll "[Name]", name$, 1 ReplaceAll "[Address]", address$, 1 ReplaceAll "[City]", city$, 1 ReplaceAll "[State]", state$, 1 ReplaceAll "[Zip]", zip$, 1 ReplaceAll "[Phone]", phone$, 1 IF save% THEN WriteUserInfo initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$ freeze% = ViewFreezeScreen(0) ChildFrame Tab StartOfLine EndOfLine 1 CASE ELSE ' If a different template was opened, don't do anything. END SELECT ViewRedrawWindow ' This is the end of the
section of the macro. ' This routine goes to the page frame of the current page. SUB GoToPageFrame type% = GetTextFrameType() WHILE type% <> 1 AND type% <> 2 ParentFrame type% = GetTextFrameType() WEND END SUB ' This routine replaces all occurrences in all frames of one string for another. SUB ReplaceAll(parm1$, parm2$, page%) ret% = EditReplace(parm1$, parm2$, , page%, , , , 0, 0, 0) GoToPageFrame END SUB ' This routine gets specific user information from the wsw.ini file. SUB GetUserInfo(initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$) iniFile$ = "wsw.ini" sec$ = "Templates" ' Get defaults from the WSWin section of the wsw.ini file first. ret% = GetPrivateProfileString("WSWin", "UserName", name$, name$, 255, iniFile$) ret% = GetPrivateProfileString("WSWin", "Company", company$, company$, 255, iniFile$) ' Now see if there are entries in the Templates section. ret% = GetPrivateProfileString(sec$, "Initial", initial$, initial$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Name", name$, name$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Company", company$, company$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Address", address$, address$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "City", city$, city$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "State", state$, state$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Zip", zip$, zip$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Phone", phone$, phone$, 255, iniFile$) ret% = GetPrivateProfileString(sec$, "Fax", fax$, fax$, 255, iniFile$) END SUB ' This routine writes specific user information to the wsw.ini file. SUB WriteUserInfo(initial$, name$, company$, address$, city$, state$, zip$, phone$, fax$) iniFile$ = "wsw.ini" sec$ = "Templates" ret% = WritePrivateProfileString(sec$, "Initial", initial$, iniFile$) ret% = WritePrivateProfileString(sec$, "Name", name$, iniFile$) ret% = WritePrivateProfileString(sec$, "Company", company$, iniFile$) ret% = WritePrivateProfileString(sec$, "Address", address$, iniFile$) ret% = WritePrivateProfileString(sec$, "City", city$, iniFile$) ret% = WritePrivateProfileString(sec$, "State", state$, iniFile$) ret% = WritePrivateProfileString(sec$, "Zip", zip$, iniFile$) ret% = WritePrivateProfileString(sec$, "Phone", phone$, iniFile$) ret% = WritePrivateProfileString(sec$, "Fax", fax$, iniFile$) END SUB ' This function calculates the day of the week for a given date. It also returns the number ' of days in the given month in the last parameter. FUNCTION Weekday%(month%, day%, year%, days%) DIM daysInMonth%(14) ' save entry values entryDay% = day% entryMonth% = month% entryYear% = year% entryCentury% = 0 daysInMonth%(1) = 31 daysInMonth%(2) = 28 daysInMonth%(3) = 31 daysInMonth%(4) = 30 daysInMonth%(5) = 31 daysInMonth%(6) = 30 daysInMonth%(7) = 31 daysInMonth%(8) = 31 daysInMonth%(9) = 30 daysInMonth%(10) = 31 daysInMonth%(11) = 30 daysInMonth%(12) = 31 daysInMonth%(13) = 31 daysInMonth%(14) = 28 ' January 1, 1980 is day one - it was a Tuesday ' If Sunday is 0, then Tuesday is 2. numDays% = 1 ' Take care of 4-digit years century% = year% \ 100 year% = year% MOD 100 ' Take care of leap years IF (century% MOD 4 = 0) AND (year% = 0) THEN daysInMonth%(2) = 29 IF (century% MOD 4 > 0) THEN IF (year% > 0) AND (year% MOD 4 = 0) THEN daysInMonth%(2) = 29 END IF daysInMonth%(14) = daysInMonth%(2) ' Fix up the month, day, and year so that it is a real date. WHILE day% > daysInMonth%(month%) day% = day% - daysInMonth%(month%) ' next two lines not needed for Zeller's congruence ' Don't forget leap days 'IF (month% = 2) AND (year% MOD 4 = 0) THEN day% = day% - 1 month% = month% + 1 IF month% > 12 THEN month% = month% - 12 year% = year% + 1 END IF WEND ' Begin Zeller's congruence ' Jan and Feb are months 13 and 14 of previous year IF month% < 3 THEN month% = month% + 12 IF year% = 00 THEN century% = century% - 1 year% = 99 ELSE year% = year% - 1 END IF END IF Zmonth% = ((month% + 1) * 26) \ 10 Zyear% = year% \ 4 Zcentury% = century% \ 4 wkdaynum% = day% + Zmonth% + year% + Zyear% + Zcentury% - ( 2 * century% ) WHILE wkdaynum% < 0 wkdaynum% = wkdaynum% + 7 WEND wkdaynum% = wkdaynum% MOD 7 ' This returns 0 for Saturday, 1 for Sunday, 2 for Monday, etc. ' wrap Saturday to after Friday IF (wkdaynum% = 0) THEN wkdaynum% = 7 ' We want 0 for Sunday, 1 for Monday, 2 for Tuesday, etc. Weekday% = wkdaynum% - 1 ' We'll also calculate the number of days in the month days% = daysInMonth%(month%) ' next line never entered because month% now > 2 'IF (month% = 2) and (year% MOD 4 = 0) THEN days% = days% + 1 ' restore entry values day% = entryDay% month% = entryMonth% year% = entryYear% century% = entryCentury% END FUNCTION