home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / 123EXP.ZIP / IMP_ROW.CLA < prev    next >
Text File  |  1994-01-07  |  23KB  |  540 lines

  1.             MEMBER('dcf')
  2. imp_row     PROCEDURE
  3. !******************************************************************************
  4. !   This sample program illustrates a method for reading a PORTION of a 1-2-3
  5. !   format spreadsheet file.  It accepts the spreadsheet row and column, the
  6. !   orientation of the numbers (either vertical or horizontal) and begins
  7. !   importing numbers from that point.  It stops importing when the first blank
  8. !   cell is encountered in the direction of the import - to the right (hor-
  9. !   izontal) or down (vertical).  The numbers read are then presented in a
  10. !   preview screen.  The user can then decide to keep them or try importing
  11. !   from another area of the spreadsheet.
  12.  
  13. !   DISCLAIMER: I have not spent any time cleaning up this code.  There are
  14. !   lots of calls to other functions and procedures that I have not removed.
  15. !   There are also references to global variables and files that I have not
  16. !   provided.
  17.  
  18. !******************************************************************************
  19.  
  20. !══════════════════════════════════════════════════════════════════════════════
  21. !   RED - 03/25/93
  22.  
  23. !   This procedure imports a row from a 1-2-3 spreadsheet file into the
  24. !   year amounts for the current cash flow line and saves the line.
  25.  
  26. !══════════════════════════════════════════════════════════════════════════════
  27. parms_scr   SCREEN         WINDOW(9,61),PRE(scr),HLP('imp_row'),HUE ( , ,0),TRN
  28.                 ROW(2,61)  PAINT(7,1),HUE(8,0),TRN
  29.                 ROW(1,1)   PAINT(8,60),HUE(8,7)
  30.                 ROW(2,2)   PAINT(4,23),HUE(1,7)
  31.                 ROW(5,25)  PAINT(1,4),HUE(1,7)
  32.                 ROW(3,25)  PAINT(1,9),HUE(0,7)
  33.                 ROW(4,30)  PAINT(4,28),HUE(0,7)
  34.                 ROW(9,2)   PAINT(1,60),HUE(8,0),TRN
  35.                 ROW(1,1)   STRING('╒═<0{42}>═{15}╕')
  36.                 ROW(2,1)   REPEAT(6);STRING('│<0{58}>│') .
  37.                 ROW(8,1)   STRING('╘═{58}╛')
  38.                 ROW(4,30)  STRING('┌─{26}┐')
  39.                 ROW(5,30)  REPEAT(2);STRING('│<0{26}>│') .
  40.                 ROW(7,30)  STRING('└─{26}┘')
  41.                 ROW(1,3)   STRING('Import numbers from a row in a spreadsheet')
  42.                 ROW(5,28)  STRING(']')
  43.                 ROW(2,3)   STRING('Spreadsheet Filename:')
  44.                     COL(25) ENTRY(@S35),USE(wks_filename),HUE(0,7),SEL(15,4),REQ,LFT,UPR
  45.                 ROW(3,10)  STRING('Starting Cell:')
  46.                     COL(25) ENTRY(@S2),USE(prj:ipr_column),HUE(0,7),SEL(15,4),REQ,LFT,UPR,IMM
  47.                     COL(27) STRING(':')
  48.                     COL(28) ENTRY(@N_5),USE(prj:ipr_row),HUE(0,7),SEL(15,4),INS,REQ
  49.                 ROW(5,12)  STRING('Orientation: [')
  50.                     COL(26) MENU(@S2),USE(prj:ipr_orient),HUE(0,7),SEL(0,7),REQ,IMM
  51.                     COL(31)    STRING('═<16>  Numbers are Horizontal'),HUE(0,7),SEL(15,4)
  52.                 ROW(6,31)      STRING('<25>   Numbers are Vertical  '),HUE(0,7),SEL(15,4)
  53.             .              .
  54.  
  55. stat_screen SCREEN         WINDOW(10,44),AT(14,36),PRE(sta),HUE(8,0,0),TRN
  56.                 ROW(10,1)  PAINT(1,1),TRN
  57.                 ROW(1,1)   PAINT(9,42),HUE(24,6)
  58.                 ROW(3,2)   PAINT(4,40),HUE(16,6)
  59.                 ROW(3,3)   PAINT(4,38),HUE(17,6)
  60.                 ROW(4,5)   PAINT(2,13),HUE(16,6)
  61.                 ROW(4,23)  PAINT(1,9),HUE(16,6)
  62.                 ROW(1,43)  PAINT(9,1),HUE(16,6)
  63.                 ROW(1,44)  PAINT(1,1),TRN
  64.                     COL(1) STRING('┌─{41}')
  65.                 ROW(2,1)   REPEAT(5);STRING('│') .
  66.                 ROW(7,1)   STRING('├─{41}')
  67.                 ROW(8,1)   STRING('│')
  68.                 ROW(9,1)   STRING('└─{41}')
  69.                 ROW(1,43)  STRING('┐')
  70.                 ROW(2,43)  REPEAT(5);STRING('│') .
  71.                 ROW(7,43)  STRING('┤')
  72.                 ROW(8,43)  STRING('│')
  73.                 ROW(9,43)  STRING('┘')
  74.                 ROW(3,3)   STRING('┌─<0{8}>─{5}┐<0,0>┌─<0{4}>─{5}┐')
  75.                 ROW(4,3)   STRING('│<0{14}>│<0,0>│<0{10}>│')
  76.                 ROW(5,3)   STRING('│<0{14}>│<0,0>└─{10}┘')
  77.                 ROW(6,3)   STRING('└─{14}┘')
  78.                 ROW(3,5)   STRING('Position')
  79.                     COL(23) STRING('Cell')
  80.                 ROW(4,25)  STRING(':')
  81.                 ROW(8,3)   STRING('Press [Shift+Esc] to abort.')
  82. message         ROW(2,3)   STRING(39),HUE(17,6)
  83. wks_pointer     ROW(4,8)   STRING(@N9)
  84. file_size       ROW(5,5)   STRING(12)
  85. col             ROW(4,23)  STRING(2)
  86. row                 COL(26) STRING(5)
  87.             .
  88.  
  89. preview     SCREEN         WINDOW(24,59),AT(2,13),PRE(pre),HUE ( , ,0),TRN
  90.                 ROW(24,2)  PAINT(1,57),HUE(8,0),TRN
  91.                 ROW(2,59)  PAINT(23,1),HUE(8,0),TRN
  92.                 ROW(1,1)   PAINT(23,58),HUE(8,3)
  93.                 ROW(2,3)   PAINT(2,55),HUE(0,3)
  94.                 ROW(4,22)  PAINT(3,16),HUE(15,3)
  95.                 ROW(5,27)  PAINT(1,6),HUE(0,3)
  96.                 ROW(8,7)   PAINT(1,1),HUE(1,3)
  97.                 ROW(1,1)   STRING('╒═<0{14}>═{41}╕')
  98.                 ROW(2,1)   REPEAT(5);STRING('│<0{56}>│') .
  99.                 ROW(7,1)   STRING('╞════╤═{13}╦════╤═{13}╦════╤═{13}╡')
  100.                 ROW(8,1)   REPEAT(15);STRING('│<0{4}>│<0{13}>║<0{4}>│<0{13}>║<0{4}>│<0{13}>│') .
  101.                 ROW(23,1)  STRING('╘════╧═{13}╩════╧═{13}╩════╧═{13}╛')
  102.                 ROW(4,22)  STRING('┌─{14}┐')
  103.                 ROW(5,22)  STRING('│<0{14}>│')
  104.                 ROW(6,22)  STRING('└─{14}┘')
  105.                 ROW(1,3)   STRING('Import Preview')
  106.                 ROW(2,3)   STRING('These are the numbers that will be imported.  Do you')
  107.                 ROW(3,3)   STRING('want to go ahead and move them into the current line?')
  108.                 ROW(5,34)  MENU(@S3),USE(mem:continue),HUE(3,3),SEL(3,3),REQ,IMM
  109.                     COL(27)    STRING('Yes'),SEL(15,4)
  110.                     COL(31)    STRING('No'),SEL(15,4)
  111.                            .
  112.                            REPEAT(15,3),EVERY(1,19),INDEX(preview_idx)
  113. year            ROW(8,2)       STRING(@N04)
  114. import_no           COL(7)     STRING(13)
  115.             .              .
  116.  
  117. preview_data    GROUP       ! Table of imported numbers
  118. preview_no          REAL,DIM(40)
  119.                 .
  120.  
  121.     INCLUDE('wks_file.inc')
  122.  
  123. preview_idx BYTE
  124.  
  125. row_no      SHORT           ! Spreadsheet row# (relative to 0)
  126. col_no      SHORT           ! Numeric spreadsheet column
  127.  
  128. row_offset  BYTE            ! Row increment amount for proper orientation
  129. col_offset  BYTE            ! Column "      "      "   "      "
  130.  
  131. at_eof      BYTE
  132. !──────────────────────────────────────────────────────────────────────────────
  133.     CODE
  134.  
  135.     action = mem:chg_record
  136.  
  137.     IF lin:method <> mth:discrete_sch
  138.         disp_msg('The current cash flow line is not a discrete schedule.')
  139.         RETURN
  140.     .
  141.     DO init_parms                           ! Set the defualts
  142.     DO get_numbers                          ! Accept the parameters and load
  143.                                             !   the numbers
  144.     DO cleanup
  145.  
  146.     RETURN
  147.  
  148. !───Routines───────────────────────────────────────────────────────────────────
  149. init_parms      ROUTINE             ! Set the defaults if they're empty
  150.     IF prj:ipr_filename = ''
  151.         prj:ipr_filename = CLIP(cfg:data_dir) & '\DCF.WK1'
  152.     .
  153.     IF prj:ipr_column = ''
  154.         prj:ipr_column = 'A'
  155.     .
  156.     IF prj:ipr_row = ''
  157.         prj:ipr_row = 1
  158.     .
  159.     IF prj:ipr_orient = ''
  160.         prj:ipr_orient = '═'
  161.     .
  162.  
  163. get_numbers  ROUTINE    ! Accept the parameters and load the numbers
  164.     OPEN(parms_scr)                             ! Display the window
  165.     wks_filename = prj:ipr_filename
  166.  
  167.     SETCURSOR                                   ! Cursor off
  168.     DISPLAY                                     ! Display fields
  169.  
  170.     LOOP
  171.         ALERT                                   ! Reset all keys
  172.         ALERT(esc_key)                          ! Enable the Esc key
  173.         ALERT(reject_key)                       !   and the Shift+Esc key
  174.         ALIAS(ctrl_esc,reject_key)
  175.         ALERT(accept_key)
  176.         ALERT(F3_key)
  177.         ACCEPT                                  ! Accept the parms
  178.  
  179.         CASE KEYCODE()
  180.         OF reject_key
  181.             DO cleanup
  182.             RETURN
  183.         OF accept_key
  184.             UPDATE
  185.             SELECT(?)
  186.             SELECT                              ! Accept and edit all fields
  187.             CYCLE
  188.         OF esc_key
  189.             IF FIELD() = ?wks_filename
  190.                 DO cleanup
  191.                 RETURN
  192.             ELSE
  193.                 SELECT(?-1); CYCLE
  194.             .
  195.         OF F3_key
  196.             IF FIELD() <> ?wks_filename
  197.                 BEEP
  198.                 SELECT(?); CYCLE
  199.         .   .
  200.  
  201.         CASE FIELD()
  202.         OF ?wks_filename
  203.             IF KEYCODE() = esc_key
  204.                 DO cleanup
  205.                 RETURN
  206.             .
  207.             IF (wks_filename = '')              OR |
  208.                (KEYCODE() = F3_key)             OR |
  209.                (INSTRING('*',wks_filename,1,1)) OR |
  210.                (INSTRING('?',wks_filename,1,1))
  211.                 UPDATE
  212.                 IF wks_filename = ''
  213.                     wks_filename = '*.WK1'          ! Select spreadsheets
  214.                 .
  215.                 IF sel_file(wks_filename,,files_only)
  216.                     DISPLAY(?wks_filename)          ! Redisplay selected file
  217.                 ELSE
  218.                     SELECT(?); CYCLE
  219.             .   .
  220.             IF NOT namevalid(wks_filename)
  221.                 disp_msg('Invalid filename syntax. Please re-enter.')
  222.                 SELECT(?); CYCLE
  223.             .
  224.             ! Add a default ".WK1" extension if there isn't one
  225.             IF NOT INSTRING('.WK',wks_filename,1)
  226.                 wks_filename = CLIP(wks_filename) & '.WK1'
  227.                 DISPLAY(?)
  228.             ELSE
  229.                 IF SUB(wks_filename,-1,1) = '.'     ! Period at last position?
  230.                     wks_filename = CLIP(wks_filename) & 'WK1'
  231.                     DISPLAY(?)
  232.             .   .
  233.             IF NOT filexists(wks_filename)
  234.                 disp_msg('Filename not found. Please re-enter.')
  235.                 SELECT(?); CYCLE
  236.             .
  237.  
  238.         OF ?prj:ipr_column
  239.             IF NOT INRANGE(prj:ipr_column,'A ','IV')
  240.                 disp_msg('Please enter a column indicator between "A" and "IV".')
  241.                 SELECT(?); CYCLE
  242.             .
  243.         OF ?prj:ipr_row
  244.             IF NOT INRANGE(prj:ipr_row,1,max_123_rows)
  245.                 disp_msg('Please enter a row number between 1 and ' & max_123_rows & '.')
  246.                 SELECT(?); CYCLE
  247.             .
  248.         OF ?prj:ipr_orient
  249.             DO check_ver
  250.             IF wks_pointer > 0                  ! Good WKS file?
  251.                 DO init_stats                   ! Display the stat screen
  252.                 DO find_cell                    ! Find the specified cell
  253.                 IF wks_pointer NOT > file_size  ! Any numbers found?
  254.                     DO load_table               ! Load numbers in the table
  255.                     DO show_preview             ! Show the numbers that will load
  256.                     IF mem:continue = 'Yes'     ! Go ahead and keep them?
  257.                         DO update_line          ! Update the line
  258.                         BREAK                   !   and quit
  259.             .   .   .
  260.             CLOSE(wks_file)
  261.             SELECT(?wks_filename); CYCLE
  262.     .   .
  263.  
  264. check_ver   ROUTINE         ! Check for a valid spreadsheet file. wks_pointer
  265.                             !   is > 0 if it's valid.
  266.     OPEN(wks_file)
  267.     IF ERRORCODE()
  268.         err_msg('Unable to access the spreadsheet file.')
  269.         wks_pointer = 0
  270.     ELSE
  271.         file_size = BYTES(wks_file)         ! Save the size of the file
  272.  
  273.         GET(wks_file,1,6)                   ! Read the BOF record
  274.         IF (wks:opcode  = bof_op) AND |     ! BOF record?
  275.           ((wks:version = ver_123_1) OR |   ! Version 1.x or
  276.            (wks:version = ver_123_2))       !   2.x spreadsheet?
  277.             wks_pointer = 7                 ! Yes - continue on
  278.         ELSE
  279.             wks_pointer = 0                 ! No - try again
  280.             CLOSE(wks_file)
  281.             disp_msg('Not a valid 1-2-3 spreadsheet file. Please re-enter.')
  282.     .   .
  283.  
  284. init_stats   ROUTINE
  285.     OPEN(stat_screen)
  286.     sta:file_size   = RIGHT('of ' & LEFT(FORMAT(file_size,@N9),9),12)
  287.     sta:row         = 1
  288.     sta:col         = 'A'
  289.     sta:wks_pointer = ''
  290.  
  291.     prj:ipr_filename = wks_filename     ! Save the parameters in
  292.     PUT(project)                        !   the project record
  293.  
  294.     IF prj:ipr_orient = '═'    ! Set the offsets to establish the proper orientation
  295.         col_offset = 1          ! Horizontal orientation - move the right
  296.         row_offset = 0
  297.     ELSE
  298.         col_offset = 0          ! Vertical orientation - move down
  299.         row_offset = 1
  300.     .
  301.  
  302. find_cell   ROUTINE     ! Find the specified starting cell
  303.     row_no = prj:ipr_row - 1            ! Row# is relative to 0
  304.  
  305.     IF LEN(CLIP(prj:ipr_column)) < 2        ! Compute the column NUMBER from the letters (1-2-3 columns #'s are relative to 0!)
  306.         col_no =      VAL(SUB(prj:ipr_column,1,1)) - 65                ! Only one letter
  307.     ELSE
  308.         col_no = ( ( (VAL(SUB(prj:ipr_column,1,1)) - 65) + 1) * 26 ) | ! Two letter
  309.                 +    (VAL(SUB(prj:ipr_column,2,1)) - 65)
  310.     .
  311.     sta:message = 'Looking for the starting cell...'
  312.  
  313.     at_eof = false
  314.     GET(wks_file,wks_pointer,4)             ! Read the first record header
  315.  
  316.     LOOP UNTIL wks_pointer > file_size      ! Find the 1st data record
  317.         IF INRANGE(wks:opcode,integer_op,formula_op)    ! Data opcode?
  318.             BREAK                           ! wks_pointer points to the start of the 1st data record
  319.         .
  320.         DO get_next
  321.         LOOP UNTIL NOT KEYBOARD()           ! Check for the abort key
  322.             ASK
  323.             IF KEYCODE() = reject_key
  324.                 DO scan_abort
  325.                 EXIT
  326.     .   .   .
  327.     IF wks_pointer > file_size              ! Any data found?
  328.         DO no_data_err                      !   No.
  329.         EXIT
  330.     .
  331.     GET(wks_file,wks_pointer,9)             ! Read the 1st data record header
  332.     cur_col = col_no
  333.     cur_row = row_no
  334.  
  335.     LOOP UNTIL wks_pointer > file_size
  336.         DO show_cell
  337.         IF INRANGE(wks:opcode,integer_op,formula_op)    ! Data cell?
  338.             IF (wks:row > cur_row) OR |          ! Past the specified cell?
  339.               ((wks:row = cur_row) AND (wks:col > cur_col))
  340.                 DO no_num_err
  341.                 EXIT
  342.             .
  343.             IF (wks:opcode = integer_op)  OR |  ! Is it a number?
  344.                (wks:opcode = floating_op) OR |
  345.                (wks:opcode = formula_op)
  346.                 IF wks:row = cur_row AND |  ! Are we on the specified cell?
  347.                    wks:col = cur_col
  348.                     BREAK                   ! Yes - start reading here (at wks_pointer position)
  349.         .   .   .
  350.         DO get_next
  351.         LOOP UNTIL NOT KEYBOARD()           ! Check for the abort key
  352.             ASK                             !   sequence
  353.             IF KEYCODE() = reject_key
  354.                 DO scan_abort
  355.                 EXIT
  356.     .   .   .
  357.  
  358.     IF wks_pointer > file_size  ! Anything found?
  359.         DO no_data_err          !   No.
  360.     .
  361.  
  362. load_table  ROUTINE             ! Load the numbers into the preview table
  363.     sta:message = 'Extracting the numbers from the file...'
  364.     CLEAR(preview_data)
  365.     preview_idx = 0
  366.     cur_col     = wks:col
  367.     cur_row     = wks:row
  368.  
  369.     LOOP UNTIL at_eof
  370.         DO load_number                          ! Get the number from the cell
  371.  
  372.         DO show_cell                            ! Display the cell location
  373.  
  374.         preview_idx += 1
  375.         IF preview_idx > dcf:years              ! All done?
  376.             BREAK
  377.         .
  378.         preview_no[preview_idx] = wks_number    ! Move the number into the
  379.                                                 !   preview table
  380.  
  381.         cur_col = cur_col + col_offset          ! Set the next cell location
  382.         cur_row = cur_row + row_offset          !   to read from
  383.  
  384.         DO find_next
  385.     .
  386.  
  387. find_next   ROUTINE     ! Skip any records between the current position and the
  388.                         !   next cell where we should find a number (indicated
  389.                         !   by the coordinates in cur_row and cur_col)
  390.  
  391.     LOOP UNTIL at_eof OR (wks_pointer > file_size)
  392.         GET(wks_file,wks_pointer,9)             ! Read the next header
  393.         sta:wks_pointer = wks_pointer           ! Display the counter
  394.  
  395.         IF wks:opcode = eof_op                  ! 1-2-3 EOF mark?
  396.             wks_pointer = file_size + 1         ! All done
  397.             at_eof      = true
  398.         ELSE
  399.             IF INRANGE(wks:opcode,integer_op,formula_op)    ! Data cell?
  400.                 IF (wks:row = cur_row) AND |    ! Did we find the cell?
  401.                    (wks:col = cur_col)
  402.                     IF wks:opcode = label_op    ! First empty or label cell
  403.                         at_eof = true           !   marks the end
  404.                     .
  405.                     BREAK                       ! Yes - we're done looking
  406.                 .
  407.                 IF (wks:row > cur_row) OR  |    ! Are we past where the cell
  408.                   ((wks:row = cur_row) AND |    !   should be?
  409.                      (wks:col > cur_col))
  410.                     at_eof = true               ! All done!
  411.         .   .   .
  412.         DO show_cell                            ! Display the column and row
  413.  
  414.         wks_pointer += wks:length + 4           ! Move over the current record
  415.         DO abort_check                          ! Watch for Shift+Esc
  416.     .
  417.  
  418. show_preview    ROUTINE     ! Let the use preview the numbers we found
  419.     CLOSE(stat_screen)
  420.     OPEN (preview)
  421.     mem:continue = 'Yes'
  422.     LOOP preview_idx = 1 TO dcf:years   ! Show the numbers
  423.         pre:year      = YEAR(dcf:date) + preview_idx - 1
  424.  
  425.         EXECUTE (lnt:places +1)
  426.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line0)
  427.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line1)
  428.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line2)
  429.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line3)
  430.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line4)
  431.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line5)
  432.             pre:import_no = FORMAT(preview_no[preview_idx],fmt:line6)
  433.     .   .
  434.     SELECT(?mem:continue)
  435.  
  436.     ALERT                                   ! Reset all keys
  437.     ALERT(esc_key)                          ! Enable the ESC keys
  438.     ALERT(accept_key)
  439.     ALERT(reject_key)
  440.     ALIAS(ctrl_esc,reject_key)
  441.     ACCEPT                                  ! Get the response
  442.  
  443.     IF (KEYCODE() = esc_key) OR (KEYCODE() = reject_key)
  444.         mem:continue = 'No'
  445.     .
  446.     CLOSE(preview)
  447.  
  448. update_line     ROUTINE     ! Move the numbers into the line and save it
  449.     LOOP preview_idx = 1 TO dcf:years   ! Move the numbers
  450.         lin:amount[preview_idx] = preview_no[preview_idx]
  451.     .
  452.     PUT(lineitem)                       ! Update the line item
  453.     IF ERRORCODE()
  454.         err_msg('Unable to save the imported number in this line.')
  455.     ELSE
  456.         action = mem:no_action          ! Set action to complete
  457.     .
  458.  
  459. get_next    ROUTINE             ! Get the next 123 record
  460.     wks_pointer += wks:length + 4       ! Move over the current record
  461.     GET(wks_file,wks_pointer,9)         !   and read the next header
  462.     sta:wks_pointer = wks_pointer       ! Display the counter
  463.  
  464. no_data_err ROUTINE
  465.     sta:message = ''
  466.     CLOSE(wks_file)
  467.     disp_msg('Invalid spreadsheet format.  No numeric data cells were found.')
  468.     CLOSE(stat_screen)
  469.     wks_pointer = file_size + 1 ! Accept the filename again
  470.  
  471. no_num_err ROUTINE
  472.     DO show_cell
  473.     sta:message = ''
  474.     CLOSE(wks_file)
  475.     disp_msg('Cell ' & CLIP(prj:ipr_column) & ':' & prj:ipr_row & ' does not contain a number.')
  476.     CLOSE(stat_screen)
  477.     wks_pointer = file_size + 1 ! Accept the filename again
  478.  
  479. scan_abort  ROUTINE             ! Abort the initial scan
  480.     BEEP
  481.     OPEN(msg_box); msg_text = 'Aborting.  Just a moment...'
  482.     DO cleanup
  483.     disp_msg('The scanning was aborted as requested.')
  484.     CLOSE(stat_screen)
  485.     wks_pointer = file_size + 1 ! Accept the filename again
  486.  
  487. load_number ROUTINE     ! This moves the numeric data from the current record
  488.                         !   and checks to be sure it's coming from the correct
  489.                         !   cell location.  If the record is not a number,
  490.                         !   stop loading.
  491.     sta:wks_pointer = wks_pointer
  492.     CASE wks:opcode
  493.     OF integer_op                       ! Integer?
  494.         GET(wks_file,wks_pointer,11)    ! Get the integer record (size=7 + 4 byte header)
  495.         wks_pointer += 11               ! Advance the file pointer
  496.         wks_number = wks:integer
  497.     OF floating_op
  498.         GET(wks_file,wks_pointer,17)    ! Get the real number record (size=13 + 4 byte header)
  499.         wks_pointer += 17               ! Advance the file pointer
  500.         wks_number = wks:real_no
  501.     OF formula_op                       ! Formula
  502.         GET(wks_file,wks_pointer,17)    ! Get the real number result (size=13 + 4 byte header)
  503.         wks_pointer += 4 + wks:length   ! Advance the file pointer over the formula text (up to 2048 bytes)
  504.         wks_number = wks:real_no
  505.     ELSE
  506.         CLEAR(wks_number,1)             ! Set to highest # possible
  507.         at_eof = true                   ! All done!
  508.     .
  509.  
  510. show_cell       ROUTINE     ! Display the 1-2-3 spreadsheet the column # as
  511.                             !   letter(s) and the row number.
  512.     IF col_shown <> wks:col             ! Is column display up to date?
  513.         col_shown     = wks:col         ! No - update it
  514.         col_letter[1] = wks:col / 26    ! First letter group# (0 if only 1 letter)
  515.         col_letter[2] = wks:col % 26    ! Code of second (or only) letter
  516.  
  517.         IF col_letter[1] = 0            ! Only one letter?
  518.             sta:col = ' ' & CHR(col_letter[2] + 65)         ! Show 1 letter
  519.         ELSE
  520.             sta:col = CHR(col_letter[1] + 64) & CHR(col_letter[2] + 65)
  521.     .   .
  522.     sta:row = wks:row                   ! Dislay the row#
  523.  
  524. abort_check     ROUTINE
  525.     LOOP UNTIL NOT KEYBOARD()                   ! Look for keystroke
  526.         ASK                                     ! Get keycode if there is one
  527.         IF (KEYCODE() = reject_key) OR |        ! On Shift+Esc
  528.            (KEYCODE() = ctrl_esc)               !   or Ctrl+Esc
  529.             BEEP
  530.             OPEN(msg_box); msg_text = 'Aborting.  Just a moment...'
  531.             DO cleanup
  532.             disp_msg('The extracting was aborted as requested.')
  533.             at_eof = true
  534.     .   .
  535.  
  536. cleanup         ROUTINE
  537.     CLOSE(wks_file)
  538.     CLOSE(msg_box)                      ! Clear whatever message was displayed
  539.     sta:message = ''
  540.