// THIS CODE IS INCLUDED IN GLOBAL CODE WITH #include /* Some of these routines use a "switch" file. Basically, IF A FILE EXISTS, DO X, ELSE DO Y. The CONTENT of a switch file is COMPLETELY IRRELEVANT. It can AND SHOULD have a zero length. The ONLY purpose of a switch file is to trigger "switch" code. Basically, using switch files lets users with LITTLE TO NO computer savvy set PROGRAM parameters simply by giving a file a particular name. FOR INSTANCE, in a batch file: IF EXIST c:\switchfiles\SesameAdminMode SET SHOW_ADMIN_FIELDS=Yes ELSE SET SHOW_ADMIN_FIELDS=No One advantage to switch files is that completely unrelated programs can all look at the same "switchfiles" folder for their particular switch files, rather than having user-set configurations scattered all over the place. Obviously, the switch file technique is used for things like enabling temporary Administrator, Power User or Diagnostic modes, not for things like font choice (unless you need to temporarily override user-selected fonts so a particular report prints properly). The switch file technique avoids things like users reading an on-line manual, finding out an admin-level password or finding hidden options by accident and then accessing things they're not supposed to be accessing. */ /* ************************** LIST OF USER-DEFINED PROCEDURES ************************** TYPES: 1) IN-LINE IF 2) DATA CHECKING 3) STRING AND BLOCK TEXT FORMATTING 4) STRING MANIPULATION 5) DATE FORMATTING 6) DATE MATH AND AGE 7) STATUS 8) HYPERLINKS 9) EXTERNAL PROGRAMS 1) ***** IN-LINE IF FUNCTIONS ***** IifStr() String - in-line if returns first string if condition is true, else second IifChar() Char - in-line if returns first character if condition is true, else second IifDate() Date - in-line if returns first date if condition is true, else second IifTime() Time - in-line if returns first time if condition is true, else second IifInt() Int - in-line if returns first integer if condition is true, else second IifDouble() Double - in-line if returns first double if condition is true, else second IifMoney() Money - in-line if returns first amount if condition is true, else second 2) ***** DATA CHECKING FUNCTIONS ***** Holds() - Equivalent to If @Instr(a, b) > 0 Holds5 - Returns True if A contains up to 5 specific strings 3) ***** STRING AND BLOCK TEXT FORMATTING ***** AllTrim() String - strips all leading and trailing spaces (leaves trailing CRLF) AllTrimNoEOL() String - strips all leading and trailing spaces and trailing EOL StringIsEmpty() Boolean - returns True if string is empty or only spaces NoEOL() String - Returns a string with trailing EOL removed JoinStringsWithBlanks() String - Joins up to 10 non-empty strings, adding a blank line between them. Ignores empty strings. Use this to merge text blocks into a single block with a blank line maintaining separation between blocks. JoinStringsWithEOLs() String - Joins up to 10 non-empty strings, starting each string on a new line. Ignores empty strings. Use this to merge multiple fields into a multi-line text block, e.g., Name, Company Name, Department, Street 1, Street 2 into part of a mailing address. AddBlankLines() String - Adds # of blank lines to a string 4) ***** STRING MANIPULATION ***** CharByVal() Char - Returns first character of a string and strips it Calling string ends up 1 character shorter LastCharByVal() Char - returns last character of a string and strips it Calling string ends up 1 character shorter 5) ***** DATE FORMATTING ***** ParensDOW() String - calculates DOW and returns it in parentheses 6) ******* DATE MATH AND AGE ****** AddToDate() Date - Returns Old date plus/minus X days, weeks, months or years as Date DateDifference() Date - Returns difference between two dates as integer AgeToday() Int - Returns the person's age in years today. AgeOnDate() Int - Returns the person's age in years on a specified date HandleWeekend() Date - Keeps or moves date back or forward if it falls on a weekend OPTIONS: "Ahead", "Forward", "Back", "Closest", "Keep", "Leave", "OK, "Weekend" Only checks first letter. Keep through Weekend all leave the date. WeekendTreatment() String - Translates radio button labels for use with HandleWeekend Inputs: "Use Monday", "Use Friday", "Use Closest", "Keep It" 7) ******* STATUS ****** SwitchFileExists() Boolean - returns True if the specified "switch" file exists ShowAdminMode() Sets sInAdminMode and if true displays info box ModeAsString() String - Returns current mode as a mixed-case string ModeAsCaps() String - Returns current mode as an uppercase string 8) ***** HYPERLINKS ***** The link must be a text field in the format DESCRIPTION#URL LinkDescription() String - Returns the description portion of a hyperlink text field LinkURL() String - Returns the full URL of a hyperlink text field LinkPageURL() String - Returns the full URL of a hyperlink text field without any anchor LinkAnchor() String - Returns the anchor portion of a hyperlink text field LinkData() String - Returns parts of a hyperlink text field 9) ***** EXTERNAL PROGRAMS ***** ViewHTMLHelp() Opens the specified HTML help file in the Sesame-specified browser 10) ***** FORM-SPECIFIC ***** SetSearchReadability() Set the writability of the Search tab LE's [Form-specific] ************************** END OF LIST OF USER-DEFINED PROCEDURES ************************** */ // ******************************** DECLARE STATIC VARIABLES ******************************* stat sInAdminMode as Boolean stat sUserInitials as String stat sUserFirstName as String stat sUserFullName as String stat sReadOnly as Boolean stat sHTMLBrowser as String stat sDefaultHelpPath as String // Full path stat sStringOfEqualSigns as String // ******************************** USER-DEFINED PROCEDURES ******************************** /* 1) +++++++++++++++++++++++++++ + IN-LINE IF FUNCTIONS + +++++++++++++++++++++++++++ (None for If Boolean ...) */ // ====================================================================== // IIF STR - IN-LINE IF FOR STRINGS // If Condition is true returns first string, else second // ====================================================================== Function IifStr(TestCondition as Boolean, TrueString as String, FalseString as String) as String If TestCondition then Return(TrueString) Else Return(FalseString) End Function // IifStr // ====================================================================== // IIF CHAR - IN-LINE IF FOR CHARS // If Condition is true returns first character, else second // ====================================================================== Function IifChar(TestCondition as Boolean, TrueChar as Char, FalseChar as Char) as Char If TestCondition then Return(TrueChar) Else Return(FalseChar) End Function // IifChar // ====================================================================== // IIF DATE - IN-LINE IF FOR DATES // If Condition is true returns first date, else second // ====================================================================== Function IifDate(TestCondition as Boolean, TrueDate as Date, FalseDate as Date) as Date If TestCondition then Return(TrueDate) Else Return(FalseDate) End Function // IifDate // ====================================================================== // IIF TIME - IN-LINE IF FOR TIME // If Condition is true returns first time, else second // ====================================================================== Function IifTime(TestCondition as Boolean, TrueTime as Time, FalseTime as Time) as Time If TestCondition then Return(TrueTime) Else Return(FalseTime) End Function // IifTime // ====================================================================== // IIF INT - IN-LINE IF FOR INTEGERS // If Condition is true returns first integer else second // ====================================================================== Function IifInt(TestCondition as Boolean, TrueInt as Int, FalseInt as Int) as Int If TestCondition then Return(TrueInt) Else Return(FalseInt) End Function // IifInt // ====================================================================== // IIF DOUBLE - IN-LINE IF FOR DOUBLES // If Condition is true returns first double, else second // ====================================================================== Function IifDouble(TestCondition as Boolean, TrueDouble as Double, FalseDouble as Double) as Double If TestCondition then Return(TrueDouble) Else Return(FalseDouble) End Function // IifDouble // ====================================================================== // IIF MONEY - IN-LINE IF FOR MONEY // If Condition is true returns first amount, else second // ====================================================================== Function IifMoney(TestCondition as Boolean, TrueAmount as Money, FalseAmount as Money) as Money If TestCondition then Return(TrueAmount) Else Return(FalseAmount) End Function // IifMoney /* 2) +++++++++++++++++++++++++++++++++++++++++ + + + DATA CHECKING FUNCTIONS + + + +++++++++++++++++++++++++++++++++++++++++ */ // ====================================================================== // HOLDS - Returns True if A contains B // ====================================================================== Function Holds(DoesThis as String, HoldThis as String, IgnoreCase as Int) as Boolean If IgnoreCase = 1 then { DoesThis = ToUpper(DoesThis) HoldThis = ToUpper(HoldThis) } Return(@Instr(DoesThis,HoldThis)>0) End Function // Holds // ====================================================================== // HOLDS 5 - Returns True if A contains up to 5 specific strings // Ignores empty strings // ====================================================================== Function Holds5(DoesThis as String, S1 as String, S2 as String, S3 as String, S4 as String, S5 as String, IgnoreCase as Int) as Boolean var vInt as Int = 1 If IgnoreCase = 1 then { DoesThis = ToUpper(DoesThis) S1 = ToUpper(S1) S2 = ToUpper(S2) S3 = ToUpper(S3) S4 = ToUpper(S4) S5 = ToUpper(S5) } If S1 <> "" then vInt = vInt * @Instr(DoesThis, S1) If S2 <> "" then vInt = vInt * @Instr(DoesThis, S2) If S3 <> "" then vInt = vInt * @Instr(DoesThis, S3) If S4 <> "" then vInt = vInt * @Instr(DoesThis, S4) If S5 <> "" then vInt = vInt * @Instr(DoesThis, S5) Return(vInt > 0) End Function // Holds5 // ====================================================================== // MAX VAL - Returns Highest field value // ====================================================================== Function MaxVal(FileToCheck as String, Fieldname as String) as Double var vString as String var Count as Int vString = @XListValues(FileToCheck, Fieldname) vString = @UniqueStringArray(vString) vString = @SortStringArray(vString, 1) // Numeric Count = @CountStringArray(vString) Return(@ToNumber(@AccessStringArray(vString,Count))) End Function // MaxVal // ====================================================================== // MIN VAL - Returns Lowest field value // ====================================================================== Function MinVal(FileToCheck as String, Fieldname as String) as Double var vString as String vString = @XListValues(FileToCheck, Fieldname) vString = @UniqueStringArray(vString) vString = @SortStringArray(vString, 1) // Numeric Return(@ToNumber(@AccessStringArray(vString,1))) End Function // MinVal // ====================================================================== // FORM MAX VAL - Returns Highest field value // ====================================================================== Function FormMaxVal(FormName as String, Element as String) as Double var vString as String var Count as Int vString = @FormGetValues(FormName, Element) vString = @UniqueStringArray(vString) vString = @SortStringArray(vString, 1) // Numeric Count = @CountStringArray(vString) Return(@ToNumber(@AccessStringArray(vString,Count))) End Function // FormMaxVal // ====================================================================== // FORM MIN VAL - Returns Lowest field value // ====================================================================== Function FormMinVal(FormName as String, Element as String) as Double var vString as String vString = @FormGetValues(FormName, Element) vString = @UniqueStringArray(vString) vString = @SortStringArray(vString, 1) // Numeric Return(@ToNumber(@AccessStringArray(vString,1))) End Function // FormMinVal /* 3) +++++++++++++++++++++++++++++++++++++++++ + + + STRING AND BLOCK TEXT FORMATTING + + + +++++++++++++++++++++++++++++++++++++++++ */ // ====================================================================== // ALL TRIM strips all leading and trailing spaces (leaves trailing CRLF) // ====================================================================== Function AllTrim(vTempVar as String) as String Return(@TrimStringRight(@TrimStringLeft(vTempVar," ")," ")) End Function // AllTrim // ====================================================================== // ALL TRIM NO EOL strips all leading and trailing spaces and trailing EOL // ====================================================================== Function AllTrimNoEOL(vTempVar as String) as String Return(@TrimStringRight(@TrimStringRight(@TrimStringLeft(vTempVar," ")," "), @Newline())) End Function // AllTrimNoEOL // ====================================================================== // STRING IS EMPTY returns True if string is empty or only spaces // ====================================================================== Function StringIsEmpty(vTempVar as String) as Boolean Return(@TrimStringRight(@TrimStringLeft(vTempVar," ")," ") = "") End Function // StringIsEmpty // ====================================================================== // NO EOL returns a string with any EOL removed // ====================================================================== Function NoEOL(vTempVar as String) as String Return(@TrimStringRight(vTempVar, @Newline())) End Function // NoEOL // ======================================================================================== // JOIN STRINGS WITH BLANKS // Merges up to 10 NON-EMPTY strings with blanks between each. Considers spaces as empty. // Empty strings are ignored. // Removes leading carriage returns from result and trailing CR's for each field. // // USE THIS TO JOIN MULTIPLE MULTI-LINE FIELDS INTO ONE WITH SEPARATION PRESERVED // Example: // Source Fields: // Current Job Description: (3 lines of text) // Previous Job Description: (5 lines of text) // Grad School: (empty) // Military Service: (4 lines of text) // // Result: // Current Job Description: (3 lines of text) // // Previous Job Description: (5 lines of text) // // Military Service: (4 lines of text) // ======================================================================================== Function JoinStringsWithBlanks(a as String, b as String, c as String, d as String, e as String, f as String, g as String, h as String, i as String, j as String) as String var vOut as String = "" If not StringIsEmpty(a) then vOut = AllTrimNoEOL(a) If not StringIsEmpty(b) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(b) If not StringIsEmpty(c) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(c) If not StringIsEmpty(d) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(d) If not StringIsEmpty(e) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(e) If not StringIsEmpty(f) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(f) If not StringIsEmpty(g) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(g) If not StringIsEmpty(h) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(h) If not StringIsEmpty(i) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(i) If not StringIsEmpty(j) then vOut = vOut + @Newline() + @Newline() + AllTrimNoEOL(j) vOut = @TrimStringLeft(vOut, @Newline()) Return(vOut) End Function // JoinStringsWithBlanks // =========================================================================================== // JOIN STRINGS WITH EOLS // Merges up to 10 NON-EMPTY strings with no blanks between each. Considers spaces as empty. // Empty strings are ignored. // Removes leading carriage returns from result and trailing CR's for each field. // // USE THIS TO JOIN MULTIPLE 1-LINE FIELDS INTO A SINGLE TEXT BLOCK WITH EOL's PRESERVED // Example: // Source Fields: // Name = John Smith // Company = (empty) // Street = 123 Jones Street // City = Dallas, Texas // // Result: // John Smith // 123 Jones Street // Dallas, Texas // // =========================================================================================== Function JoinStringsWithEOLs(a as String, b as String, c as String, d as String, e as String, f as String, g as String, h as String, i as String, j as String) as String var vOut as String = "" If not StringIsEmpty(a) then vOut = AllTrimNoEOL(a) If not StringIsEmpty(b) then vOut = vOut + @Newline() + AllTrimNoEOL(b) If not StringIsEmpty(c) then vOut = vOut + @Newline() + AllTrimNoEOL(c) If not StringIsEmpty(d) then vOut = vOut + @Newline() + AllTrimNoEOL(d) If not StringIsEmpty(e) then vOut = vOut + @Newline() + AllTrimNoEOL(e) If not StringIsEmpty(f) then vOut = vOut + @Newline() + AllTrimNoEOL(f) If not StringIsEmpty(g) then vOut = vOut + @Newline() + AllTrimNoEOL(g) If not StringIsEmpty(h) then vOut = vOut + @Newline() + AllTrimNoEOL(h) If not StringIsEmpty(i) then vOut = vOut + @Newline() + AllTrimNoEOL(i) If not StringIsEmpty(j) then vOut = vOut + @Newline() + AllTrimNoEOL(j) vOut = @TrimStringLeft(vOut, @Newline()) Return(vOut) End Function // JoinStringsWithEOLs // ====================================================================== // ADD BLANK LINES // Adds # of blank lines to a string // ====================================================================== Function AddBlankLines(vStringToChange as String, vBlanksToAdd as Int) as String var vLastChar as String var vStringLen as Int var vCnt as Int If vBlanksToAdd < 1 then Return(vStringToChange) // Strip ONE EOL if there is one. vLastChar = @Right(vStringToChange,1) If (vLastChar = @chr(10)) or (vLastChar = @chr(13)) then { vStringLen = @Len(vStringToChange) -1 vStringToChange = @Left(vStringToChange,vStringLen) If (vLastChar = @chr(10)) or (vLastChar = @chr(13)) then { vStringLen = @Len(vStringToChange) -1 vStringToChange = @Left(vStringToChange, vStringLen) } } // Add an EOL vStringToChange = vStringToChange + @Newline() For vCnt = 1 to vBlanksToAdd vStringToChange = vStringToChange + @Newline() Next Return(vStringToChange) End Function // AddBlankLines /* 4) +++++++++++++++++++++++++++++++++ + + + STRING MANIPULATION + + + +++++++++++++++++++++++++++++++++ */ // ====================================================================== // CHAR BY VAL returns first character and strips it from the string // Calling string is 1 character shorter // ====================================================================== Function CharByVal(var StringToChange as String) as Char var RetChar as Char = "" var NewLength as Int If StringToChange <> "" then { RetChar = @Left(StringToChange, 1) NewLength = @Len(StringToChange) - 1 StringToChange = @Right(StringToChange, NewLength) } Return(RetChar) End Function // CharByVal // ====================================================================== // LAST CHAR BY VAL returns last character and strips it from the string // Calling string is 1 character shorter // ====================================================================== Function LastCharByVal(var StringToChange as String) as Char var RetChar as Char = "" var NewLength as Int If StringToChange <> "" then { RetChar = @Right(StringToChange, 1) NewLength = @Len(StringToChange) - 1 StringToChange = @Left(StringToChange, NewLength) } Return(RetChar) End Function // LastCharByVal /* 5) +++++++++++++++++++++++++++++++++ + + + DATE FORMATTING + + + +++++++++++++++++++++++++++++++++ */ // ====================================================================== // PARENS DOW calculates DOW and returns it in parentheses // ====================================================================== Function ParensDOW(DateVal as Date) as String Return("( " + @DOW$(DateVal) + " )") End Function // ParensDOW // ====================================================================== // USSlashDATE returns date in MM/DD/YYYY format (from YYYY/MM/DD) // ====================================================================== Function USSlashDate(vDate as Date) as String Return(@Mid(vDate,6,2) + "/" + @Right(vDate, 2) + "/" + @Left(vDate, 4)) End Function // USSlashDate // ====================================================================== // USDashDATE returns date in MM-DD-YYYY format (from YYYYMMDD) // ====================================================================== Function USDashDate(vDate as Date) as String Return(@Mid(vDate,6,2) + "-" + @Right(vDate, 2) + "-" + @Left(vDate, 4)) End Function // USDashDate /* 6) ++++++++++++++++++++++++ + DATE MATH AND AGE + ++++++++++++++++++++++++ */ // ====================================================================== // ADD TO DATE // Returns Old date plus X days, weeks, months or years as Date // AMOUNT TO ADD CAN BE NEGATIVE // ====================================================================== /* *** CAUTION - DOES NOT HANDLE "MONTH" COMPLETELY ACCURATELY *** The problem is: What is "one month" after March 31? Is it April 30 or June 1? What is "one month" before March 31? Is it Feb 28? */ Function AddToDate(OldDate as Date, AddWhat as String, AmountToAdd as Int) as Date var NewDate as Date = OldDate var YearNum as Int = @Year(OldDate) var MonthNum as Int = @Month(OldDate) AddWhat = @Replace(ToUpper(AddWhat), "S","") // Convert to uppercase, remove final S if any If AmountToAdd = 0 then // Do nothing -- date will be returned unchanged Else If AddWhat = "DAY" then NewDate = OldDate + AmountToAdd Else If AddWhat = "WEEK" then NewDate = OldDate + (7 * AmountToAdd) Else If AddWhat = "YEAR" then NewDate = @ToDate(@str(YearNum + AmountToAdd) + @Right(OldDate, 6)) Else If AddWhat <> "MONTH" then // Do nothing -- date will be returned unchanged Else If AmountToAdd > 0 then // ADD months { MonthNum = MonthNum + AmountToAdd // E.g. 11/23/2003 + 27 = 38/23/2003, Months = 38 YearNum = YearNum + (MonthNum /12) MonthNum = @Mod(MonthNum, 12) If MonthNum = 0 Then MonthNum = 12 // December mod 12 = Month 0 NewDate = @ToDate(@Str(YearNum) + "/" + @Right("0" + @Str(MonthNum),2) + @Right(OldDate, 3)) } Else // SUBTRACT months { /* Vars: MonthNum = current month AmountToAdd = Amount to SUBTRACT YearNum = current year */ // Example: subtract 22 months from 1998/02/18 YearNum = YearNum + @Int(AmountToAdd / 12) // How many years to subtract = YearNum is now 1997 AmountToAdd = @Mod(AmountToAdd, 12) // How many months (less than yr) to subtract = 10. // Year is now correct but months not changed yet If AmountToAdd = 0 // 12 mos, 24, etc. -- Do nothing Else If (AmountToAdd + MonthNum) < 1 Then // e.g., subtract 2 to 11 months from February { YearNum = YearNum - 1 // Do subtraction "borrowing" of 12 months. YearNum is now 1996 MonthNum = MonthNum + 12 + AmountToAdd // ADD MINUS 10 months to 14 months. Month is now 4 = April } Else MonthNum = MonthNum + AmountToAdd NewDate = @ToDate(@Str(YearNum) + "/" + @Right("0" + @Str(MonthNum),2) + @Right(OldDate, 3)) } Return(NewDate) End Function // AddToDate // ====================================================================== // DATE DIFFERENCE // Returns difference between two dates as integer // ====================================================================== Function DateDifference(vDateOne as Date, vDateTwo as Date) as Int var vDiff as Int vDiff = @ToNumber(vDateOne) - @ToNumber(vDateTwo) Return(vDiff) End Function // DateDifference // ====================================================================== // AGE TODAY // Returns age in years on date calculation is run // ====================================================================== Function AgeToday(vBirthDate as Date) As Int var vAge as Int var vYears as Int var vAdj as Int vYears = @Year(@Date) - @Year(vBirthDate) vAdj = 0 If ((@Month(@Date) < @Month(vBirthDate)) Or ((@Month(@Date) = @Month(vBirthDate)) And (@DOM(@Date) < @DOM(vBirthDate)))) { vAdj = 1 } vAge = vYears - vAdj If vAge < 0 then @MsgBox("FUTURE BIRTHDATES NOT ALLOWED!", "", "") Return(vAge) End Function // AgeToday // ====================================================================== // AGE ON DATE // Returns age in years on a specified date // ====================================================================== Function AgeOnDate(vBirthDate as Date, vAgeAsOfDate as Date) As Int var vAge as Int var vYears as Int var vAdj as Int vYears = @Year(vAgeAsOfDate) - @Year(vBirthDate) vAdj = 0 If ((@Month(vAgeAsOfDate) < @Month(vBirthDate)) Or ((@Month(vAgeAsOfDate) = @Month(vBirthDate)) And (@DOM(vAgeAsOfDate) < @DOM(vBirthDate)))) { vAdj = 1 } vAge = vYears - vAdj If vAge < 0 then @MsgBox("THE BIRTHDATE CANNOT BE AFTER THE AGE DATE", "", "") Return(vAge) End Function // AgeOnDate // ====================================================================== // HANDLE WEEKEND // Keeps or moves date back or forward if it falls on a weekend // ====================================================================== Function HandleWeekend(CheckDate as Date, DateAction as String) as Date // OPTIONS: "Ahead", "Forward", "Back", "Closest", "Keep", "Leave", "OK, "Weekend" // Only checks first letter. Keep through Weekend all leave the date. var OutDate as Date = CheckDate var TempNum as Int DateAction = ToUpper(@Left(DateAction + "K", 1)) // Empty = Keep TempNum = @DOW(CheckDate) If (TempNum < 6) or @Rest("KLOW", DateAction) then // Do nothing - use CheckDate Else If DateAction = "B" then // BACK { If TempNum = 7 then TempNum = 2 Else TempNum = 1 OutDate = CheckDate - TempNum } Else If @Instr("AF", DateAction) > 0 then // AHEAD { If TempNum = 6 then TempNum = 2 Else TempNum = 1 OutDate = CheckDate + TempNum } Else If DateAction = "C" then // CLOSEST { If TempNum = 7 then TempNum = 1 Else TempNum = -1 OutDate = CheckDate + TempNum } Else @MsgBox("Error!", "Invalid Action specified for weekend date:", "Action: " + DateAction) Return(OutDate) End Function // HandleWeekend // ====================================================================== // WEEKEND TREATMENT // Translates radio button labels for use with HandleWeekend // Inputs: "Use Monday", "Use Friday", "Use Closest", "Keep It" // ====================================================================== Function WeekendTreatment(DoThis as String) as String // Translate Weekend to format used by HandleWeekend DoThis = ToUpper(DoThis) If DoThis = "USE MONDAY" then DoThis = "Ahead" Else If DoThis = "USE FRIDAY" then DoThis = "Back" Else If DoThis = "USE CLOSEST" then DoThis = "Closest" Else If DoThis = "KEEP IT" then DoThis = "Keep" Else DoThis = "" // (Unspecified !) NOTE - HandleWeekend will treat as Keep Return(DoThis) End Function // WeekendTreatment /* 7) +++++++++++++++++ + + + STATUS + + + +++++++++++++++++ */ // ====================================================================== // SWITCH FILE EXISTS returns True if the specified file exists // The files are used as "switches"--contents are irrelevant. // ====================================================================== Function SwitchFileExists(vFileToCheck as String) as Boolean Return(FileExists(vFileToCheck)) End Function // SwitchFileExists // ====================================================================== // SHOW ADMIN MODE displays a MsgBox if in AdminMode // ====================================================================== Subroutine ShowAdminMode() sInAdminMode = SwitchFileExists("C:\Sesame\AdminMode.txt") If sInAdminMode then @MsgBox("","YOU ARE IN ADMIN MODE.","") End Subroutine // ShowAdminMode // ====================================================================== // MODE AS STRING // Returns current mode in a mixed-case string // // @Mode() returns an integer that identifies the current Sesame mode. // 0 = Add Data Mode // 1 = Update Mode // 2 = Search Mode (Retrieve Spec) // 3 = No Mode (Startup Form) // 4 = Dialog Mode (Shown with @FormAsDialog) // ====================================================================== Function ModeAsString() as String Return(@Select(@Mode()+1, "Add Data", "Update", "Search", "No Mode", "Dialog Mode")) End Function // ModeAsString // ====================================================================== // MODE AS CAPS // Returns current mode in an uppercase string // ====================================================================== Function ModeAsCaps() as String Return(@Select(@Mode()+1, "ADD DATA", "UPDATE", "SEARCH", "NO MODE", "DIALOG MODE")) End Function // ModeAsCaps /* 8) +++++++++++++++++++++++++ + + + HYPERLINKS + + + +++++++++++++++++++++++++ */ // ====================================================================== // LINK DESCRIPTION // Returns the description portion of a hyperlink text field // The link must be in the format DESCRIPTION#URL // ====================================================================== Function LinkDescription(Hyperlink as String) as String Return(Split(Hyperlink, "#")) End Function // LinkDescription // ====================================================================== // LINK URL // Returns the full URL of a hyperlink text field // The link must be in the format DESCRIPTION#URL // ====================================================================== Function LinkURL(Hyperlink as String) as String var vJunk as String vJunk = Split(Hyperlink, "#") Return(Hyperlink) End Function // LinkURL // ====================================================================== // LINK PAGE URL // Returns the full URL of a hyperlink text field without any anchor // The link must be in the format DESCRIPTION#URL // ====================================================================== Function LinkPageURL(Hyperlink as String) as String var vRetVal as String vRetVal = Split(Hyperlink, "#") // Strip the Description vRetVal = Split(Hyperlink, "#") // Take the URL up to the anchor Return(vRetVal) End Function // LinkPageURL // ====================================================================== // LINK ANCHOR // Returns the anchor portion of a hyperlink text field // The link must be in the format DESCRIPTION#URL // ====================================================================== Function LinkAnchor(Hyperlink as String) as String var vJunk as String vJunk = Split(Hyperlink, "#") // Leaves Hyperlink as full URL vJunk = Split(Hyperlink, "#") // Leaves Hyperlink as the anchor portion or empty Return(Hyperlink) End Function // LinkAnchor // ====================================================================== // LINK DATA // Returns parts of hyperlink text field // The link must be in the format DESCRIPTION#URL // Data returned is set by DataToReturn // 0 = Return field contents (Description#full URL) // 1 = Return description // 2 = Return full URL (including any anchor // 3 = Return full page URL without anchor // 4 = Return anchor only (useful when HTML has relative URLs) // ====================================================================== Function LinkData(Hyperlink as String, DataToReturn as Int) as String var RetVal as String = "" If (DataToReturn < 0) or (DataToReturn) > 4 then RetVal = "PARAMETER OUT OF RANGE! MUST BE BETWEEN 0 AND 4" Else If DataToReturn = 0 then RetVal = Hyperlink // Return full field contents Else If DataToReturn = 1 then RetVal = LinkDescription(Hyperlink) // Description only Else If DataToReturn = 2 then RetVal = LinkURL(Hyperlink) // Full URL Else If DataToReturn = 3 then RetVal = LinkPageURL(Hyperlink) // Page URL without anchor Else RetVal = LinkAnchor(Hyperlink) // DataToReturn = 4 // Anchor only Return(RetVal) End Function // LinkData /* 9) +++++++++++++++++++++++++ + + + EXTERNAL PROGRAMS + + + +++++++++++++++++++++++++ */ // ====================================================================== // VIEW HTML HELP // Opens the specified HTML document in the specified browser // The browser is set in a static variable // ====================================================================== Subroutine ViewHTMLHelp(vHelpPath as String, vHelpDocName as String) // Assumes user has FireFox installed !!! var CmdLine as String If vHelpPath = "" then vHelpPath = sDefaultHelpPath If @Right(vHelpPath, 1) <> "\" then vHelpPath = vHelpPath + "\" CmdLine = @chr(34) + sHTMLBrowser + @chr(34) + " " + @chr(34) + vHelpPath + vHelpDocName + @chr(34) CreateAProcess(CmdLine) End Subroutine // ViewHTMLHelp // ******************************** END USER-DEFINED PROCEDURES ******************************** // ************************************ SET STATIC VARIABLES *********************************** Subroutine SetStaticVars() // SET SYSVARS ShowAdminMode() // Sets sInAdminMode & displays dialog if true sUserInitials = "" // Leaving these null to make this program generic sUserFirstName = "" sUserFullName = "" sReadOnly = True sHTMLBrowser = "C:\Program Files\Internet Explorer\iexplore.exe" // sHTMLBrowser = "C:\Program Files\Mozilla Firefox\firefox.exe" sDefaultHelpPath = "G:\Sesame\Help\" sStringOfEqualSigns = @Text(70,"=") End Subroutine // SetStaticVars