home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / b / b430 / 1.ddi / UTILS / DATECONV / DATECONV.SCZ (.txt) next >
Encoding:
Wingz Script  |  1990-06-15  |  30.3 KB  |  769 lines

  1. WNGZWZSC0110
  2. Excel
  3. Lotus
  4. Full Impact
  5. File Source
  6. Cancel
  7. 6DateConv.scz:duit = 1;DateConv.scz:type = CTVALUE(1,0)
  8. 4ON REPAINT CALL DateConv.scz:DRAW_LOGO() END REPAINT
  9. Formulas.wkz
  10. Formulas.wkz9
  11. BYou MUST open a Microsoft Excel WKS or WK1 sheet before beginning!
  12.  date formatted cell(s) 5
  13. 9containing either formulas or text strings were found in 5
  14. ;this worksheet.  These cells and their contents are listed 5
  15. ;in the worksheet "Formulas.wkz".  You must manually verify 5
  16. &the correct operations of these cells.5
  17. Formulas.wkz
  18. "The conversion has been completed!
  19. Formulas.wkz
  20. Formulas.wkz9
  21. >You MUST open a Lotus 1-2-3 WKS or WK1 sheet before beginning!
  22.  date formatted cell(s) 5
  23. 9containing either formulas or text strings were found in 5
  24. ;this worksheet.  These cells and their contents are listed 5
  25. ;in the worksheet "Formulas.wkz".  You must manually verify 5
  26. &the correct operations of these cells.5
  27. Formulas.wkz
  28. "The conversion has been completed!
  29. Formulas.wkz
  30. Formulas.wkz9
  31. JYou MUST open a Ashton-Tate Full Impact WKS or WK1 sheet before beginning!
  32.  date formatted cell(s) 5
  33. 9containing either formulas or text strings were found in 5
  34. ;this worksheet.  These cells and their contents are listed 5
  35. ;in the worksheet "Formulas.wkz".  You must manually verify 5
  36. &the correct operations of these cells.5
  37. Formulas.wkz
  38. "The conversion has been completed!
  39. ADATE
  40. ADDDAYS
  41. ADDHOURS
  42. ADDMINUTES
  43.     ADDMONTHS
  44. DAYNAME
  45. MINUTE
  46. ADDSECONDS
  47. ADDYEARS
  48. ATIME
  49. MONTH
  50.     MONTHNAME
  51. SECOND
  52.     DATEVALUE
  53. Formulas.wkz
  54. Formulas.wkz
  55. DateConverter
  56. Convert All
  57. DateConv.scz:duit = 1
  58. DateConv.scz:duit = 0
  59. 'DateConv.scz:global = 1;quit dialog box
  60.     Convert '
  61. ' formatted as '5
  62. ', or globally convert all?5
  63. Tms Rmn
  64. 433333$@
  65. 433333$@
  66. Tms Rmn
  67. gfffff&@
  68. 433333&@
  69. Date Converter
  70. cell_format
  71. current_row
  72. current_col
  73. num_rows
  74. num_cols
  75. starting_row
  76. starting_col
  77. show_help
  78. open_sheet    
  79. begin_adjustments
  80. abort
  81. sheet_name
  82. current_cell
  83. num_formula_cells
  84. global
  85. decimal
  86. DateConv_Excp
  87. DateConv_123.
  88. DateConv_FI
  89. CheckForDateFormulas%
  90. CustomDates
  91. Convert
  92. Draw_LogoZ
  93. {==========================================================================
  94. PROGRAM NAME
  95.     DateConv
  96. COPYRIGHT INFORMATION
  97.     Lotus and 1-2-3 are registered trademarks of Lotus Development
  98.     Corporation. Microsoft and Excel are registered trademarks of
  99.     Microsoft Corporation. Ashton-Tate and Full Impact are registered
  100.     trademarks of the Ashton-Tate Corporation.
  101. DESCRIPTION
  102.     This script aids the user in converting date serial numbers from
  103.     foreign file formats to Wingz' date serial numbering scheme.
  104. LIBRARY MODULES
  105.     DateConv_Exc () - Function for converting Excel files.
  106.     DateConv_123 () - Function for converting Lotus files.
  107.     DateConv_FI () - Function for converting Full Impact files.
  108.     CheckForDateFormulas () - This function checks the current cell
  109.         for date related functions and if    they exist, the name of
  110.         the cell is placed in the worksheet Formulas.wkz.
  111.     CustomDates () - This function checks the current cell for cells
  112.         formatted    with the standard date formats from Excel.  These
  113.         are m/d/yy, d-mmm-yy, d-mmm,mmm-yy, m/d/yy h:mm. When Wingz
  114.         converts a SYLK file from Excel, it will create Excel's
  115.         standard date formats as custom formats.  This is not valid
  116.         with files saved as WK1 or WKS.
  117.     Convert () - This function prompts the user whether or not to
  118.         convert the number based on the displayed custom format.
  119.         The reason for this is that time formats and date formats
  120.         have the letter "m" in common, and    date and time format
  121.         strings can be used in conjunction with one another.
  122. NOTES
  123.     None.
  124. HISTORY
  125.     03/27/90 - KHB - Initial code.
  126. ==========================================================================}
  127. DEFINE     cell_format,
  128.         current_row,
  129.         current_col,
  130.         num_rows,
  131.         num_cols,
  132.         d1,
  133.         starting_row,
  134.         starting_col,
  135.         show_help,
  136.         open_sheet,
  137.         begin_adjustments,
  138.         abort,
  139.         sheet_name,
  140.         current_cell,
  141.         num_formula_cells,
  142.         duit,
  143.         global,
  144.         decimal,
  145.         type
  146. NEW MODAL DIALOG BOX AT (-1,-1) (6500,3100)
  147. ADD RADIO BUTTON "Excel","Lotus","Full Impact" AT (3200,210) (6300,2000)
  148. SHOW CONTROL TITLE "File Source"
  149. ADD PUSH BUTTON "OK","Cancel" AT (3200,2350) (6300,2750)
  150. DIALOG CANCEL PUSH BUTTON
  151. SELECT CONTROL 2
  152. DIALOG DEFAULT PUSH BUTTON
  153. SCRIPT "DateConv.scz:duit = 1;DateConv.scz:type = CTVALUE(1,0)"
  154. ADD CUSTOM BUTTON AT (0,0) (3000,3000)
  155. DISABLE CONTROL
  156. SCRIPT "ON REPAINT CALL DateConv.scz:DRAW_LOGO() END REPAINT"    
  157. NO LINE BORDER
  158. USE DIALOG BOX
  159. IF duit
  160.     CASE type
  161.         WHEN 1
  162.             CALL DateConv_Exc ()
  163.         WHEN 2
  164.             CALL DateConv_123 ()
  165.         WHEN 3
  166.             CALL DateConv_FI ()
  167.     END CASE
  168. END IF
  169. {==========================================================================
  170. FUNCTION NAME
  171.     DateConv_Exc
  172. DESCRIPTION
  173.     This function will correct dates in WKS, WK1, and SYLK files
  174.     generated by Microsoft Excel version 1.5, as well as version
  175.     2.2 files with the starting date option of 1904.
  176. NOTES
  177.     This function is necessary because Excel does not follow the
  178.     convention established by Lotus for date serial numbers.
  179.     Instead, Excel begins it's date series with 0 on Jan 1, 1904.
  180.     Excel fails to read and write Lotus 1-2-3 generated WK1 or WKS
  181.     files correctly.  It performs no translations on the date
  182.     numbers as they are read in.  This situation causes Excel to
  183.     be 4 years and 1 day ahead of Lotus 1-2-3 AND Wingz.  If the
  184.     date from Excel is before March 1,    1904, then the date is 4
  185.     years and two days off.  For example, if Lotus 1-2-3 and 
  186.     Wingz believe that it is March 6, 1989, Excel believes that
  187.     it is March 7, 1993.
  188. HISTORY
  189.     03/07/89 - KHB - Initial code.
  190.     03/10/89 - JVR - Enhanced module formatting.
  191.     05/13/89 - HLG - Removed the user interface from DateConv and
  192.                   broke it down into 3 separate scripts:
  193.                     DateConv.Exc - to correct dates in WKS, WK1,
  194.                                 and SYLK files generated by
  195.                                 Microsoft Excel.
  196.                     DateConv.123 - to correct dates in WKS & WK1
  197.                                 files generated by Lotus 1-2-3.
  198.                     DateConv.FI  - to correct dates in WKS & WK1
  199.                                 files generated by Ashton-Tate
  200.                                 Full Impact.
  201.     02/22/90 - KHB - Added code to recognize and convert custom formats.
  202.                   Added capability to retain decimal portion of the
  203.                   date.  serial number and discarded variable d2 by
  204.                   combining the adddays and the addyears into one
  205.                   equation.
  206.     03/27/90 - KHB - Believe it or not, the three scripts were merged
  207.                   again into 1.
  208.       05/06/90 - DAB - Ported to Windows 3.0
  209. ==========================================================================}
  210. FUNCTION DateConv_Exc ()
  211.     num_formula_cells = 0
  212.     GO TO WINDOW "Formulas.wkz"
  213.     IF NAME() = "Formulas.wkz"
  214.         CLOSE NOW
  215.     END IF { Formulas.wkz already exists }
  216.     IF (ISERR(NAME()))
  217.         MESSAGE "You MUST open a Microsoft Excel WKS or WK1 sheet before beginning!"
  218.     ELSE { valid name }
  219.         sheet_name = NAME()
  220.         REPAINT OFF
  221.         NO AUTO MOVE
  222.         SELECT ACTIVE CELLS
  223.         num_rows = ROWS(SELECTION(1))
  224.         num_cols = COLS(SELECTION(1))
  225.         starting_row = ROW()
  226.         starting_col = COL()
  227.         current_row = 1
  228.         current_col = 1
  229.         UNSELECT
  230.         WHILE (current_col <= num_cols)
  231.             WHILE (current_row <= num_rows)
  232.                 current_cell = MAKECELL(current_col, current_row)
  233.                 GO TO CELL current_cell
  234.                 cell_format = BITAND(FORMAT(), 240) 
  235.                 { Check for formulas or text dates.  If so, do not change }
  236.                 IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR 
  237.                    (ISSTRING(INDIRECT(current_cell)) = 1)  
  238.                     current_row = current_row + 1
  239.                     CALL CheckForDateFormulas (cell_format, current_cell)
  240.                     CONTINUE WHILE
  241.                 END IF { a formula or text date }
  242.                 { Check if cell is formatted with one of Excel's standard date formats. }
  243.                 IF (cell_format = 224)
  244.                     current_row = current_row + 1
  245.                     CALL CustomDates ()
  246.                     CONTINUE WHILE
  247.                 END IF { a standard Excel date format }
  248.                 IF (cell_format = 80) OR (cell_format = 96) OR 
  249.                    (cell_format = 112) OR (cell_format = 128) OR 
  250.                    (cell_format = 144)
  251.                     decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
  252.                     IF INDIRECT(current_cell) <= 60
  253.                         d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
  254.                     ELSE
  255.                         d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
  256.                     END IF
  257.                     PUT d1 + decimal INTO current_cell
  258.                 END IF { a date format }
  259.                 current_row = current_row + 1
  260.             END WHILE { rows }
  261.             current_row = 1
  262.             current_col = current_col + 1
  263.         END WHILE { columns }
  264.         GO TO CELL MAKECELL(starting_col,starting_row)
  265.         IF (num_formula_cells > 0)
  266.             MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
  267.                 "containing either formulas or text strings were found in " &
  268.                 "this worksheet.  These cells and their contents are listed " &
  269.                 "in the worksheet ""Formulas.wkz"".  You must manually verify " &
  270.                 "the correct operations of these cells."
  271.             GO TO WINDOW sheet_name
  272.             WINDOW LOCATION (0,0)
  273.             WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
  274.             GO TO WINDOW "Formulas.wkz"
  275.             WINDOW LOCATION (.75 * DESKRIGHT(), 0)
  276.             WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
  277.             GO TO CELL A1
  278.             COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
  279.             COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
  280.         END IF { if formula or text cells found }
  281.         AUTO MOVE
  282.         REPAINT ON
  283.         REPAINT ALL WINDOWS
  284.         MESSAGE "The conversion has been completed!"
  285.     END IF { worksheet loaded }
  286. END FUNCTION { End of function DateConv_Exc () }
  287. {==============================================================================
  288. FUNCTION NAME
  289.     DateConv_123
  290. DESCRIPTION
  291.     This function will correct dates in WKS & WK1 files generated by   
  292.     Lotus 1-2-3.
  293. NOTES
  294.     This function is necessary because Lotus 1-2-3  believes that 1900
  295.     is a    leap year and so counts February 29, 1900 as a legitimate date.
  296.     This is not so.  The rule for leap years is that they are every year
  297.     evenly divisible by four except for centesimal years (1800, 1900, 2000)
  298.     unless the centesimal year is evenly divisible by 400.  That is why
  299.     the year 2000 will be a leap year but 1900 was not.
  300. HISTORY
  301.     03/07/89 - KHB - Initial code.
  302.     03/10/89 - JVR - Enhanced module formatting.
  303.     05/13/89 - HLG - Removed the user interface from DateConv and broke
  304.                   it down into 3 separate scripts:
  305.                     DateConv.Exc - to correct dates in WKS & WK1 files 
  306.                                 generated by Microsoft Excel.
  307.                     DateConv.123 - to correct dates in WKS & WK1 files 
  308.                                 generated by Lotus 1-2-3.
  309.                     DateConv.FI  - to correct dates in WKS & WK1 files 
  310.                                 generated by Ashton-Tate Full Impact.
  311.     03/27/90 - KHB - Believe it or not, the three scripts were merged
  312.                   again into 1.
  313. ===============================================================================}
  314. FUNCTION DateConv_123 ()
  315.     num_formula_cells = 0
  316.     GO TO WINDOW "Formulas.wkz"
  317.     IF NAME() = "Formulas.wkz"
  318.         CLOSE NOW
  319.     END IF { Formulas.wkz already exists }
  320.     IF (ISERR(NAME()))
  321.         MESSAGE "You MUST open a Lotus 1-2-3 WKS or WK1 sheet before beginning!"
  322.     ELSE { valid name }
  323.         sheet_name = NAME()
  324.         REPAINT OFF
  325.         NO AUTO MOVE
  326.         SELECT ACTIVE CELLS
  327.         num_rows = ROWS(SELECTION(1))
  328.         num_cols = COLS(SELECTION(1))
  329.         starting_row = ROW()
  330.         starting_col = COL()
  331.         current_row = 1
  332.         current_col = 1
  333.         UNSELECT
  334.         WHILE (current_col <= num_cols)
  335.             WHILE (current_row <= num_rows)
  336.                 current_cell = MAKECELL(current_col, current_row)
  337.                 GO TO CELL current_cell
  338.                 cell_format = BITAND(FORMAT(), 240) 
  339.                 { Check for formulas or text dates.  If so, do not change }
  340.                 IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR 
  341.                    (ISSTRING(INDIRECT(current_cell)) = 1)  
  342.                     current_row = current_row + 1
  343.                     CALL CheckForDateFormulas (cell_format, current_cell)
  344.                     CONTINUE WHILE
  345.                 END IF
  346.                 IF (cell_format = 80) OR (cell_format = 96) OR 
  347.                    (cell_format = 112) OR (cell_format = 128) OR 
  348.                    (cell_format = 144)
  349.                     IF INDIRECT(current_cell) <= 59
  350.                         d1 = ADDDAYS(INDIRECT(current_cell),1) 
  351.                         PUT d1 INTO current_cell
  352.                     END IF
  353.                 END IF { a date format }
  354.                 current_row = current_row + 1
  355.             END WHILE { rows }
  356.             current_row = 1
  357.             current_col = current_col + 1
  358.         END WHILE { columns }
  359.         GO TO CELL MAKECELL(starting_col,starting_row)
  360.         IF (num_formula_cells > 0)
  361.             MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
  362.                 "containing either formulas or text strings were found in " &
  363.                 "this worksheet.  These cells and their contents are listed " &
  364.                 "in the worksheet ""Formulas.wkz"".  You must manually verify " &
  365.                 "the correct operations of these cells."
  366.             GO TO WINDOW sheet_name
  367.             WINDOW LOCATION (0,0)
  368.             WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
  369.             GO TO WINDOW "Formulas.wkz"
  370.             WINDOW LOCATION (.75 * DESKRIGHT(), 0)
  371.             WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
  372.             GO TO CELL A1
  373.             COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
  374.             COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
  375.         END IF { if formula or text cells found }
  376.         AUTO MOVE
  377.         REPAINT ON
  378.         REPAINT ALL WINDOWS
  379.         MESSAGE "The conversion has been completed!"
  380.     END IF { worksheet loaded }
  381. END FUNCTION { End of function DateConv_123 () }
  382. {==============================================================================
  383. PROGRAM NAME
  384.     DateConv.FI
  385. DESCRIPTION
  386.     This function will correct dates in WKS & WK1 files generated by   
  387.     Ashton-Tate Full Impact.
  388. NOTES
  389.     This function is necessary because Full Impact does not follow the
  390.     convention established by Lotus for date serial numbers.  Instead,
  391.     Full Impact begins it's date series with 0 on Jan 1, 1904.  Full
  392.     Impact fails to read and write Lotus 1-2-3 generated WK1 or WKS
  393.     files correctly.  It performs no translations on the date numbers
  394.     as they are read in.  This situation causes Full Impact to be 4 years 
  395.     and 1 day ahead of Lotus 1-2-3 AND Wingz. If the date from Full
  396.     Impact is before March 1, 1904, then the date is 4 years and two
  397.     days off.  For example, if Lotus 1-2-3 and Wingz believe that it
  398.     is March 6, 1989, Full Impact believes that it is March 7, 1993.
  399. HISTORY
  400.     03/07/89 - KHB - Initial code.
  401.     03/10/89 - JVR - Enhanced module formatting.
  402.     05/13/89 - HLG - Removed the user interface from DateConv and broke
  403.                   it down into 3 separate scripts:
  404.                     DateConv.Exc - to correct dates in WKS & WK1 files 
  405.                                 generated by Microsoft Excel.
  406.                     DateConv.123 - to correct dates in WKS & WK1 files 
  407.                                 generated by Lotus 1-2-3.
  408.                     DateConv.FI  - to correct dates in WKS & WK1 files 
  409.                                 generated by Ashton-Tate Full Impact.
  410.     02/23/90 - KHB - Added capability to retain decimal portion of the date
  411.                     serial number and discarded variable d2 by combining
  412.                     the adddays and the addyears into one equation.
  413.     03/27/90 - KHB - Believe it or not, the three scripts were merged
  414.                   again into 1.
  415.   ===============================================================================}
  416. FUNCTION DateConv_FI ()
  417.     num_formula_cells = 0
  418.     GO TO WINDOW "Formulas.wkz"
  419.     IF NAME() = "Formulas.wkz"
  420.         CLOSE NOW
  421.     END IF { Formulas.wkz already exists }
  422.     IF (ISERR(NAME()))
  423.         MESSAGE "You MUST open a Ashton-Tate Full Impact WKS or WK1 sheet before beginning!"
  424.     ELSE { valid name }
  425.         sheet_name = NAME()
  426.         REPAINT OFF
  427.         NO AUTO MOVE
  428.         SELECT ACTIVE CELLS
  429.         num_rows = ROWS(SELECTION(1))
  430.         num_cols = COLS(SELECTION(1))
  431.         starting_row = ROW()
  432.         starting_col = COL()
  433.         current_row = 1
  434.         current_col = 1
  435.         UNSELECT
  436.         WHILE (current_col <= num_cols)
  437.             WHILE (current_row <= num_rows)
  438.                 current_cell = MAKECELL(current_col, current_row)
  439.                 GO TO CELL current_cell
  440.                 cell_format = BITAND(FORMAT(), 240) 
  441.                 { Check for formulas or text dates.  If so, do not change }
  442.                 IF (ISERR(FORMULATEXT(RANGE(current_cell))) = 0) OR 
  443.                    (ISSTRING(INDIRECT(current_cell)) = 1)  
  444.                     current_row = current_row + 1
  445.                     CALL CheckForDateFormulas (cell_format, current_cell)
  446.                     CONTINUE WHILE
  447.                 END IF
  448.                 IF (cell_format = 80) OR (cell_format = 96) OR 
  449.                    (cell_format = 112) OR (cell_format = 128) OR 
  450.                    (cell_format = 144)
  451.                     decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
  452.                     IF INDIRECT(current_cell) <= 60
  453.                         d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
  454.                     ELSE
  455.                         d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
  456.                     END IF
  457.                     PUT d1 + decimal INTO current_cell
  458.                 END IF { a date format }
  459.                 current_row = current_row + 1
  460.             END WHILE { rows }
  461.             current_row = 1
  462.             current_col = current_col + 1
  463.         END WHILE { columns }
  464.         GO TO CELL MAKECELL(starting_col,starting_row)
  465.         IF (num_formula_cells > 0)
  466.             MESSAGE STRING(num_formula_cells - 1, 0) & " date formatted cell(s) " &
  467.                 "containing either formulas or text strings were found in " &
  468.                 "this worksheet.  These cells and their contents are listed " &
  469.                 "in the worksheet ""Formulas.wkz"".  You must manually verify " &
  470.                 "the correct operations of these cells."
  471.             GO TO WINDOW sheet_name
  472.             WINDOW LOCATION (0,0)
  473.             WINDOW SIZE (.75 * DESKRIGHT(), DESKBOTTOM())
  474.             GO TO WINDOW "Formulas.wkz"
  475.             WINDOW LOCATION (.75 * DESKRIGHT(), 0)
  476.             WINDOW SIZE (.25 * DESKRIGHT(), DESKBOTTOM())
  477.             GO TO CELL A1
  478.             COLUMN WIDTH RANGE A1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .25)
  479.             COLUMN WIDTH RANGE B1 TO ((.25 * DESKRIGHT() - (1440 * .25)) * .75)
  480.         END IF { if formula or text cells found }
  481.         AUTO MOVE
  482.         REPAINT ON
  483.         REPAINT ALL WINDOWS
  484.         MESSAGE "The conversion has been completed!"
  485.     END IF { worksheet loaded }
  486. END FUNCTION { End of function DateConv_FI () }
  487. {===============================================================================
  488. FUNCTION NAME
  489.     CheckForDateFormulas
  490. DESCRIPTION
  491.     This function checks the current cell for date related functions and if
  492.     they exist, the name of the cell is placed in the worksheet Formulas.wkz.
  493. RETURNS
  494.     Nothing.
  495. PARAMETERS
  496.     current_format - the format of the cell as determined by the formula
  497.                    BITAND(FORMAT(), 240).
  498.     the_cell        - the cell being checked expressed as a string.
  499. NOTES
  500.     None.
  501. HISTORY
  502.     03/10/89 - JVR - Initial code.
  503. ===============================================================================}
  504. FUNCTION CheckForDateFormulas (current_format, the_cell)
  505. DEFINE    cell_formula,
  506.         formula_flag
  507.     formula_flag = 0
  508.     cell_formula = ""
  509.     IF (current_format = 80) OR (current_format = 96) OR (current_format = 112) OR 
  510.         (current_format = 128) OR (current_format = 144)
  511.         IF (ISERR(FORMULATEXT(RANGE(the_cell))) = 0)
  512.             cell_formula = UPPER(FORMULATEXT(RANGE(the_cell)))
  513.         ELSE { else must be text }
  514.             cell_formula = CELLTEXT(RANGE(the_cell)) 
  515.         END IF
  516.         formula_flag = 1
  517.     ELSEIF (current_format = 0) OR (current_format = 16)
  518.         IF (ISERR(FORMULATEXT(RANGE(the_cell))) = 0)
  519.             cell_formula = UPPER(FORMULATEXT(RANGE(the_cell)))
  520.             IF (CONTAINS(cell_formula, "ADATE"))
  521.                 formula_flag = 1
  522.             ELSEIF CONTAINS(cell_formula, "ADDDAYS")
  523.                 formula_flag = 1
  524.             ELSEIF CONTAINS(cell_formula, "ADDHOURS")
  525.                 formula_flag = 1
  526.             ELSEIF CONTAINS(cell_formula, "ADDMINUTES")
  527.                 formula_flag = 1
  528.             ELSEIF CONTAINS(cell_formula, "ADDMONTHS")
  529.                 formula_flag = 1
  530.             ELSEIF CONTAINS(cell_formula, "DAY")
  531.                 formula_flag = 1
  532.             ELSEIF CONTAINS(cell_formula, "DAYNAME")
  533.                 formula_flag = 1
  534.             ELSEIF CONTAINS(cell_formula, "HOUR")
  535.                 formula_flag = 1
  536.             ELSEIF CONTAINS(cell_formula, "MINUTE")
  537.                 formula_flag = 1
  538.             ELSEIF CONTAINS(cell_formula, "ADDSECONDS")
  539.                 formula_flag = 1
  540.             ELSEIF CONTAINS(cell_formula, "ADDYEARS")
  541.                 formula_flag = 1
  542.             ELSEIF CONTAINS(cell_formula, "ATIME")
  543.                 formula_flag = 1
  544.             ELSEIF CONTAINS(cell_formula, "MONTH")
  545.                 formula_flag = 1
  546.             ELSEIF CONTAINS(cell_formula, "MONTHNAME")
  547.                 formula_flag = 1
  548.             ELSEIF CONTAINS(cell_formula, "NOW")
  549.                 formula_flag = 1
  550.             ELSEIF CONTAINS(cell_formula, "SECOND")
  551.                 formula_flag = 1
  552.             ELSEIF CONTAINS(cell_formula, "YEAR")
  553.                 formula_flag = 1
  554.             ELSEIF CONTAINS(cell_formula, "DATEVALUE")
  555.                 formula_flag = 1
  556.             ELSEIF CONTAINS(cell_formula, "DATE")
  557.                 formula_flag = 1
  558.             END IF { formula contains a date keyword }
  559.         END IF { cell contains a formula }
  560.     END IF { date format }
  561.     IF (formula_flag)
  562.         IF (num_formula_cells = 0)
  563.             NEW WORKSHEET "Formulas.wkz" LOCATION 
  564.                             (DESKRIGHT(), DESKBOTTOM()) + (1440, 1440)
  565.             HIDE ENTRY BAR
  566.             HIDE TOOL BOX
  567.             HIDE HEADINGS
  568.             num_formula_cells = num_formula_cells + 1
  569.         END IF { if first formula cell found create hidden sheet }
  570.         GO TO WINDOW "Formulas.wkz"
  571.         PUT current_cell INTO MAKECELL(1, num_formula_cells)
  572.         PUT """" & cell_formula & """" INTO MAKECELL(2, num_formula_cells)
  573.         GO TO CELL MAKECELL(1, num_formula_cells)
  574.         ALIGN CENTER
  575.         num_formula_cells = num_formula_cells + 1
  576.         GO TO WINDOW sheet_name
  577.     END IF { formula found so add to Formulas.wkz worksheet }
  578. END FUNCTION { CheckForDateFormulas }
  579. {===============================================================================
  580. FUNCTION NAME
  581.     CustomDates
  582. DESCRIPTION
  583.     This function checks the current cell for cells formatted with the
  584.     standard date formats from Excel.  These are m/d/yy,d-mmm-yy,d-mmm,
  585.     mmm-yy,m/d/yy h:mm. When Wingz converts a SYLK file from Excel, it
  586.     will create Excel's standard date formats as custom formats.  This
  587.     is not valid with files saved as WK1 or WKS.
  588. RETURNS
  589.     Nothing.
  590. PARAMETERS
  591.     None
  592. NOTES
  593.     None.
  594. HISTORY
  595.     02/22/90 - KHB - Initial code.
  596. ===============================================================================}
  597. FUNCTION CustomDates ()
  598.     DEFINE     fmt,
  599.             isdate,
  600.             pos,
  601.             len,
  602.             i,
  603.             start_pos,
  604.             end_pos,
  605.             new_fmt
  606.     fmt = LOWER(CUSTOMFORMAT())
  607.     len = LENGTH(fmt)
  608.     start_pos = 0
  609.     end_pos = 0
  610.     { If format string has a literal, strip out the literal and leave
  611.       the formatting chars. }
  612.     FOR i = 0 TO len-1
  613.         IF CODE(MID(fmt,i,1)) = 34
  614.             IF start_pos = 0 
  615.                 start_pos = i + 1
  616.             ELSE
  617.                 end_pos = i + 1
  618.             END IF
  619.         END IF
  620.     END FOR
  621.     new_fmt = LEFT(fmt,start_pos-1) & " " & MID(fmt,end_pos,len)
  622.     isdate = 0
  623.     IF MATCH(new_fmt,"d",1) <> 0 { If new_fmt contains a d, dd, ddd, dddd, it's a date format. }
  624.         IF (CONTAINS(new_fmt,"d") = 1) OR (CONTAINS(new_fmt,"dd") = 1) OR 
  625.            (CONTAINS(new_fmt,"ddd") = 1) OR (CONTAINS(new_fmt,"dddd") = 1)
  626.             isdate = 1
  627.         END IF
  628.     ELSEIF MATCH(new_fmt,"y",1) <> 0 { If new_fmt contains a yy or yyyy, it's a date format. }
  629.         IF (CONTAINS(new_fmt,"yy") = 1) OR (CONTAINS(new_fmt,"yyyy") = 1)
  630.             isdate = 1
  631.         END IF
  632.     ELSEIF MATCH(new_fmt,"m",1) <> 0
  633.         { If format string contains "mmm" or "mmmm", then date format involved. }
  634.         IF ((CONTAINS(new_fmt,"mmm") = 1) OR (CONTAINS(new_fmt,"mmmm") = 1))
  635.                 isdate = 1
  636.         ELSEIF ((CONTAINS(new_fmt,"m") = 1) OR (CONTAINS(new_fmt,"mm") = 1))      
  637.             { Format string might contain time as well as date formatting, 
  638.             so prompt user if they want to convert, else do the conversion. }
  639.             IF (CONTAINS(new_fmt,"h") = 1) OR (CONTAINS(new_fmt,"s") = 1)
  640.                 { If serial number < 1, do not convert }
  641.                 IF INT(INDIRECT(current_cell)) = 0 
  642.                     isdate = 0
  643.                 ELSE
  644.                     isdate = Convert (fmt)
  645.                 END IF
  646.                 REPAINT OFF
  647.             ELSE
  648.                 isdate = 1
  649.             END IF
  650.         END IF
  651.     ELSEIF MATCH(new_fmt,"h",1) <> 0 { If new_fmt contains a h or hh, it's a time format. }
  652.         IF (CONTAINS(new_fmt,"h") = 1) OR (CONTAINS(new_fmt,"hh") = 1)
  653.             { If serial number < 1, do not convert }
  654.             IF INT(INDIRECT(current_cell)) = 0
  655.                 isdate = 0
  656.             ELSE
  657.                 isdate = Convert (fmt)
  658.             END IF
  659.         END IF
  660.     ELSEIF MATCH(new_fmt,"s",1) <> 0 { If new_fmt contains an s or ss, it's a time format. }
  661.         IF (CONTAINS(new_fmt,"s") = 1) OR (CONTAINS(new_fmt,"ss") = 1)
  662.             { If serial number < 1, do not convert }
  663.             IF INT(INDIRECT(current_cell)) = 0
  664.                 isdate = 0
  665.             ELSE
  666.                 isdate = Convert (fmt)
  667.             END IF
  668.         END IF
  669.     END IF    
  670.     IF isdate { If the format is a date string. }
  671.         decimal = INDIRECT(current_cell) - INT(INDIRECT(current_cell))
  672.         IF INDIRECT(current_cell) <= 60
  673.             d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),2)
  674.         ELSE
  675.             d1 = ADDDAYS(ADDYEARS(INDIRECT(current_cell),4),1)
  676.         END IF
  677.         PUT d1 + decimal INTO current_cell
  678.     END IF
  679. END FUNCTION { END OF FUNCTION CustomDates () }
  680. {==========================================================================
  681. FUNCTION NAME
  682.     Convert
  683. DESCRIPTION
  684.     This function prompts the user whether or not to convert the number
  685.     based on the displayed custom format.  The reason for this is that
  686.     time formats and date formats    have the letter "m" in common, and
  687.     date and time format strings can be used in conjunction with one
  688.     another.
  689. RETURNS
  690.     1 - Convert the number
  691.     0 - Do not convert the number
  692. PARAMETERS
  693.     None
  694. NOTES
  695.     None.
  696. HISTORY
  697.     02/22/90 - KHB - Initial code.
  698. ==========================================================================}
  699. FUNCTION Convert (fmt)
  700.     IF global
  701.         RETURN 1
  702.     END IF
  703.     NEW MODAL DIALOG BOX AT (-1,-1) (5500,2000) NAME DIALOG BOX "DateConverter"
  704.     ADD PUSH BUTTON "Convert All","No","Yes" AT (0,1500) (5500,1850)
  705.     DIALOG DEFAULT PUSH BUTTON
  706.     SCRIPT "DateConv.scz:duit = 1"
  707.     SELECT CONTROL 2
  708.     DIALOG CANCEL PUSH BUTTON
  709.     SCRIPT "DateConv.scz:duit = 0"
  710.     SELECT CONTROL 1
  711.     SCRIPT "DateConv.scz:global = 1;quit dialog box"
  712.     ADD TEXT "Convert '" & INDIRECT(current_cell) & "' formatted as '" & fmt 
  713.         & "', or globally convert all?" at (100,100) (5400,1300)
  714.     NO LINE BORDER
  715.     USE DIALOG BOX
  716.     RETURN duit
  717. END FUNCTION { END OF FUNCTION Convert () }
  718. FUNCTION Draw_Logo ()
  719.     VIEWPORT (0,0) (1,1)
  720.     SCALED WINDOW (0,0) (15,15)
  721.     FILL FG GREY()
  722.     FILL PATTERN 1
  723.     FILL FG GREY()
  724.     FILL RECTANGLE (1.5,6.5) (14.5,9)
  725.     MOVE (1.5,12.5)
  726.     OPEN POLYGON
  727.         DRAW (14.5,12.5)
  728.         DRAW (8,.5)
  729.         DRAW (1.5,12.5)
  730.     CLOSE POLYGON
  731.     FILL POLYGON
  732.     KILL POLYGON
  733.     FILL FG blue()
  734.     FILL PATTERN 1
  735.     LINE FG BLACK()
  736.     MOVE (1,13)
  737.     OPEN POLYGON
  738.         DRAW (14,13)
  739.         DRAW (7.5,1)
  740.         DRAW (1,13)
  741.     CLOSE POLYGON
  742.     FILL POLYGON
  743.     KILL POLYGON
  744.     FILL FG WHITE()
  745.     TEXT COLOR WHITE()
  746.     TEXT FONT "Tms Rmn"
  747.     TEXT SIZE 18
  748.     MOVE (3.7,10.1)
  749.     DRAW TEXT "W"
  750.     MOVE (9.3,10.1)
  751.     DRAW TEXT "Z"
  752.     TEXT SIZE 14
  753.     MOVE (6,10.44)
  754.     DRAW TEXT "ING"
  755.     TEXT SIZE 14
  756.     TEXT FONT "Tms Rmn"
  757.     MOVE (11.2,11.1)
  758.     TEXT SIZE 8
  759.     DRAW TEXT "TM"
  760.     PAINT RECTANGLE (1,7) (14,9.5)
  761.     TEXT COLOR BLACK()
  762.     TEXT STYLE "SB"
  763.     TEXT SIZE 12
  764.     MOVE (2,7.5)
  765.     DRAW TEXT "Date Converter"
  766. END FUNCTION
  767. ON ERROR
  768. END ERROR
  769.