home *** CD-ROM | disk | FTP | other *** search
Wingz Script | 1990-06-15 | 30.3 KB | 769 lines |
- WNGZWZSC0110
- Excel
- Lotus
- Full Impact
- File Source
- Cancel
- 6DateConv.scz:duit = 1;DateConv.scz:type = CTVALUE(1,0)
- 4ON REPAINT CALL DateConv.scz:DRAW_LOGO() END REPAINT
- Formulas.wkz
- Formulas.wkz9
- BYou MUST open a Microsoft Excel WKS or WK1 sheet before beginning!
- date formatted cell(s) 5
- 9containing either formulas or text strings were found in 5
- ;this worksheet. These cells and their contents are listed 5
- ;in the worksheet "Formulas.wkz". You must manually verify 5
- &the correct operations of these cells.5
- Formulas.wkz
- "The conversion has been completed!
- Formulas.wkz
- Formulas.wkz9
- >You MUST open a Lotus 1-2-3 WKS or WK1 sheet before beginning!
- date formatted cell(s) 5
- 9containing either formulas or text strings were found in 5
- ;this worksheet. These cells and their contents are listed 5
- ;in the worksheet "Formulas.wkz". You must manually verify 5
- &the correct operations of these cells.5
- Formulas.wkz
- "The conversion has been completed!
- Formulas.wkz
- Formulas.wkz9
- JYou MUST open a Ashton-Tate Full Impact WKS or WK1 sheet before beginning!
- date formatted cell(s) 5
- 9containing either formulas or text strings were found in 5
- ;this worksheet. These cells and their contents are listed 5
- ;in the worksheet "Formulas.wkz". You must manually verify 5
- &the correct operations of these cells.5
- Formulas.wkz
- "The conversion has been completed!
- ADATE
- ADDDAYS
- ADDHOURS
- ADDMINUTES
- ADDMONTHS
- DAYNAME
- MINUTE
- ADDSECONDS
- ADDYEARS
- ATIME
- MONTH
- MONTHNAME
- SECOND
- DATEVALUE
- Formulas.wkz
- Formulas.wkz
- DateConverter
- Convert All
- DateConv.scz:duit = 1
- DateConv.scz:duit = 0
- 'DateConv.scz:global = 1;quit dialog box
- Convert '
- ' formatted as '5
- ', or globally convert all?5
- Tms Rmn
- 433333$@
- 433333$@
- Tms Rmn
- gfffff&@
- 433333&@
- Date Converter
- cell_format
- current_row
- current_col
- num_rows
- num_cols
- starting_row
- starting_col
- show_help
- open_sheet
- begin_adjustments
- abort
- sheet_name
- current_cell
- num_formula_cells
- global
- decimal
- DateConv_Excp
- DateConv_123.
- DateConv_FI
- CheckForDateFormulas%
- CustomDates
- Convert
- Draw_LogoZ
- {==========================================================================
- PROGRAM NAME
- DateConv
- COPYRIGHT INFORMATION
- Lotus and 1-2-3 are registered trademarks of Lotus Development
- Corporation. Microsoft and Excel are registered trademarks of
- Microsoft Corporation. Ashton-Tate and Full Impact are registered
- trademarks of the Ashton-Tate Corporation.
- DESCRIPTION
- This script aids the user in converting date serial numbers from
- foreign file formats to Wingz' date serial numbering scheme.
- LIBRARY MODULES
- DateConv_Exc () - Function for converting Excel files.
- DateConv_123 () - Function for converting Lotus files.
- DateConv_FI () - Function for converting Full Impact files.
- CheckForDateFormulas () - This function checks the current cell
- for date related functions and if they exist, the name of
- the cell is placed in the worksheet Formulas.wkz.
- CustomDates () - This function checks the current cell for cells
- formatted with the standard date formats from Excel. These
- are m/d/yy, d-mmm-yy, d-mmm,mmm-yy, m/d/yy h:mm. When Wingz
- converts a SYLK file from Excel, it will create Excel's
- standard date formats as custom formats. This is not valid
- with files saved as WK1 or WKS.
- Convert () - This function prompts the user whether or not to
- convert the number based on the displayed custom format.
- The reason for this is that time formats and date formats
- have the letter "m" in common, and date and time format
- strings can be used in conjunction with one another.
- NOTES
- None.
- HISTORY
- 03/27/90 - KHB - Initial code.
- ==========================================================================}
- DEFINE cell_format,
- current_row,
- current_col,
- num_rows,
- num_cols,
- d1,
- starting_row,
- starting_col,
- show_help,
- open_sheet,
- begin_adjustments,
- abort,
- sheet_name,
- current_cell,
- num_formula_cells,
- duit,
- global,
- decimal,
- type
- NEW MODAL DIALOG BOX AT (-1,-1) (6500,3100)
- ADD RADIO BUTTON "Excel","Lotus","Full Impact" AT (3200,210) (6300,2000)
- SHOW CONTROL TITLE "File Source"
- ADD PUSH BUTTON "OK","Cancel" AT (3200,2350) (6300,2750)
- DIALOG CANCEL PUSH BUTTON
- SELECT CONTROL 2
- DIALOG DEFAULT PUSH BUTTON
- SCRIPT "DateConv.scz:duit = 1;DateConv.scz:type = CTVALUE(1,0)"
- ADD CUSTOM BUTTON AT (0,0) (3000,3000)
- DISABLE CONTROL
- SCRIPT "ON REPAINT CALL DateConv.scz:DRAW_LOGO() END REPAINT"
- NO LINE BORDER
- USE DIALOG BOX
- IF duit
- CASE type
- WHEN 1
- CALL DateConv_Exc ()
- WHEN 2
- CALL DateConv_123 ()
- WHEN 3
- CALL DateConv_FI ()
- END CASE
- END IF
- {==========================================================================
- FUNCTION NAME
- DateConv_Exc
- DESCRIPTION
- This function will correct dates in WKS, WK1, and SYLK files
- generated by Microsoft Excel version 1.5, as well as version
- 2.2 files with the starting date option of 1904.
- NOTES
- This function is necessary because Excel does not follow the
- convention established by Lotus for date serial numbers.
- Instead, Excel begins it's date series with 0 on Jan 1, 1904.
- Excel fails to read and write Lotus 1-2-3 generated WK1 or WKS
- files correctly. It performs no translations on the date
- numbers as they are read in. This situation causes Excel to
- be 4 years and 1 day ahead of Lotus 1-2-3 AND Wingz. If the
- date from Excel is before March 1, 1904, then the date is 4
- years and two days off. For example, if Lotus 1-2-3 and
- Wingz believe that it is March 6, 1989, Excel believes that
- it is March 7, 1993.
- HISTORY
- 03/07/89 - KHB - Initial code.
- 03/10/89 - JVR - Enhanced module formatting.
- 05/13/89 - HLG - Removed the user interface from DateConv and
- broke it down into 3 separate scripts:
- DateConv.Exc - to correct dates in WKS, WK1,
- and SYLK files generated by
- Microsoft Excel.
- DateConv.123 - to correct dates in WKS & WK1
- files generated by Lotus 1-2-3.
- DateConv.FI - to correct dates in WKS & WK1
- files generated by Ashton-Tate
- Full Impact.
- 02/22/90 - KHB - Added code to recognize and convert custom formats.
- Added capability to retain decimal portion of the
- date. serial number and discarded variable d2 by
- combining the adddays and the addyears into one
- equation.
- 03/27/90 - KHB - Believe it or not, the three scripts were merged
- again into 1.
- 05/06/90 - DAB - Ported to Windows 3.0
- ==========================================================================}
- FUNCTION DateConv_Exc ()
- num_formula_cells = 0
- GO TO WINDOW "Formulas.wkz"
- IF NAME() = "Formulas.wkz"
- CLOSE NOW
- END IF { Formulas.wkz already exists }
- IF (ISERR(NAME()))
- MESSAGE "You MUST open a Microsoft Excel WKS or WK1 sheet before beginning!"
- ELSE { valid name }
- sheet_name = NAME()
- REPAINT OFF
- NO AUTO MOVE
- SELECT ACTIVE CELLS
- num_rows = ROWS(SELECTION(1))
- num_cols = COLS(SELECTION(1))
- starting_row = ROW()
- starting_col = COL()
- current_row = 1
- current_col = 1
- UNSELECT
- WHILE (current_col <= num_cols)
- WHILE (current_row <= num_rows)
- current_cell = MAKECELL(current_col, current_row)
- GO TO CELL current_cell
- cell_format = BITAND(FORMAT(), 240)
- { Check for formulas or text dates. If so, do not change }
- IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR
- (ISSTRING(INDIRECT(current_cell)) = 1)
- current_row = current_row + 1
- CALL CheckForDateFormulas (cell_format, current_cell)
- CONTINUE WHILE
- END IF { a formula or text date }
- { Check if cell is formatted with one of Excel's standard date formats. }
- IF (cell_format = 224)
- current_row = current_row + 1
- CALL CustomDates ()
- CONTINUE WHILE
- END IF { a standard Excel date format }
- IF (cell_format = 80) OR (cell_format = 96) OR
- (cell_format = 112) OR (cell_format = 128) OR
- (cell_format = 144)
- decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
- IF INDIRECT(current_cell) <= 60
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
- ELSE
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
- END IF
- PUT d1 + decimal INTO current_cell
- END IF { a date format }
- current_row = current_row + 1
- END WHILE { rows }
- current_row = 1
- current_col = current_col + 1
- END WHILE { columns }
- GO TO CELL MAKECELL(starting_col,starting_row)
- IF (num_formula_cells > 0)
- MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
- "containing either formulas or text strings were found in " &
- "this worksheet. These cells and their contents are listed " &
- "in the worksheet ""Formulas.wkz"". You must manually verify " &
- "the correct operations of these cells."
- GO TO WINDOW sheet_name
- WINDOW LOCATION (0,0)
- WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
- GO TO WINDOW "Formulas.wkz"
- WINDOW LOCATION (.75 * DESKRIGHT(), 0)
- WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
- GO TO CELL A1
- COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
- COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
- END IF { if formula or text cells found }
- AUTO MOVE
- REPAINT ON
- REPAINT ALL WINDOWS
- MESSAGE "The conversion has been completed!"
- END IF { worksheet loaded }
- END FUNCTION { End of function DateConv_Exc () }
- {==============================================================================
- FUNCTION NAME
- DateConv_123
- DESCRIPTION
- This function will correct dates in WKS & WK1 files generated by
- Lotus 1-2-3.
- NOTES
- This function is necessary because Lotus 1-2-3 believes that 1900
- is a leap year and so counts February 29, 1900 as a legitimate date.
- This is not so. The rule for leap years is that they are every year
- evenly divisible by four except for centesimal years (1800, 1900, 2000)
- unless the centesimal year is evenly divisible by 400. That is why
- the year 2000 will be a leap year but 1900 was not.
- HISTORY
- 03/07/89 - KHB - Initial code.
- 03/10/89 - JVR - Enhanced module formatting.
- 05/13/89 - HLG - Removed the user interface from DateConv and broke
- it down into 3 separate scripts:
- DateConv.Exc - to correct dates in WKS & WK1 files
- generated by Microsoft Excel.
- DateConv.123 - to correct dates in WKS & WK1 files
- generated by Lotus 1-2-3.
- DateConv.FI - to correct dates in WKS & WK1 files
- generated by Ashton-Tate Full Impact.
- 03/27/90 - KHB - Believe it or not, the three scripts were merged
- again into 1.
- ===============================================================================}
- FUNCTION DateConv_123 ()
- num_formula_cells = 0
- GO TO WINDOW "Formulas.wkz"
- IF NAME() = "Formulas.wkz"
- CLOSE NOW
- END IF { Formulas.wkz already exists }
- IF (ISERR(NAME()))
- MESSAGE "You MUST open a Lotus 1-2-3 WKS or WK1 sheet before beginning!"
- ELSE { valid name }
- sheet_name = NAME()
- REPAINT OFF
- NO AUTO MOVE
- SELECT ACTIVE CELLS
- num_rows = ROWS(SELECTION(1))
- num_cols = COLS(SELECTION(1))
- starting_row = ROW()
- starting_col = COL()
- current_row = 1
- current_col = 1
- UNSELECT
- WHILE (current_col <= num_cols)
- WHILE (current_row <= num_rows)
- current_cell = MAKECELL(current_col, current_row)
- GO TO CELL current_cell
- cell_format = BITAND(FORMAT(), 240)
- { Check for formulas or text dates. If so, do not change }
- IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR
- (ISSTRING(INDIRECT(current_cell)) = 1)
- current_row = current_row + 1
- CALL CheckForDateFormulas (cell_format, current_cell)
- CONTINUE WHILE
- END IF
- IF (cell_format = 80) OR (cell_format = 96) OR
- (cell_format = 112) OR (cell_format = 128) OR
- (cell_format = 144)
- IF INDIRECT(current_cell) <= 59
- d1 = ADDDAYS(INDIRECT(current_cell),1)
- PUT d1 INTO current_cell
- END IF
- END IF { a date format }
- current_row = current_row + 1
- END WHILE { rows }
- current_row = 1
- current_col = current_col + 1
- END WHILE { columns }
- GO TO CELL MAKECELL(starting_col,starting_row)
- IF (num_formula_cells > 0)
- MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
- "containing either formulas or text strings were found in " &
- "this worksheet. These cells and their contents are listed " &
- "in the worksheet ""Formulas.wkz"". You must manually verify " &
- "the correct operations of these cells."
- GO TO WINDOW sheet_name
- WINDOW LOCATION (0,0)
- WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
- GO TO WINDOW "Formulas.wkz"
- WINDOW LOCATION (.75 * DESKRIGHT(), 0)
- WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
- GO TO CELL A1
- COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
- COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
- END IF { if formula or text cells found }
- AUTO MOVE
- REPAINT ON
- REPAINT ALL WINDOWS
- MESSAGE "The conversion has been completed!"
- END IF { worksheet loaded }
- END FUNCTION { End of function DateConv_123 () }
- {==============================================================================
- PROGRAM NAME
- DateConv.FI
- DESCRIPTION
- This function will correct dates in WKS & WK1 files generated by
- Ashton-Tate Full Impact.
- NOTES
- This function is necessary because Full Impact does not follow the
- convention established by Lotus for date serial numbers. Instead,
- Full Impact begins it's date series with 0 on Jan 1, 1904. Full
- Impact fails to read and write Lotus 1-2-3 generated WK1 or WKS
- files correctly. It performs no translations on the date numbers
- as they are read in. This situation causes Full Impact to be 4 years
- and 1 day ahead of Lotus 1-2-3 AND Wingz. If the date from Full
- Impact is before March 1, 1904, then the date is 4 years and two
- days off. For example, if Lotus 1-2-3 and Wingz believe that it
- is March 6, 1989, Full Impact believes that it is March 7, 1993.
- HISTORY
- 03/07/89 - KHB - Initial code.
- 03/10/89 - JVR - Enhanced module formatting.
- 05/13/89 - HLG - Removed the user interface from DateConv and broke
- it down into 3 separate scripts:
- DateConv.Exc - to correct dates in WKS & WK1 files
- generated by Microsoft Excel.
- DateConv.123 - to correct dates in WKS & WK1 files
- generated by Lotus 1-2-3.
- DateConv.FI - to correct dates in WKS & WK1 files
- generated by Ashton-Tate Full Impact.
- 02/23/90 - KHB - Added capability to retain decimal portion of the date
- serial number and discarded variable d2 by combining
- the adddays and the addyears into one equation.
- 03/27/90 - KHB - Believe it or not, the three scripts were merged
- again into 1.
- ===============================================================================}
- FUNCTION DateConv_FI ()
- num_formula_cells = 0
- GO TO WINDOW "Formulas.wkz"
- IF NAME() = "Formulas.wkz"
- CLOSE NOW
- END IF { Formulas.wkz already exists }
- IF (ISERR(NAME()))
- MESSAGE "You MUST open a Ashton-Tate Full Impact WKS or WK1 sheet before beginning!"
- ELSE { valid name }
- sheet_name = NAME()
- REPAINT OFF
- NO AUTO MOVE
- SELECT ACTIVE CELLS
- num_rows = ROWS(SELECTION(1))
- num_cols = COLS(SELECTION(1))
- starting_row = ROW()
- starting_col = COL()
- current_row = 1
- current_col = 1
- UNSELECT
- WHILE (current_col <= num_cols)
- WHILE (current_row <= num_rows)
- current_cell = MAKECELL(current_col, current_row)
- GO TO CELL current_cell
- cell_format = BITAND(FORMAT(), 240)
- { Check for formulas or text dates. If so, do not change }
- IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR
- (ISSTRING(INDIRECT(current_cell)) = 1)
- current_row = current_row + 1
- CALL CheckForDateFormulas (cell_format, current_cell)
- CONTINUE WHILE
- END IF
- IF (cell_format = 80) OR (cell_format = 96) OR
- (cell_format = 112) OR (cell_format = 128) OR
- (cell_format = 144)
- decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
- IF INDIRECT(current_cell) <= 60
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
- ELSE
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
- END IF
- PUT d1 + decimal INTO current_cell
- END IF { a date format }
- current_row = current_row + 1
- END WHILE { rows }
- current_row = 1
- current_col = current_col + 1
- END WHILE { columns }
- GO TO CELL MAKECELL(starting_col,starting_row)
- IF (num_formula_cells > 0)
- MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
- "containing either formulas or text strings were found in " &
- "this worksheet. These cells and their contents are listed " &
- "in the worksheet ""Formulas.wkz"". You must manually verify " &
- "the correct operations of these cells."
- GO TO WINDOW sheet_name
- WINDOW LOCATION (0,0)
- WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
- GO TO WINDOW "Formulas.wkz"
- WINDOW LOCATION (.75 * DESKRIGHT(), 0)
- WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
- GO TO CELL A1
- COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
- COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
- END IF { if formula or text cells found }
- AUTO MOVE
- REPAINT ON
- REPAINT ALL WINDOWS
- MESSAGE "The conversion has been completed!"
- END IF { worksheet loaded }
- END FUNCTION { End of function DateConv_FI () }
- {===============================================================================
- FUNCTION NAME
- CheckForDateFormulas
- DESCRIPTION
- This function checks the current cell for date related functions and if
- they exist, the name of the cell is placed in the worksheet Formulas.wkz.
- RETURNS
- Nothing.
- PARAMETERS
- current_format - the format of the cell as determined by the formula
- BITAND(FORMAT(), 240).
- the_cell - the cell being checked expressed as a string.
- NOTES
- None.
- HISTORY
- 03/10/89 - JVR - Initial code.
- ===============================================================================}
- FUNCTION CheckForDateFormulas (current_format, the_cell)
- DEFINE cell_formula,
- formula_flag
- formula_flag = 0
- cell_formula = ""
- IF (current_format = 80) OR (current_format = 96) OR (current_format = 112) OR
- (current_format = 128) OR (current_format = 144)
- IF (ISERR(FORMULATEXT(RANGE(the_cell))) = 0)
- cell_formula = UPPER(FORMULATEXT(RANGE(the_cell)))
- ELSE { else must be text }
- cell_formula = CELLTEXT(RANGE(the_cell))
- END IF
- formula_flag = 1
- ELSEIF (current_format = 0) OR (current_format = 16)
- IF (ISERR(FORMULATEXT(RANGE(the_cell))) = 0)
- cell_formula = UPPER(FORMULATEXT(RANGE(the_cell)))
- IF (CONTAINS(cell_formula, "ADATE"))
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDDAYS")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDHOURS")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDMINUTES")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDMONTHS")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "DAY")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "DAYNAME")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "HOUR")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "MINUTE")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDSECONDS")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ADDYEARS")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "ATIME")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "MONTH")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "MONTHNAME")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "NOW")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "SECOND")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "YEAR")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "DATEVALUE")
- formula_flag = 1
- ELSEIF CONTAINS(cell_formula, "DATE")
- formula_flag = 1
- END IF { formula contains a date keyword }
- END IF { cell contains a formula }
- END IF { date format }
- IF (formula_flag)
- IF (num_formula_cells = 0)
- NEW WORKSHEET "Formulas.wkz" LOCATION
- (DESKRIGHT(), DESKBOTTOM()) + (1440, 1440)
- HIDE ENTRY BAR
- HIDE TOOL BOX
- HIDE HEADINGS
- num_formula_cells = num_formula_cells + 1
- END IF { if first formula cell found create hidden sheet }
- GO TO WINDOW "Formulas.wkz"
- PUT current_cell INTO MAKECELL(1, num_formula_cells)
- PUT """" & cell_formula & """" INTO MAKECELL(2, num_formula_cells)
- GO TO CELL MAKECELL(1, num_formula_cells)
- ALIGN CENTER
- num_formula_cells = num_formula_cells + 1
- GO TO WINDOW sheet_name
- END IF { formula found so add to Formulas.wkz worksheet }
- END FUNCTION { CheckForDateFormulas }
- {===============================================================================
- FUNCTION NAME
- CustomDates
- DESCRIPTION
- This function checks the current cell for cells formatted with the
- standard date formats from Excel. These are m/d/yy,d-mmm-yy,d-mmm,
- mmm-yy,m/d/yy h:mm. When Wingz converts a SYLK file from Excel, it
- will create Excel's standard date formats as custom formats. This
- is not valid with files saved as WK1 or WKS.
- RETURNS
- Nothing.
- PARAMETERS
- None
- NOTES
- None.
- HISTORY
- 02/22/90 - KHB - Initial code.
- ===============================================================================}
- FUNCTION CustomDates ()
- DEFINE fmt,
- isdate,
- pos,
- len,
- i,
- start_pos,
- end_pos,
- new_fmt
- fmt = LOWER(CUSTOMFORMAT())
- len = LENGTH(fmt)
- start_pos = 0
- end_pos = 0
- { If format string has a literal, strip out the literal and leave
- the formatting chars. }
- FOR i = 0 TO len-1
- IF CODE(MID(fmt,i,1)) = 34
- IF start_pos = 0
- start_pos = i + 1
- ELSE
- end_pos = i + 1
- END IF
- END IF
- END FOR
- new_fmt = LEFT(fmt,start_pos-1) & " " & MID(fmt,end_pos,len)
- isdate = 0
- IF MATCH(new_fmt,"d",1) <> 0 { If new_fmt contains a d, dd, ddd, dddd, it's a date format. }
- IF (CONTAINS(new_fmt,"d") = 1) OR (CONTAINS(new_fmt,"dd") = 1) OR
- (CONTAINS(new_fmt,"ddd") = 1) OR (CONTAINS(new_fmt,"dddd") = 1)
- isdate = 1
- END IF
- ELSEIF MATCH(new_fmt,"y",1) <> 0 { If new_fmt contains a yy or yyyy, it's a date format. }
- IF (CONTAINS(new_fmt,"yy") = 1) OR (CONTAINS(new_fmt,"yyyy") = 1)
- isdate = 1
- END IF
- ELSEIF MATCH(new_fmt,"m",1) <> 0
- { If format string contains "mmm" or "mmmm", then date format involved. }
- IF ((CONTAINS(new_fmt,"mmm") = 1) OR (CONTAINS(new_fmt,"mmmm") = 1))
- isdate = 1
- ELSEIF ((CONTAINS(new_fmt,"m") = 1) OR (CONTAINS(new_fmt,"mm") = 1))
- { Format string might contain time as well as date formatting,
- so prompt user if they want to convert, else do the conversion. }
- IF (CONTAINS(new_fmt,"h") = 1) OR (CONTAINS(new_fmt,"s") = 1)
- { If serial number < 1, do not convert }
- IF INT(INDIRECT(current_cell)) = 0
- isdate = 0
- ELSE
- isdate = Convert (fmt)
- END IF
- REPAINT OFF
- ELSE
- isdate = 1
- END IF
- END IF
- ELSEIF MATCH(new_fmt,"h",1) <> 0 { If new_fmt contains a h or hh, it's a time format. }
- IF (CONTAINS(new_fmt,"h") = 1) OR (CONTAINS(new_fmt,"hh") = 1)
- { If serial number < 1, do not convert }
- IF INT(INDIRECT(current_cell)) = 0
- isdate = 0
- ELSE
- isdate = Convert (fmt)
- END IF
- END IF
- ELSEIF MATCH(new_fmt,"s",1) <> 0 { If new_fmt contains an s or ss, it's a time format. }
- IF (CONTAINS(new_fmt,"s") = 1) OR (CONTAINS(new_fmt,"ss") = 1)
- { If serial number < 1, do not convert }
- IF INT(INDIRECT(current_cell)) = 0
- isdate = 0
- ELSE
- isdate = Convert (fmt)
- END IF
- END IF
- END IF
- IF isdate { If the format is a date string. }
- decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
- IF INDIRECT(current_cell) <= 60
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
- ELSE
- d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
- END IF
- PUT d1 + decimal INTO current_cell
- END IF
- END FUNCTION { END OF FUNCTION CustomDates () }
- {==========================================================================
- FUNCTION NAME
- Convert
- DESCRIPTION
- This function prompts the user whether or not to convert the number
- based on the displayed custom format. The reason for this is that
- time formats and date formats have the letter "m" in common, and
- date and time format strings can be used in conjunction with one
- another.
- RETURNS
- 1 - Convert the number
- 0 - Do not convert the number
- PARAMETERS
- None
- NOTES
- None.
- HISTORY
- 02/22/90 - KHB - Initial code.
- ==========================================================================}
- FUNCTION Convert (fmt)
- IF global
- RETURN 1
- END IF
- NEW MODAL DIALOG BOX AT (-1,-1) (5500,2000) NAME DIALOG BOX "DateConverter"
- ADD PUSH BUTTON "Convert All","No","Yes" AT (0,1500) (5500,1850)
- DIALOG DEFAULT PUSH BUTTON
- SCRIPT "DateConv.scz:duit = 1"
- SELECT CONTROL 2
- DIALOG CANCEL PUSH BUTTON
- SCRIPT "DateConv.scz:duit = 0"
- SELECT CONTROL 1
- SCRIPT "DateConv.scz:global = 1;quit dialog box"
- ADD TEXT "Convert '" & INDIRECT(current_cell) & "' formatted as '" & fmt
- & "', or globally convert all?" at (100,100) (5400,1300)
- NO LINE BORDER
- USE DIALOG BOX
- RETURN duit
- END FUNCTION { END OF FUNCTION Convert () }
- FUNCTION Draw_Logo ()
- VIEWPORT (0,0) (1,1)
- SCALED WINDOW (0,0) (15,15)
- FILL FG GREY()
- FILL PATTERN 1
- FILL FG GREY()
- FILL RECTANGLE (1.5,6.5) (14.5,9)
- MOVE (1.5,12.5)
- OPEN POLYGON
- DRAW (14.5,12.5)
- DRAW (8,.5)
- DRAW (1.5,12.5)
- CLOSE POLYGON
- FILL POLYGON
- KILL POLYGON
- FILL FG blue()
- FILL PATTERN 1
- LINE FG BLACK()
- MOVE (1,13)
- OPEN POLYGON
- DRAW (14,13)
- DRAW (7.5,1)
- DRAW (1,13)
- CLOSE POLYGON
- FILL POLYGON
- KILL POLYGON
- FILL FG WHITE()
- TEXT COLOR WHITE()
- TEXT FONT "Tms Rmn"
- TEXT SIZE 18
- MOVE (3.7,10.1)
- DRAW TEXT "W"
- MOVE (9.3,10.1)
- DRAW TEXT "Z"
- TEXT SIZE 14
- MOVE (6,10.44)
- DRAW TEXT "ING"
- TEXT SIZE 14
- TEXT FONT "Tms Rmn"
- MOVE (11.2,11.1)
- TEXT SIZE 8
- DRAW TEXT "TM"
- PAINT RECTANGLE (1,7) (14,9.5)
- TEXT COLOR BLACK()
- TEXT STYLE "SB"
- TEXT SIZE 12
- MOVE (2,7.5)
- DRAW TEXT "Date Converter"
- END FUNCTION
- ON ERROR
- END ERROR
-