home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Tu-Basic / MC2.INC < prev    next >
Text File  |  1987-04-01  |  3KB  |  98 lines

  1. '┌───────────────────────────────────────────────────────────────────────────┐
  2. '│                               MC.BAS                                   │
  3. '│                             VERSION 1.0                                   │
  4. '│                                                                           │
  5. '│                           MODULE: MC2.INC                                 │
  6. '│                                                                           │
  7. '│                   Turbo Basic                     │
  8. '│        (C) Copyright 1987 by Borland International             │
  9. '│                                                                           │
  10. '│ DESCRIPTION: Init and display and clear spreadsheet grid             │
  11. '│                                         │
  12. '│                                                                           │
  13. '└───────────────────────────────────────────────────────────────────────────┘
  14.  
  15.  
  16. SUB Grid
  17. ' Grid displays the entire spreadsheet grid AND command line
  18.  
  19.   SHARED XPos%(),BORDER%
  20.   LOCAL I%
  21.  
  22.   IF Border%=%True  THEN
  23.     LOCATE 1,1 : COLOR %HighLightColor,9
  24.     FOR I% = %FXMin  TO %FXMax
  25.       PRINT tab(Xpos%(I%));"│    ";CHR$(I%);"    ";
  26.     NEXT I%
  27.     PRINT "│";
  28.     LOCATE 2,1
  29.     FOR I% = %FYMin  TO %FYMax
  30.       PRINT using "##";I%
  31.     NEXT I%
  32.     CALL DISPAUTO
  33.     CALL Flash(31,"Type / for Commands, F2 for Edit", %FALSE  )
  34.     COLOR %HighLightColor,0
  35.     LOCATE,36 : PRINT "/";
  36.     LOCATE,52 : PRINT "F2";
  37.     CALL NormVideo
  38.   END IF
  39. END SUB
  40.  
  41. SUB DISPAUTO
  42. ' Display the AutoCalc state
  43.   SHARED AutoCalC%,BORDER%
  44.  
  45.   IF BORDER%=%True  THEN
  46.     CALL Flash( 66,"AutoCalc is", %FALSE  )
  47.     LOCATE ,78 : COLOR %HighLightColor,0
  48.     IF AutoCalc%=%True  THEN
  49.       PRINT "ON ";
  50.     ELSE
  51.       PRINT "OFF";
  52.     END IF
  53.     CALL NormVideo
  54.  END IF
  55. END SUB
  56.  
  57. SUB Init
  58. ' Init initializes most of the needed global variables AND arrays.
  59.  
  60.   SHARED  GlobFX%, GlobFY%, AutoCalc%, Border%
  61.   LOCAL I%,J%
  62.  
  63.     FOR I% = %FXMin  TO %FXMax       ' Set up each cell record
  64.       FOR J% = %FYMin  TO %FYMax     '
  65.         CALL PutRec( I%,J%,%Txt ,"",0.0,%NumDecPlaces ,%FieldWidth , 7*256+0)
  66.       NEXT J%
  67.     NEXT I%
  68.     Border%   = %True
  69.     AutoCalc% = %TRUE
  70.     GlobFX%   = %FXMin                 ' We will start with autocalc on
  71.     GlobFY%   = %FYMin                 ' Start at the upper left corner (A1)
  72.  
  73. END SUB
  74.  
  75. SUB ClearSheet
  76. ' ClearSheet clears the all the spreadsheet cells and redraws the spreadsheet.
  77.  
  78.   LOCAL Ch$
  79.  
  80.   CALL NormVideo
  81.   CALL ClearStat
  82.   LOCATE %StatusLine ,1            ' Make sure you go to the prompt location
  83.                                    ' after a ClearStat, because ClearStat does
  84.                                    ' not restore the previous cursor position
  85.   PRINT "Clear this worksheet (Y/N) ? "; ' Make sure the user wants to do this
  86.   DO
  87.     CALL Readkbd(CH$)
  88.   LOOP UNTIL UCASE$(Ch$)="Y" OR UCASE$(Ch$)="N"
  89.   PRINT UCASE$(Ch$);
  90.   IF UCASE$(Ch$)="Y" THEN
  91.     CALL Init                      'initialize the cells of the spreadsheet
  92.     CLS
  93.     CALL Grid                      ' Redraw the grid
  94.   END IF
  95.  
  96. END SUB
  97.  
  98.