home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1990 / USERJL90.MSA / SHEET_MANUAL.ARC / MANUAL.DOC
Text File  |  1990-05-15  |  212KB  |  6,535 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                           SHEET -- FOR ATARI ST
  27.             A BASIC interpreter in a spreadsheet environment
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.         Atari, 520 ST and ST are trademarks of Atari Corporation
  50.                GEM is trademark of Digital Research, Inc.
  51.          Lotus 123 is trademark of Lotus Development Corporation
  52.  
  53.  
  54.  
  55.         Copyright (C) 1988, Chor-ming Lung. All rights reserved.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.                             Table of Content
  76.                             ________________
  77.  
  78.  
  79.  
  80. Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  81.  
  82. Disclaimer  . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  83.  
  84. Requirements  . . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  85.  
  86. Introduction  . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
  87.  
  88.                           PART I -- TUTORIAL  . . . . . . . . . . .   3
  89. Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   4
  90. Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   9
  91. Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
  92. Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  13
  93. Example 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  15
  94. Example 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  16
  95. Example 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18
  96. Example 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19
  97. Example 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20
  98.  
  99.                   PART II -- Spreadsheet operations . . . . . . . .  22
  100.  
  101. MENU SELECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  102.      Desk . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  103.           About SHEET . . . . . . . . . . . . . . . . . . . . . . .  23
  104.      File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  105.           New    N  . . . . . . . . . . . . . . . . . . . . . . . .  23
  106.           Load   L  . . . . . . . . . . . . . . . . . . . . . . . .  23
  107.           Load WKS  . . . . . . . . . . . . . . . . . . . . . . . .  23
  108.           Load PART . . . . . . . . . . . . . . . . . . . . . . . .  23
  109.           Save   S  . . . . . . . . . . . . . . . . . . . . . . . .  23
  110.           Save WKS  . . . . . . . . . . . . . . . . . . . . . . . .  23
  111.           Save PART . . . . . . . . . . . . . . . . . . . . . . . .  23
  112.           Print  P  . . . . . . . . . . . . . . . . . . . . . . . .  23
  113.           Quit   Q  . . . . . . . . . . . . . . . . . . . . . . . .  23
  114.      Sheet  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  115.           Erase . . . . . . . . . . . . . . . . . . . . . . . . . .  23
  116.           Defaults  . . . . . . . . . . . . . . . . . . . . . . . .  23
  117.           Options . . . . . . . . . . . . . . . . . . . . . . . . .  24
  118.           Dates . . . . . . . . . . . . . . . . . . . . . . . . . .  24
  119.      Row/Col  . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  120.           Insert  I . . . . . . . . . . . . . . . . . . . . . . . .  25
  121.           Delete  D . . . . . . . . . . . . . . . . . . . . . . . .  25
  122.           Col widths  . . . . . . . . . . . . . . . . . . . . . . .  25
  123.      Cells  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  124.           Reformat  R . . . . . . . . . . . . . . . . . . . . . . .  25
  125.           Erase     E . . . . . . . . . . . . . . . . . . . . . . .  25
  126.           Copy      C . . . . . . . . . . . . . . . . . . . . . . .  25
  127.           Move      M . . . . . . . . . . . . . . . . . . . . . . .  25
  128.           Adjust    A . . . . . . . . . . . . . . . . . . . . . . .  25
  129.      Graph  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
  130.      Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  26
  131.  
  132.  
  133.                                   - i -
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144. MOVING AROUND . . . . . . . . . . . . . . . . . . . . . . . . . . .  27
  145.  
  146. EDITING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  28
  147.      Types of cell entry  . . . . . . . . . . . . . . . . . . . . .  28
  148.           Formula . . . . . . . . . . . . . . . . . . . . . . . . .  28
  149.           Constant  . . . . . . . . . . . . . . . . . . . . . . . .  28
  150.           Statement . . . . . . . . . . . . . . . . . . . . . . . .  28
  151.           Command . . . . . . . . . . . . . . . . . . . . . . . . .  28
  152.           Text  . . . . . . . . . . . . . . . . . . . . . . . . . .  28
  153.      Rules for constructing formula . . . . . . . . . . . . . . . .  29
  154.      Cell input . . . . . . . . . . . . . . . . . . . . . . . . . .  30
  155.           Move the editing cursor . . . . . . . . . . . . . . . . .  30
  156.           Modify your input . . . . . . . . . . . . . . . . . . . .  30
  157.           Terminate your input  . . . . . . . . . . . . . . . . . .  30
  158.           Miscellaneous operations  . . . . . . . . . . . . . . . .  30
  159.      Modify a cell  . . . . . . . . . . . . . . . . . . . . . . . .  31
  160.      Editing direction  . . . . . . . . . . . . . . . . . . . . . .  31
  161.  
  162. CUSTOMIZED DISPLAY  . . . . . . . . . . . . . . . . . . . . . . . .  32
  163.      Change column width  . . . . . . . . . . . . . . . . . . . . .  32
  164.      Default display format . . . . . . . . . . . . . . . . . . . .  33
  165.      Display format:  . . . . . . . . . . . . . . . . . . . . . . .  33
  166.      Block  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  34
  167.      De-select blocks . . . . . . . . . . . . . . . . . . . . . . .  34
  168.      Change display format  . . . . . . . . . . . . . . . . . . . .  35
  169.  
  170. COPY AND MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . .  36
  171.      Relative and Absolue cell reference  . . . . . . . . . . . . .  37
  172.  
  173. ERASE CELLS . . . . . . . . . . . . . . . . . . . . . . . . . . . .  38
  174.  
  175. INSERT AND DELETE . . . . . . . . . . . . . . . . . . . . . . . . .  39
  176.      Row/Column selection . . . . . . . . . . . . . . . . . . . . .  39
  177.  
  178. LOAD, SAVE AND PRINT  . . . . . . . . . . . . . . . . . . . . . . .  40
  179.      File extension . . . . . . . . . . . . . . . . . . . . . . . .  40
  180.      Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  181.      Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  182.      Load PART  . . . . . . . . . . . . . . . . . . . . . . . . . .  40
  183.      Save Part  . . . . . . . . . . . . . . . . . . . . . . . . . .  41
  184.      Lotus files  . . . . . . . . . . . . . . . . . . . . . . . . .  41
  185.      Print  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  41
  186.  
  187.                         PART III -- SHEET BASIC . . . . . . . . . .  43
  188.  
  189. Cells and Variables . . . . . . . . . . . . . . . . . . . . . . . .  44
  190.      Cell reference with dimension  . . . . . . . . . . . . . . . .  44
  191.      Variables  . . . . . . . . . . . . . . . . . . . . . . . . . .  44
  192.      Cell reference with variables  . . . . . . . . . . . . . . . .  44
  193.      String . . . . . . . . . . . . . . . . . . . . . . . . . . . .  45
  194.      String operators
  195.      String operators . . . . . . . . . . . . . . . . . . . . . . .  45
  196.  
  197. Flow control Statements . . . . . . . . . . . . . . . . . . . . . .  47
  198.      IF .. THEN .. ELSE ..  . . . . . . . . . . . . . . . . . . . .  47
  199.      GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47
  200.      GOSUB .. RETURN  . . . . . . . . . . . . . . . . . . . . . . .  47
  201.  
  202.                                  - ii -
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.      LOOP .. EXIT IF .. ENDLOOP . . . . . . . . . . . . . . . . . .  47
  214.      FOR .. NEXT  . . . . . . . . . . . . . . . . . . . . . . . . .  48
  215.      RUN  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  48
  216.  
  217. I/O Statements  . . . . . . . . . . . . . . . . . . . . . . . . . .  49
  218.      REDIRECT TO  . . . . . . . . . . . . . . . . . . . . . . . . .  49
  219.      PRINT statement  . . . . . . . . . . . . . . . . . . . . . . .  49
  220.  
  221. Miscellaneous statements  . . . . . . . . . . . . . . . . . . . . .  51
  222.      SAVE SCREEN  . . . . . . . . . . . . . . . . . . . . . . . . .  51
  223.      RESTORE SCREEN . . . . . . . . . . . . . . . . . . . . . . . .  51
  224.      WAIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
  225.      DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
  226.      MESSAGE  . . . . . . . . . . . . . . . . . . . . . . . . . . .  52
  227.  
  228. Text files  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  229.      GET_FILE . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  230.      OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  231.      CLOSE  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53
  232.      INPUT #n . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
  233.      PRINT #n . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
  234.  
  235. Worksheet commands  . . . . . . . . . . . . . . . . . . . . . . . .  55
  236.      COPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  237.      MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  238.      ERASE  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  239.      REFORMAT . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
  240.      SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56
  241.      SWAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56
  242.  
  243. Console commands  . . . . . . . . . . . . . . . . . . . . . . . . .  57
  244.      CLS  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  245.      CURSORON . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  246.      CURSOROFF  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  247.      VIDEOHIGH  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  248.      VIDEONORM  . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  249.      GOTOXY . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
  250.      INKEY  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  251.      UNGET  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  252.      INPUT  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
  253.  
  254. Graphic commands  . . . . . . . . . . . . . . . . . . . . . . . . .  59
  255.      Setup commands . . . . . . . . . . . . . . . . . . . . . . . .  60
  256.           WINDOW  . . . . . . . . . . . . . . . . . . . . . . . . .  60
  257.           VIEWPORT  . . . . . . . . . . . . . . . . . . . . . . . .  61
  258.           SCALE . . . . . . . . . . . . . . . . . . . . . . . . . .  61
  259.           CLEAR . . . . . . . . . . . . . . . . . . . . . . . . . .  61
  260.           EXITGRAPH . . . . . . . . . . . . . . . . . . . . . . . .  61
  261.      Line/Dot commands  . . . . . . . . . . . . . . . . . . . . . .  62
  262.           ATTRIBUTE . . . . . . . . . . . . . . . . . . . . . . . .  62
  263.           LINE  . . . . . . . . . . . . . . . . . . . . . . . . . .  62
  264.           LINE_TO . . . . . . . . . . . . . . . . . . . . . . . . .  62
  265.           PLOT  . . . . . . . . . . . . . . . . . . . . . . . . . .  63
  266.           PLOT DATA . . . . . . . . . . . . . . . . . . . . . . . .  63
  267.           SPLINE  . . . . . . . . . . . . . . . . . . . . . . . . .  63
  268.      Turtlegraphics . . . . . . . . . . . . . . . . . . . . . . . .  64
  269.  
  270.                                  - iii -
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.           FORWARD . . . . . . . . . . . . . . . . . . . . . . . . .  64
  282.           TURN  . . . . . . . . . . . . . . . . . . . . . . . . . .  64
  283.           TURN_TO . . . . . . . . . . . . . . . . . . . . . . . . .  64
  284.      Axis command . . . . . . . . . . . . . . . . . . . . . . . . .  65
  285.           MARKX . . . . . . . . . . . . . . . . . . . . . . . . . .  65
  286.           MARKY . . . . . . . . . . . . . . . . . . . . . . . . . .  65
  287.           LABELX  . . . . . . . . . . . . . . . . . . . . . . . . .  65
  288.           LABELY  . . . . . . . . . . . . . . . . . . . . . . . . .  65
  289.      Text command . . . . . . . . . . . . . . . . . . . . . . . . .  66
  290.           PTEXT . . . . . . . . . . . . . . . . . . . . . . . . . .  66
  291.      Miscellaneous  . . . . . . . . . . . . . . . . . . . . . . . .  67
  292.           MOUSE_POS . . . . . . . . . . . . . . . . . . . . . . . .  67
  293.  
  294. Tips on using SHEET BASIC . . . . . . . . . . . . . . . . . . . . .  68
  295.      Interrupt  . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  296.      Using previous row format  . . . . . . . . . . . . . . . . . .  68
  297.      Error
  298.      Error  . . . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  299.      Multiple statements  . . . . . . . . . . . . . . . . . . . . .  68
  300.      Garbled screen . . . . . . . . . . . . . . . . . . . . . . . .  68
  301.      Adjust . . . . . . . . . . . . . . . . . . . . . . . . . . . .  68
  302.  
  303. Appendix A BUILT-IN FUNCTIONS . . . . . . . . . . . . . . . . . . .  69
  304.      Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69
  305.           General functions . . . . . . . . . . . . . . . . . . . .  69
  306.                ABS  . . . . . . . . . . . . . . . . . . . . . . . .  69
  307.                INT  . . . . . . . . . . . . . . . . . . . . . . . .  69
  308.                FRAC . . . . . . . . . . . . . . . . . . . . . . . .  69
  309.                FACT . . . . . . . . . . . . . . . . . . . . . . . .  69
  310.                SQR  . . . . . . . . . . . . . . . . . . . . . . . .  69
  311.                SQRT . . . . . . . . . . . . . . . . . . . . . . . .  69
  312.           Trigo & logarithm functions . . . . . . . . . . . . . . .  69
  313.                SIN  . . . . . . . . . . . . . . . . . . . . . . . .  69
  314.                COS  . . . . . . . . . . . . . . . . . . . . . . . .  69
  315.                TAN  . . . . . . . . . . . . . . . . . . . . . . . .  69
  316.                ASIN . . . . . . . . . . . . . . . . . . . . . . . .  69
  317.                ACOS . . . . . . . . . . . . . . . . . . . . . . . .  69
  318.                ATAN . . . . . . . . . . . . . . . . . . . . . . . .  69
  319.                LOG  . . . . . . . . . . . . . . . . . . . . . . . .  69
  320.                LN . . . . . . . . . . . . . . . . . . . . . . . . .  69
  321.                EXP  . . . . . . . . . . . . . . . . . . . . . . . .  69
  322.                RAD_DEG  . . . . . . . . . . . . . . . . . . . . . .  69
  323.                DEG_RAD  . . . . . . . . . . . . . . . . . . . . . .  69
  324.           DATE functions  . . . . . . . . . . . . . . . . . . . . .  69
  325.                DATE . . . . . . . . . . . . . . . . . . . . . . . .  69
  326.                DAY  . . . . . . . . . . . . . . . . . . . . . . . .  69
  327.                MONTH  . . . . . . . . . . . . . . . . . . . . . . .  69
  328.                YEAR . . . . . . . . . . . . . . . . . . . . . . . .  69
  329.           Matrix functions  . . . . . . . . . . . . . . . . . . . .  69
  330.                INVERSE  . . . . . . . . . . . . . . . . . . . . . .  69
  331.                TRANSPOSE  . . . . . . . . . . . . . . . . . . . . .  69
  332.      Statistics . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  333.           AVERAGE . . . . . . . . . . . . . . . . . . . . . . . . .  70
  334.           MEDIAN  . . . . . . . . . . . . . . . . . . . . . . . . .  70
  335.           STD . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  336.           VAR . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  337.           SQR_SUM . . . . . . . . . . . . . . . . . . . . . . . . .  70
  338.  
  339.                                  - iv -
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.      Miscellaneous  . . . . . . . . . . . . . . . . . . . . . . . .  70
  351.           MAX . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  352.           MIN . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  353.           SUM . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  354.           RAND  . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  355.           IFF . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  356.           ISEMPTY . . . . . . . . . . . . . . . . . . . . . . . . .  70
  357.           TRUE  . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  358.           FALSE . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  359.           ALERT . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  360.           COL_WIDTH . . . . . . . . . . . . . . . . . . . . . . . .  71
  361.           LAST_ROW  . . . . . . . . . . . . . . . . . . . . . . . .  71
  362.           LAST_COL  . . . . . . . . . . . . . . . . . . . . . . . .  71
  363.           SEARCH  . . . . . . . . . . . . . . . . . . . . . . . . .  71
  364.      Finance  . . . . . . . . . . . . . . . . . . . . . . . . . . .  71
  365.           Future growth . . . . . . . . . . . . . . . . . . . . . .  71
  366.                GRATE  . . . . . . . . . . . . . . . . . . . . . . .  71
  367.                GBASE  . . . . . . . . . . . . . . . . . . . . . . .  71
  368.                GFUTURE  . . . . . . . . . . . . . . . . . . . . . .  71
  369.           Investment  . . . . . . . . . . . . . . . . . . . . . . .  71
  370.                INVEST_PV  . . . . . . . . . . . . . . . . . . . . .  71
  371.                INVEST_FV  . . . . . . . . . . . . . . . . . . . . .  72
  372.                INVEST_INTEREST  . . . . . . . . . . . . . . . . . .  72
  373.                INVEST_TERM  . . . . . . . . . . . . . . . . . . . .  72
  374.           Loan  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  375.                LOAN_PAY . . . . . . . . . . . . . . . . . . . . . .  72
  376.                LOAN_AMOUNT  . . . . . . . . . . . . . . . . . . . .  72
  377.                LOAN_TERM  . . . . . . . . . . . . . . . . . . . . .  72
  378.           Withdraw  . . . . . . . . . . . . . . . . . . . . . . . .  72
  379.                WDRAW_SAVE . . . . . . . . . . . . . . . . . . . . .  72
  380.                WDRAW_AMOUNT . . . . . . . . . . . . . . . . . . . .  72
  381.                WDRAW_TERM . . . . . . . . . . . . . . . . . . . . .  72
  382.           Deposit . . . . . . . . . . . . . . . . . . . . . . . . .  72
  383.                DEPOSIT_FV . . . . . . . . . . . . . . . . . . . . .  72
  384.                DEPOSIT_AMOUNT . . . . . . . . . . . . . . . . . . .  72
  385.                DEPOSIT_TERM . . . . . . . . . . . . . . . . . . . .  72
  386.      String functions:  . . . . . . . . . . . . . . . . . . . . . .  72
  387.           FILENAME$ . . . . . . . . . . . . . . . . . . . . . . . .  72
  388.           BUF$  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  389.           MID$  . . . . . . . . . . . . . . . . . . . . . . . . . .  72
  390.           LEFT$ . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  391.           RIGHT$  . . . . . . . . . . . . . . . . . . . . . . . . .  73
  392.           SPACE$  . . . . . . . . . . . . . . . . . . . . . . . . .  73
  393.           CHR$  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  394.           STR$  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  395.           VAL . . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  396.           LEN:  . . . . . . . . . . . . . . . . . . . . . . . . . .  73
  397.           POS . . . . . . . . . . . . . . . . . . . . . . . . . . .  74
  398.  
  399. Appendix B CONTROL KEYS . . . . . . . . . . . . . . . . . . . . . .  74
  400.      Non-editing  . . . . . . . . . . . . . . . . . . . . . . . . .  74
  401.      Editing  . . . . . . . . . . . . . . . . . . . . . . . . . . .  75
  402.  
  403. Appendix C Program specification  . . . . . . . . . . . . . . . . .  75
  404.  
  405. Appendix D Lotus and SHEET  . . . . . . . . . . . . . . . . . . . .  76
  406.  
  407.                                   - v -
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. Appendix E Recalculation  . . . . . . . . . . . . . . . . . . . . .  77
  420.  
  421. Appendix F FILE FORMAT  . . . . . . . . . . . . . . . . . . . . . .  78
  422.      Header for SHT . . . . . . . . . . . . . . . . . . . . . . . .  78
  423.      Cell contents for SHT format . . . . . . . . . . . . . . . . .  78
  424.      Header for PRT . . . . . . . . . . . . . . . . . . . . . . . .  78
  425.      Cell contents for PART format  . . . . . . . . . . . . . . . .  78
  426.  
  427. Appendix G Problems . . . . . . . . . . . . . . . . . . . . . . . .  78
  428.  
  429. Biorthym program  . . . . . . . . . . . . . . . . . . . . . . . . .  80
  430.  
  431. Calendar program  . . . . . . . . . . . . . . . . . . . . . . . . .  82
  432.  
  433. Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  84
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.                                  - vi -
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  SHEET User manual             By Chor-ming Lung                October 9,
  487. 1988
  488.  
  489. Preface:
  490. ________
  491.           I have  used spreadsheet  programs for  quite a while. I feel
  492.      they are fantastic tools. I am quite familiar with Lotus  123. One
  493.      thing that  I feel  terrible is  its MACRO  language. It is not as
  494.      user-friendly as its display. I feel  that BASIC  is more powerful
  495.      and yet easier to use than MACRO.
  496.  
  497.           Thinking that  may be profitable to write a BASIC interpreter
  498.      in a spreadsheet environment,  I started  to write  the program on
  499.      Oct.  1987.  After  a  few  months'  struggle,  I have created the
  500.      program and named it SHEET.
  501.  
  502.           Making SHEET as shareware,  I uploaded  the first  version on
  503.      February 1988 to GEnie and CompuServe. Right now, SHEET can do not
  504.      only numerical calculation, but  also, graphic,  string operations
  505.      and text  files access. Its growth depends on you. If you like it,
  506.      please send me $25 or whatever you think  it is  worth. My address
  507.      is:
  508.  
  509.                           Mr. Chor-ming Lung
  510.                          330 Tremont St A-708
  511.                            Boston, MA 02116
  512.                                 U.S.A.
  513.  
  514.           You can  also send  your comments or suggestions by Email. My
  515.      addresses are:
  516.                               GEnie: LUNG
  517.                          CompuServe: 72740,40
  518.  
  519.           If you have access of GEnie, you can also leave  your message
  520.      on the bulletin board. It is Page 475, Category 2, Topic 28.
  521.  
  522.  
  523. Disclaimer:
  524. __________
  525.           I  have  made  every  effort  to  insure  the accuracy of the
  526.      program. However, there is no warranty  either express  or implied
  527.      for its uses.
  528.  
  529.  
  530. Requirements:
  531. ____________
  532.      * Atari 520 ST or 1040 ST with disk drive(s).
  533.      * Monochrome or color monitor.
  534.      * SHEETxxx.PRG, CALC.RSC and SHEET.CFG on the same directory. (xxx
  535.        is the version number of SHEET. Currently, it  is SHEET20.PRG or
  536.        version 2.0)
  537.      * You must know how to operate with GEM.
  538.      * Some BASIC programming experience is desirable if you want to
  539.        use SHEET BASIC effectively.
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.                                 Page 1
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  SHEET User manual             By Chor-ming Lung                October 9,
  559. 1988
  560.  
  561. Introduction:
  562. ____________
  563.  
  564.      Thank you  for using  SHEET. SHEET is a combination of spreadsheet
  565. and BASIC. The  spreadsheet  functions  and  commands  make  this BASIC
  566. interpreter a  lot easier to handle data and the BASIC interpreter make
  567. the spreadsheet a lot powerful  than  many  other  spreadsheet programs
  568. commercially available.
  569.  
  570.      The arrangement  of this manual consists of three parts. The first
  571. part consists of 9 example worksheets  as a  tutorial. The  second part
  572. shows the details of how to use the spreadsheet commands. The last part
  573. consists of BASIC commands and their usage.
  574.  
  575.      If you have problems in locating cell cursor  with the  mouse, you
  576. should  read  Appendix  G.  You  should  read  example 1 thoroughly. It
  577. contains informations for operating the  spreadsheet.  Example  3  is a
  578. trivial  program  but  it  is  an  important  one  too.  If  you do not
  579. understand the  cell  reference  method  in  this  program.  You cannot
  580. understand the  rest examples.  I have tried my best to describe how it
  581. works. If you still have problem, you should  read PART  III about cell
  582. reference.
  583.  
  584.      There are  three "big" program listings after the Appendixes. They
  585. use many commands of SHEET BASIC. You should not miss them too.
  586.  
  587.      Finally,  I  would  like  to  thank  all  the  users  who  provide
  588. suggestions to make SHEET more useful and reliable. I like to thank Mr.
  589. Donald A. Edwards and  Dr. Stan  Liebowitz specifically.  Without their
  590. enthusiasm, I  can hardly imagine some of the features found in version
  591. 2.0. If you have made suggestions but they are not  implemented yet, it
  592. is not  because they  are being  ignored. Instead, I do not have enough
  593. time to get everything done on this version.
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.                                 Page 2
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  SHEET User manual             By Chor-ming Lung                October 9,
  629. 1988
  630.  
  631.                           PART I -- TUTORIAL
  632.  
  633. Example 1: "AMORT.SHT"
  634.           This example shows you how to  operate with  SHEET. A  lot of
  635.      the basic  ideas of  how to  use the  mouse and your keyboard with
  636.      your worksheet are being introduced. If you understand it, you can
  637.      read PART II without any difficulty.
  638.  
  639. Example 2: "ROSES.SHT"
  640.           This example  shows you  some advanced feature of spreadsheet
  641.      design. It introduces  the  idea  of  absolute  and  relative cell
  642.      reference.
  643.  
  644. Example 3: "RANDOM.SHT"
  645.           This example  is a  simple SHEET BASIC program. The main idea
  646.      introduces in this example is a new cell reference method. You can
  647.      use  the  cell  as  a  cell  reference  or as a BASE which you can
  648.      stretch horizontally or vertically.
  649.  
  650. Example 4: "LOTTERY.SHT"
  651.           This example shows you  how  to  print  your  output  to your
  652.      printer. It  generates 6 different numbers from 1 to 36, and sorts
  653.      those numbers in ascending order, and then prints those numbers to
  654.      your printer.
  655.  
  656. Example 5: "FTEST.SHT"
  657.           This file shows you the commands for ASCII file accesses.
  658.  
  659. Example 6: "NUMBER.SHT"
  660.           This file  shows you  how to  use the file access commands to
  661.      retrieve  data  stored  in  ASCII  file  and  then  put  them into
  662.      individual cells.
  663.  
  664. Example 7: "GRID.SHT"
  665.           This first  graphic program  shows the basic process of using
  666.      the graphic commands.
  667.  
  668. Example 8: "SINCURVE.SHT"
  669.           This file shows you how to draw a sine curve with the graphic
  670.      commands.
  671.  
  672. Example 9: "SPLINE.SHT"
  673.           This file  shows you  how to  draw graph using data stored in
  674.      your worksheet.
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.                                 Page 3
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  SHEET User manual             By Chor-ming Lung                October 9,
  698. 1988
  699.  
  700.  
  701. Example 1:
  702. _________      AMORT.SHT
  703.  
  704.           Amortization means killing something bit by bit. That  is the
  705.      way we handle loans -- we pay little by little.
  706.  
  707.           Suppose  you  are  trying  to borrow $100,000. Your financial
  708.      company provides two options for this loan.
  709.           -    30 years with annual interest rate 9%
  710.           -    20 years with annual interest rate 10.5%
  711.      Intuitively, you may choose  option 1.  Well, let  us analyze this
  712.      problem with SHEET and see whether it is a wise choice.
  713.  
  714.           First, we  have to design our layout. We plan to use column A
  715.      for labels, column B for option  1  and  column  C  for  option 2.
  716.      Following are the steps for creating the template:
  717.  
  718.           Cell entry     Cell cursor    Menu option/Description
  719.      ---------------------------------------------------------
  720.                                         Find  menu  title  "Sheet"  and
  721.                                         select "Defaults".  Choose Text
  722.                                         justification  for  Center  (^)
  723.                                         and select OK.
  724.                          B1             To move your cell cursor to B1,
  725.                                         either move the mouse cursor to
  726.                                         B1 and click the  mouse button,
  727.                                         or use  the arrow  keys to move
  728.                                         the cell cursor. If you use the
  729.                                         mouse to  move your cell cursor
  730.                                         and   if    the   cell   cursor
  731.                                         disappears,   then  you  should
  732.                                         refer to Appendix F.
  733.           Option 1<Return>              Type "Option  1"  and terminate
  734.                                         it with <Return> key.
  735.                          C1             Press the  -> arrow key to move
  736.                                         from cell B1 to C1.
  737.           Option 2<Return>
  738.                          B2
  739.           \-<Return>                    Type "\-" and terminate it with
  740.                                         <Return> key.
  741.                          C2
  742.           \-<Return>
  743.                                         Find  menu  title  "Sheet"  and
  744.                                         choose "Defaults".  Choose Text
  745.                                         justification for Right (")
  746.                          A3
  747.           Amount borrowed<Return>
  748.                          A4
  749.           Annual interest rate<Return>
  750.                          A5
  751.           Total number of terms<Return>
  752.                          A6
  753.           Terms per year<Return>
  754.                          A7
  755.  
  756.                                 Page 4
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  SHEET User manual             By Chor-ming Lung                October 9,
  768. 1988
  769.  
  770.           \-<Return>
  771.                          B7
  772.           \-<Return>
  773.                          C7
  774.           \-<Return>
  775.                          A8
  776.           Payment<Return>
  777.  
  778.  
  779.  
  780.           "\-" means  to fill  up the  cell with "-". You should notice
  781.      that entries on column A occupy some areas of column  B and  C. We
  782.      need to enlarge the width of column A to make rooms for entries on
  783.      column B and C. To widen  column A,  you need  to place  the mouse
  784.      pointer within  the gap  between column  letter A and B. Press the
  785.      mouse button and drag it to the right hand side. (Alternately, you
  786.      can select  the menu  item "Col widths", enter the column name and
  787.      your desired width.) When you press and drag you mouse, you should
  788.      see the  rubber box  expanding.  If the rubber box is large enough
  789.      to cover all the characters of column A, then you can release your
  790.      mouse button. Every text in column A is right justified now.
  791.  
  792.           Well, a  template without  formulas is not a template at all.
  793.      The formula we need for this  calculation is  "LOAN_PAY". It needs
  794.      four arguments  --   amount borrowed,  annual interest rate, total
  795.      number of terms, terms per year.  That is "LOAN_PAY(B3,B4,B5,B6)".
  796.      If you enter the above line into cell B8, SHEET will treat it as a
  797.      TEXT string  instead  of  formula.  That  is  because  the leading
  798.      character of  a cell entry determines its type. A cell starts with
  799.      "+", "-", digit, "(" or "." is a formula. A cell starts with alpha
  800.      character is  a TEXT  string. A  '+' symbol before "LOAN_PAY" will
  801.      tell SHEET to treat it as  a formula.  (NOTE: If  you are  used to
  802.      Lotus  123,  you  may  tempt  to add @ symbol before "LOAN_PAY". @
  803.      symbol in SHEET has different meaning. All the  functions in SHEET
  804.      does  not  require  @  symbol.)  Here  is  the  steps for entering
  805.      "+loan_pay(b3,b4,b5,b7)" on cell B8 and copy the content  of B8 to
  806.      C8.
  807.  
  808.  
  809.           Entry     Mouse     Mouse button   Editing buffer
  810.                     cursor                   display
  811.      --------------------------------------------------------------
  812.           +loan_pay(                         +loan_pay(
  813.                     B3
  814.                               Mouse click    +loan_pay(B3
  815.                     B4
  816.           <Control>+          Mouse click    +loan_pay(B3,B4
  817.                     B5
  818.           <Control>+          Mouse click    +loan_pay(B3,B4,B5
  819.                     B6
  820.           <Control>+          Mouse click    +loan_pay(B3,B4,B5,B6
  821.           )                                  +loan_pay(B3,B4,B5,B6)
  822.           <Return>
  823.                     B8
  824.  
  825.                                 Page 5
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  SHEET User manual             By Chor-ming Lung                October 9,
  837. 1988
  838.  
  839.           <Control>+          Mouse click
  840.                     C8
  841.           <Control>+          Mouse click
  842.           <Control C>
  843.           <Return>
  844.  
  845.  
  846.  
  847.      "<Control>+Mouse click" means press the Control key and left mouse
  848.      button simultaneously.  SHEET  is case-insensitive.  It will treat
  849.      "loan_pay"  as  "LOAN_PAY".  After  those  steps,  you  should see
  850.      0.1e+38 on both B8 and C8. Don't panic. You are not suppose to pay
  851.      that  much  money  even  you    borrow  nothing. This number means
  852.      calculation  error.  During  calculation,  Lotus  uses   11  bytes
  853.      (instead of  8 bytes) to store real number. Special bit pattern is
  854.      set in these 11 bytes to  represent ERR.  Unfortunately, I  do not
  855.      have that  much energy to create my own math package. So, I choose
  856.      the largest number to represent error.
  857.  
  858.           It seems column B and column C are  too close  to each other.
  859.      You should  be able  to change  the column width of column B and C
  860.      without any difficulty now. How wide should they  be? It  is up to
  861.      you.
  862.  
  863.  
  864.           It is time to enter our data to do analysis.
  865.  
  866.           Entry          Cell cursor
  867.      -----------------------------------
  868.                          B3
  869.           100000 <Down arrow>
  870.                          B4
  871.           0.09 <Return>
  872.                          B5
  873.           360 <Return>
  874.                          B6
  875.           12 <Return>
  876.  
  877.  
  878.  
  879.           After you  have typed 100000, you terminate your input by the
  880.      down arrow key. This action changes the editing direction to DOWN.
  881.      Whenever you  terminate your  input with <Return>, the cell cursor
  882.      will automatically move DOWN.  B3 holds  the $100,000  you want to
  883.      borrow. B4  holds the  annual interest rate 9%. B5 holds the total
  884.      number of terms you must pay back to your financial company. It is
  885.      supposed to  be a  monthly payment.  You have to pay 12 times each
  886.      year. Hence, the total number is 30*12 or 360. B6 holds the number
  887.      of terms  per year.  It is  12. NOTE: if your payment is collected
  888.      quarterly, then B6 should be 4 and B5 should be 30*4 or 120.
  889.  
  890.           It is an exercise for you to enter 100000, 0.105,  240 and 12
  891.      into cells  C3, C4,  C5, and C6 are  respectively. The payment for
  892.      option 1 is 804.622617 and it is 998.379887 for option 2. Probably
  893.  
  894.                                 Page 6
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  SHEET User manual             By Chor-ming Lung                October 9,
  906. 1988
  907.  
  908.      your financial  company will  ask you  to pay  $804.62 and $998.38
  909.      respectively.  To  reflect  this  fact,  you  must  reformat  your
  910.      display. We  need to change B3..C3 and B8..C8 to DOLLAR format and
  911.      B4..C4 to percent (%) format.
  912.  
  913.  
  914.  
  915.           Key       Mouse button   Mouse cursor position
  916.      ----------------------------------------------------
  917.                                    B3
  918.           <Control>+Mouse click
  919.                                    C3
  920.           <Shift>+  Mouse click
  921.                                    B8
  922.           <Control>+Mouse click
  923.                                    C8
  924.           <Shift>+  Mouse click
  925.           <Control R>
  926.                     Select DOLLAR
  927.  
  928.  
  929.  
  930.           The above operations define two blocks. <Control>+mouse click
  931.      on a  cell defines the start of a block and <Shift>+Mouse click on
  932.      a cell defines the end of a block. The first  block is  B3..C3 and
  933.      the  second  block  is  B8..C8. <Control R> activates the reformat
  934.      dialog box. Selection DOLLAR will change cells contained  in those
  935.      blocks to DOLLAR format. I think it is an easy exercise for you to
  936.      change B4..C4 to percent format.
  937.           The payment just tells us we need to pay more for less terms.
  938.      That is  natural. The hidden truth is: we pay more money in option
  939.      1 than option 2.  How can  we find  it? Well,  we pay  804.62 each
  940.      month, and we need to do it 360 times. So, the total amount we pay
  941.      for option 1 is 360*804.62, and 240*998.38 for  option 2.  In cell
  942.      A9, enter  "Total payment".  In B9,  enter 360*b8 and in C9, enter
  943.      240*c8. Comparing the results on B9 and C9, you will  find you pay
  944.      $50,000 less in option 2. So, if you can affort $998.38 per month,
  945.      you should choose option 2.
  946.  
  947.           Now, it  is up  to you  whether you  want to  save your first
  948.      worksheet.  If  you  think  you  don't need it any more. Press the
  949.      window close button and SHEET will give you a last  chance to save
  950.      it. If  you want to save it for future reference, you should press
  951.      <Control S> and enter the file  name in  the file  selector dialog
  952.      box.
  953.  
  954.           You may  even want  to print  it out to show your spouse that
  955.      his/her decision is right or wrong. The following steps will print
  956.      cells A1..C10.
  957.           Key       Mouse button   Mouse cursor
  958.      ----------------------------------------------------
  959.                                    A1
  960.           <Control>+Mouse click
  961.                                    C10
  962.  
  963.                                 Page 7
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  SHEET User manual             By Chor-ming Lung                October 9,
  975. 1988
  976.  
  977.           <Shift>+  Mouse click
  978.           <Control P>
  979.           Fill out the Print dialog box
  980.           <Return>
  981.  
  982.  
  983.  
  984.  
  985.      After this  example, I assume you can operate this program without
  986. any difficulty. The  tedious  description  of  cell  entries  and mouse
  987. operations will not appear in the following examples.
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.                                 Page 8
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  SHEET User manual             By Chor-ming Lung                October 9,
  1044. 1988
  1045.  
  1046.  
  1047. Example 2:
  1048. _________      ROSES.SHT
  1049.  
  1050.           This  is  an  inventory  problem. Assume that you are selling
  1051.      roses. Each dozen costs 4  dollars  and  you  are  selling  for 12
  1052.      dollars per dozen. According to your pass experience, you know the
  1053.      probabilities you can sell 10 dozens, 11 dozens, 12 dozens  in one
  1054.      day  are  0.60,  0.23,  0.17.  How many dozens of roses should you
  1055.      order to get the best profit?
  1056.  
  1057.        PROFIT= 12 * actual number of dozens sold - 4 * number of dozens
  1058.                ordered
  1059.  
  1060.      For example, if you order 11 dozens and you sell only 10 dozens of
  1061.      them, then you earn:
  1062.           PROFIT = 12*10-4*11=76
  1063.  
  1064.      Here  we  need  to  create  the   array  of   profits  for  actual
  1065.      calculation.
  1066.  
  1067.           ordered/  10   11   12
  1068.           sold
  1069.           10        80   76   72
  1070.           11        80   88   84
  1071.           12        80   88   96
  1072.  
  1073.      You may  ask what  is the  meaning of  ordered 10  and sold 11? It
  1074.      means you  sell all  the 10  dozens of  roses and  still there are
  1075.      customers  asking  for  roses.  The  number of roses sold includes
  1076.      actual number  of  dozens  sold  and  number  of  dozens customers
  1077.      asking. If  you have  sold all the roses you have, you cannot give
  1078.      anything to the late customers. So, your profit is 12*10-4*10=80.
  1079.  
  1080.      If you are using calculator to find out those number, then you are
  1081.      not a  good spreadsheet  user. To  calculate the profit table, you
  1082.      must use formula. Now, we  assume  that  the  numbers  ordered are
  1083.      stored from  C1..E1 and  the numbers  sold are stored from B3..B5.
  1084.      The function we need is IFF which means IF Function (I choose this
  1085.      name because  IF is  a reserved key word for BASIC). This function
  1086.      require 3 arguments. The  first one  is a  conditional expression,
  1087.      the second  one is  an expression  returned when  the condition is
  1088.      true, the last one is an expression returned when the condition is
  1089.      false.
  1090.  
  1091.      Here is  the logic:  IF the  number of  dozens we order is greater
  1092.      than the number of dozens we sell, we use the following formula to
  1093.      calculate PROFIT:
  1094.           PROFIT = 12 * dozens ordered - 4 * dozens sold
  1095.      That is  because we can sell no more than we ordered. On the other
  1096.      hand, if the number  of dozens  we order  is not  greater than the
  1097.      number of  dozens we sell, then we can sell as many as we can. The
  1098.      PROFIT will be:
  1099.           PROFIT = 12 * dozens sold - 4 * dozens ordered
  1100.  
  1101.  
  1102.                                 Page 9
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  SHEET User manual             By Chor-ming Lung                October 9,
  1114. 1988
  1115.  
  1116.      So, we enter the following formula in C3:
  1117.           +IFF(C1<B3,12*C1-4*C1,12*B3-4*C1)
  1118.  
  1119.      Now, we can copy this formula to the rest of  the table.  The COPY
  1120.      command does not handle overlap cells correctly. So, we need to do
  1121.      it twice. The first COPY copies  C3 to  C4..C5 and  the second one
  1122.      copies C3 to D3..E5.
  1123.  
  1124.      If you compare the result you get from SHEET with the above table,
  1125.      you may say, column C is correct, but  column D  and E  is totally
  1126.      different. What  is wrong?  Let us examine the content in cell D3.
  1127.      It is:
  1128.           +IFF(D1<C3,12*D1-4*D1,12*C3-4*D1)
  1129.      COPY command will copy  the source  to destination  and modify the
  1130.      destination cell  if its content refers to other cells. The column
  1131.      letter in C3 is increased by one in  D3. Let  us examine  the cell
  1132.      content in cell D4. It is:
  1133.           +IFF(D2<C4,12*D2-4*D2,12*C4-4*D2)
  1134.      In cell  D4, not  only the  column letter changes but also the row
  1135.      number changes. Well,  the  cell  reference  we  choose  is called
  1136.      relative cell reference. We want COPY command just changes what we
  1137.      want but not every cell reference. To do this, we need to  add a $
  1138.      symbol before  the column  letter or the row number. The corrected
  1139.      formula for cell B3 should be:
  1140.           +IFF(C$1<$B3,12*C$1-4*C$1,12*$B3-4*C$1)
  1141.      and you should do the COPY again.
  1142.  
  1143.      Now, we need to find the EXPECTED PROFIT. It is:
  1144.           EP = prob selling 10 * PROFIT selling 10 + prob selling  11 *
  1145.                PROFIT selling 11 + prob selling 12 * PROFIT selling 12
  1146.      You can  setup the one formula and copy it to find EP for ordering
  1147.      10, 11 and 12.  But  you  can  also  use  the  MATRIX  function to
  1148.      calculate it  easily. Assume  we put the probabilities (0.6, 0.23,
  1149.      0.17) in cells C7..E7. Enter  "Expected  profit"  in  cell  A8 and
  1150.      enter the  formula "+matrix(c8,[c7..e7]*[c3..e5])  in cell A7. You
  1151.      should get 80, 80.8 and 78.84 in cells  C8..E8. Hence  to get more
  1152.      profit, you should order 11 dozens of roses.
  1153.  
  1154.  
  1155.  
  1156.  
  1157.      The above  two examples  show you  some fundamental operations and
  1158. calculations for using SHEET. The following examples will  show you how
  1159. to program in SHEET BASIC. Some BASIC experience is required.
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.                                 Page 10
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  SHEET User manual             By Chor-ming Lung                October 9,
  1183. 1988
  1184.  
  1185.  
  1186. Example 3
  1187. _________      RANDOM.SHT
  1188.  
  1189.           Now,  I  am  going  to  show  you  the  unusual  part of this
  1190.      spreadsheet program  -- the  BASIC interpreter.  This example will
  1191.      generate  100  random  numbers  and calculate the AVERAGE, MEDIAN,
  1192.      MINIMUM,  MAXIMUM,  VARIANCE  and  STANDARD  DEVIATION   of  those
  1193.      numbers.  "C1        :  !R=0" means that cell C1 has the statement
  1194.      "!R=0". If you want to enter the program yourself, you should move
  1195.      your cell  cursor to  C1 and  then enter "!R=0" without the double
  1196.      quotes.    To  run  the  following  BASIC  program,   please  load
  1197.      "RANDOM.SHT" and enter "@run c1" without the double quotes in your
  1198.      editing buffer.
  1199.  
  1200. C1    : !R=0
  1201. C2    : ! LOOP
  1202. C3    : ! EXIT  IF R=100
  1203. C4    : !A1[0,R]= RAND
  1204. C5    : !R=R+1
  1205. C6    : ! ENDLOOP
  1206. C7    : !B3= AVERAGE(A1..A100)
  1207. C8    : !B4= STD(A1..A100)
  1208. C9    : !B5= VAR(A1..A100)
  1209. C10   : !B6= MIN(A1..A100)
  1210. C11   : !B7= MAX(A1..A100)
  1211. C12   : !B8= MEDIAN(A1..A100)
  1212.  
  1213.           The above listing  is  printed  by  SHEET.  Here  is  a brief
  1214.      explanation for each line.
  1215.  
  1216. C1:  R is  a variable  and its  content is initialized to 0. There is a
  1217.      fundamental difference between SHEET  BASIC and  traditional BASIC
  1218.      in  handling  variables  --  YOU MUST initialize all the variables
  1219.      first. If any calculation  involved with  uninitialized variables,
  1220.      you will  be flagged and SHEET BASIC will terminate its operation.
  1221.      Other BASICs treat uninitialized variables as zero. You may have a
  1222.      hard time  to check  typo errors.  So, I FORCE users to initialize
  1223.      variables to eliminate this problem.
  1224. C2:  LOOP is not available in other  BASICs. This  flow control command
  1225.      is from  Modula-2. I  think sometimes  it is  better than WHILE ..
  1226.      WEND.
  1227. C3:  EXIT IF is part of LOOP statement. It is an exit for  the LOOP. If
  1228.      the  conditional  expression  for  EXIT  IF is true, then the next
  1229.      command being executed is the one following ENDLOOP.
  1230. C4:  RAND is the random number generating function. The  left hand side
  1231.      of  the  assignment  statement  is  A1[0,R]  which is a new way to
  1232.      access or store result in cells. We treat cells in  spreadsheet as
  1233.      two  dimensional  array.  You  can  use  the column letter and row
  1234.      number as a cell reference or use the cell reference as a BASE and
  1235.      increases  the  BASE  vertically  or  horizontally by two numbers.
  1236.      These two numbers are separated by comma and  embraced by  "[" and
  1237.      "]". For  example A2[3,4]  is equivalent  to D6. (We assume column
  1238.      letter A is 1 and B  is  2  and  so  on.  A2=[1,2]  and  A2[3,4] =
  1239.      [1,2]+[3,4] =  [4,6]= D6).  In the above listing, if R=12, A1[0,R]
  1240.  
  1241.                                 Page 11
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  SHEET User manual             By Chor-ming Lung                October 9,
  1253. 1988
  1254.  
  1255.      is referred to cell A13 (A1[0,12] = [1,1]+[0,12] = [1,13] = A13).
  1256. C5:  Increase the variable R by one.
  1257. C6:  ENDLOOP statement will force the BASIC  interpreter jumps  back to
  1258.      C3 and test whether R=100. If it is, then the next statement being
  1259.      executed is in C7.
  1260. C7:  Stores the AVERAGE values of the 100 random number in cell B3
  1261. C8:  Stores the STANDARD DEVIATION in cell B4
  1262. C9:  Stores the VARIANCE in cell B5
  1263. C10: Stores the minimum value to B6
  1264. C11: Stores the maximum value to B7
  1265. C12: Stores the MEDIAN in cell B8
  1266.  
  1267.  
  1268.  
  1269.           The logic of the above program will be  more straight forward
  1270.      if we use FOR .. NEXT statement..
  1271.  
  1272.           You  can  generate  100  numbers  by  using  the  spreadsheet
  1273.      commands only.  In cell  A1, enter  "+rand". COPY  a1 to a2..a100.
  1274.      Enter "+average(a1..a100)" in cell b3 and so on.
  1275.  
  1276.  
  1277.           Well, there  are some  difference between these two approach.
  1278.      If you want to get another  set of  random numbers,  you can "@run
  1279.      c1" again. But if you are using the spreadsheet commands, you must
  1280.      COPY it over and  over again  to get  another 100  random numbers.
  1281.      Those AVERAGE,  MIN,MAX ..  functions will hinder your inputs when
  1282.      you are in automatic recalculation mode.
  1283.  
  1284.           If you are programming in traditional  BASICs, you  know that
  1285.      it is  inconvenient to  view the  array which holds the 100 random
  1286.      numbers and you need  to write  a lot  of subroutine  to calculate
  1287.      AVERAGE,MIN,MAX   ....   SHEET   provides   you   the  spreadsheet
  1288.      functionality to help you to handle your date easily and the BASIC
  1289.      interpreter  helps  the  spreadsheet  perform  something that many
  1290.      other spreadsheet users cannot  dream  of.  That  is  some  of the
  1291.      benefit   of   having   a   BASIC  interpreter  in  a  spreadsheet
  1292.      environment.
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.                                 Page 12
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  SHEET User manual             By Chor-ming Lung                October 9,
  1322. 1988
  1323.  
  1324.  
  1325. Example 4:
  1326. _________      LOTTERY.SHT
  1327.           Everyone wants to be rich. Here is a  program in  SHEET BASIC
  1328.      which may  help you  to get  rich. Well, if you do get any profit,
  1329.      please  share  it  with  me  (grin).  This  is  a  lottery numbers
  1330.      generating program. Here is the listing from SHEET.
  1331.  
  1332. C1    : ! REDIRECT  TO "prn:"
  1333. C2    : !R=1
  1334. C3    : ! LOOP
  1335. C4    : !A1[0,R]= INT( RAND*36+1)
  1336. C5    : !J=1:F= TRUE
  1337. C6    : ! LOOP
  1338. C7    : ! EXIT  IF J=R
  1339. C8    : ! IF A1[0,J]=A1[0,R] THEN F= FALSE
  1340. C9    : ! EXIT  IF F= FALSE
  1341. C10   : !J=J+1
  1342. C11   : ! ENDLOOP
  1343. C12   : ! IF F= TRUE THEN R=R+1
  1344. C13   : ! EXIT  IF R=7
  1345. C14   : ! ENDLOOP : SAVE  SCREEN
  1346. C15   : ! SORT "A", A2..A7, A1
  1347. C16   : ! PRINT A2,A3,A4,A5,A6,A7
  1348. C17   : ! WAIT : RESTORE  SCREEN : EXITGRAPH
  1349.  
  1350.      Here is a brief explanation.
  1351. C1:  REDIRECT TO  a file.  This I/O  redirection command causes all the
  1352.      subsequent PRINT commands output to the file specified.  There are
  1353.      some  pre-defined  files.  "prn:"  is  the  printer, "con:" is the
  1354.      monitor and "aux:" is the rs-232 port.
  1355. C2:  R is a loop counter.
  1356. C3:  The outer loop for generating 6 different numbers.
  1357. C4:  INT( RAND*36+1) will generate a random  number from  1 to  36, and
  1358.      this number  is stored  from A2..A7  depends on the value of R. If
  1359.      R=1 then A1[0,R] will be A2  (Remember  A1  is  the  BASE  and its
  1360.      coordinate is [1,1], A1[0,R] = [1,1]+[0,1]=[1,2] = A2).
  1361. C5:  J is another loop counter which increases from 1 to R. F is a flag
  1362.      to see whether the previous generated number has been picked. F is
  1363.      TRUE  means  no  it  is  not.  By the way, TRUE and FALSE are pre-
  1364.      defined constants. TRUE is equal to 1 and FALSE is 0.
  1365. C6:  An inner loop to check whether the last number has been picked.
  1366. C7:  If J=R, it means we check every numbers.
  1367. C8:  Otherwise, compares each old numbers with  the new  number, if one
  1368.      of them are equal to it, then we set F to FALSE
  1369. C9:  Well, this  is the second EXIT IF statement within a LOOP. You can
  1370.      have multiple EXIT IF within a LOOP. There is no limit about it.
  1371. C10: Increase J by 1
  1372. C11: End of the inner loop
  1373. C12: If no numbers is equal, then we request for another random number.
  1374. C13: If 6 numbers have been picked, the loop should be terminated.
  1375. C14: SAVE SCREEN is a command  to  save  your  current  display.  It is
  1376.      useful if you are printing on screen.
  1377. C15: SORT is  a worksheet  command which  sort a block in descending or
  1378.      ascending order. The  first  string  "A"  tells  SORT  to  sort in
  1379.  
  1380.                                 Page 13
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  SHEET User manual             By Chor-ming Lung                October 9,
  1392. 1988
  1393.  
  1394.      ascending order. A2..A7 is the block being sorted and A1 holds the
  1395.      column that we used for determining  the  place  where  we  try to
  1396.      compare.
  1397. C16: PRINT cell  A2 to  A7. You  can use comma or semicolon to separate
  1398.      each item for PRINT statement.  Comma  will  make  the  next print
  1399.      position align to 10 characters wide tab.
  1400. C17: WAIT is  useful when  you output  the data to screen. It stops all
  1401.      the process just wait for you to press <Return> key.  It should be
  1402.      placed before  you restore  your screen.  SORT will not change the
  1403.      appearance of the updated  cells. We  need to  refresh the screen.
  1404.      EXITGRAPH is  a command to refresh the screen. By the way, you can
  1405.      update your screen manually by pressing <Alt-F>.
  1406.  
  1407.  
  1408.           One thing you may notice in this program  is I/O redirection.
  1409.      Here is  a reason why you need to redirect your data to disk file.
  1410.      A user from Canada told me that his  JUKI 6100  Daisywheel printer
  1411.      does not respond to the "end of line" character. So, he prints his
  1412.      worksheet to disk and then use 1st Word  to print  it. If  I don't
  1413.      support I/O redirection in SHEET BASIC, he may need to buy another
  1414.      printer or stop using SHEET..
  1415.  
  1416.           Currently, SHEET BASIC has  command to  redirect output only.
  1417.      Future version should provide input redirection.
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                 Page 14
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  SHEET User manual             By Chor-ming Lung                October 9,
  1461. 1988
  1462.  
  1463. Example 5:
  1464. _________      FTEST.SHT
  1465.  
  1466.           The file  name of  this example  is "FTEST.SHT".  A1..A5 is a
  1467.      program testing the output file  commands.  A7..A13  is  a program
  1468.      testing the  input file  commands. To  run it, enter "@run a1" and
  1469.      "@run a7" separately.
  1470.  
  1471. A1     :! OPEN "o",#1,"test.txt"
  1472. A2     :! PRINT #1,"123,456 789": PRINT #1
  1473. A3     :! PRINT #1,"5623.23,84.38 723.12"
  1474. A4     :! CLOSE #1
  1475. A5     :! END
  1476.  
  1477. A7     :! GET_FILE "\*.txt", FILENAME$
  1478. A8     :! OPEN "i",#1, FILENAME$
  1479. A9     :!R=1: SAVE  SCREEN
  1480. A10    :! LOOP
  1481. A11    :! INPUT #1, BUF$
  1482. A12    :! PRINT  BUF$
  1483. A13    :!R=R+1: ENDLOOP
  1484. A14    :! END
  1485.  
  1486. Explanation:
  1487. Explanation
  1488. A1:  Before we can access a file, we need  to open  it first. Statement
  1489.      A1  open  an  output  file  in  channel  #1  and  the file name is
  1490.      "test.txt". Channel number is in the range of 0~9.
  1491. A2:  Print the string "123,456 789" and a blank line to the file
  1492. A3:  Print another string to the file. You can output not only a string
  1493.      but  also  numeric  data  on  the  same line separated by comma or
  1494.      semicolon.
  1495. A4:  Close channel number 1.
  1496.  
  1497.  
  1498. A7:  Use the file selector  to  get  the  file  name  from  user. Note:
  1499.      FILENAME$ is a string variable that is changed whenever you change
  1500.      the content of the file selector dialog box.
  1501. A8:  Open that file as input file on channel #1
  1502. A9:  R is the counter for line  being  read.  Save  our  current screen
  1503.      first.
  1504. A10: Enter a loop to read the file line by line.
  1505. A11: Read a line from the file to BUF$. BUF$ is a string variable which
  1506.      can be modified by INPUT statement only.
  1507. A12: Print the line being read to the terminal.
  1508. A13: Increase the  counter of  line number  and repeat  the loop. NOTE,
  1509.      there is  no EXIT  IF statement.  There is no way to detect end of
  1510.      file in current SHEET BASIC. You must let it go  forever until the
  1511.      interpreter finds  end of  file error  and stops your program. You
  1512.      may have some extra "Syntax error" errors. It is normal.
  1513.  
  1514. NOTE:     After you are  done,  you  can  enter  the  command "@restore
  1515.           screen" to  restore your screen. Also, program A7 can be used
  1516.           to read other text files. You can even read this  document by
  1517.           choosing  this  file  and  you  can stop and resume the print
  1518.           action by <Ctrl-S> and <Ctrl-Q>.
  1519.  
  1520.                                 Page 15
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  SHEET User manual             By Chor-ming Lung                October 9,
  1532. 1988
  1533.  
  1534. Example 6:
  1535. _________      NUMBER.SHT
  1536.           The file name  for  the  following  program  is "NUMBER.SHT".
  1537.      There  are  two  programs  in  this spreadsheet. The first program
  1538.      generates data to file "test.txt". It is exactly  the same program
  1539.      of Example  5. L7..L16 reads the data from the file "test.txt" and
  1540.      separate each of line into different cells. Subroutine  P1..P11 is
  1541.      used to separate each data into different cells.
  1542.  
  1543. L1     :! OPEN "o",#1,"test.txt"
  1544. L2     :! PRINT #1,"123,456 789": PRINT #1
  1545. L3     :! PRINT #1,"5623.23,84.38 723.12"
  1546. L4     :! CLOSE #1
  1547. L5     :! END
  1548.  
  1549. L7     :! GET_FILE "*.txt", FILENAME$
  1550. L8     :! OPEN "i",#1, FILENAME$
  1551. L9     :!R=0
  1552. L10    :! LOOP
  1553. L11    :! INPUT #1, BUF$
  1554. L12    :! IF ( ASC( BUF$)<>0) THEN  GOSUB P1
  1555. L13    :!R=R+1
  1556. L14    :! ENDLOOP
  1557. L15    :! CLOSE #1
  1558. L16    :! END
  1559.  
  1560. P1     :!P=1:C=1
  1561. P2     :! LOOP
  1562. P3     :!Q= POS(" ,", BUF$,P)
  1563. P4     :! EXIT  IF Q=0
  1564. P5     :!A1[C,R]= VAL( MID$( BUF$,P,Q-P))
  1565. P6     :!C=C+1
  1566. P7     :!P=Q+1
  1567. P8     :! ENDLOOP
  1568. P9     :!A1[C,R]= VAL( MID$( BUF$,P,100))
  1569. P10    :! RETURN
  1570.  
  1571. Explanation:
  1572. Explanation
  1573. L1~L5: It is the same code for Example 5 A1~A5.
  1574. L7:  Uses the file selector to get the file name
  1575. L8:  Open the file for INPUT.
  1576. L9:  R is a counter for row number.
  1577. L10: We enter an infinite loop to read data lines.
  1578. L11: Read a line from the data file.
  1579. L12: Test whether  the line  being read  is empty or not. If it is not,
  1580.      then we call subroutine P1 to separate the data into cells.
  1581. L13: Increase our row number by one.
  1582. L14: Repeat our loop
  1583. L15 and L16 is never being  executed.  They  are  there  for decoration
  1584.      only.
  1585. P1:  P is  the starting  search position and C is the column number. It
  1586.      is zero origin. C=1 means we start from column B.
  1587. P2:  Enter the loop to separate BUF$ into pieces.
  1588. P3:  We assume the number is separate by a blank space or comma. POS is
  1589.      a function  that tries  to find  the position  of a blank space or
  1590.  
  1591.                                 Page 16
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  SHEET User manual             By Chor-ming Lung                October 9,
  1603. 1988
  1604.  
  1605.      comma from BUF$ starting from P. If POS cannot find it, Q  will be
  1606.      zero.
  1607. P4:  Check whether  Q is zero. If it is, then we have checked the whole
  1608.      data line for space and comma and that is the end of our loop.
  1609. P5:  Store the value of BUF$ from P up to Q-1. It depends  on the value
  1610.      of C and R. If C is 1 and R is 0, then the value will be stored in
  1611.      cell B1. (A1[1,0] is equivalent to B1).
  1612. P6:  Increase our column number by one.
  1613. P7:  Change our starting position for P to Q+1
  1614. P8:  Repeat from P2.
  1615. P9:  We still have one value after  the  last  space  or  comma.  It is
  1616.      stored from P to the last character of BUF$. If the len of MID$ is
  1617.      larger than the length of BUF$, then it returns a string from P to
  1618.      the last character of BUF$.
  1619. P10: End our subroutine.
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.                                 Page 17
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  SHEET User manual             By Chor-ming Lung                October 9,
  1672. 1988
  1673.  
  1674.  
  1675. Example 7:
  1676. _________      GRID.SHT
  1677.  
  1678.      This  small  program  shows  the  setup and exit process for using
  1679. graphics in SHEET BASIC. It just  uses window  1 to  draw the  x and y-
  1680. axis then marks them. To run it, enter the command "@run d1"
  1681.  
  1682. D1    : ! WINDOW 1
  1683. D2    : ! SCALE -7,-2,7,2
  1684. D3    : ! CLEAR
  1685. D4    : ! LINE -7,0,7,0: LINE 0,-10,0,10
  1686. D5    : ! MARKX 0,-6,6,0.1,0.5
  1687. D6    : ! MARKY 0,-2,2,0.2,1
  1688. D7    : ! EXITGRAPH
  1689. D8    : ! END
  1690.  
  1691. Explanation:
  1692. Explanation:
  1693. D1:  The first  command for graphics is WINDOW/VIEWPORT. WINDOW 1 means
  1694.      that we are using window 1 for output.
  1695. D2:  Setup the scaling factors. The minimum number for X is  -7 and the
  1696.      maximum number is 7 and -2, 2 for Y.
  1697. D3:  Clear the window being used.
  1698. D4:  Draws the x-axis and y-axis
  1699. D5:  Making marks  on x-axis  from -6 to 6 with increment 0.1. A bigger
  1700.      marker on increment of 0.5.
  1701. D6:  Marks y-axis
  1702. D7:  Legal way to exit from graphics commands
  1703.  
  1704. NOTE:
  1705. ____
  1706.      The first step on graphic command  is WINDOW/VIEWPORT  followed by
  1707. SCALE. After  that, you can enter any graphic commands. After the graph
  1708. is  done,  you  should  use  EXITGRAPH  to  reset  the  clipping  area.
  1709. Otherwise, your screen may seem to be locked up.
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.                                 Page 18
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  SHEET User manual             By Chor-ming Lung                October 9,
  1744. 1988
  1745.  
  1746. Example 8:
  1747. _________      SINCURVE.SHT
  1748.  
  1749.      This example  draws a sine curve on the current window. To run it,
  1750. enter the command "@run a1".
  1751.  
  1752. A1    : ! WINDOW
  1753. A2    : ! SCALE -7,-1.2,7,1.2
  1754. A3    : ! CLEAR
  1755. A4    : ! PLOT -2*PI, SIN(-2*PI)
  1756. A5    : ! FOR X=-2*PI TO 2*PI+0.1 STEP 0.1
  1757. A6    : ! LINE_TO X, SIN(X)
  1758. A7    : ! NEXT X
  1759. A8    : ! LINE -7,0,7,0: LINE 0,-1.2,0,1.2
  1760. A9    : ! MARKX 0,-7,7,0.5,1
  1761. A10   : ! MARKY 0,-1.2,1.2,0.1,0
  1762. A11   : ! LABELX 0,-7,7,1,"f0"
  1763. A12   : ! LABELY 0,-1.2,1.2,0.2,"f2"
  1764. A13   : ! WAIT 5: EXITGRAPH
  1765.  
  1766.  
  1767. Explanation:
  1768. Explanation:
  1769. A1:  WINDOW with  no parameter  means we  are using  current window for
  1770.      output.
  1771. A2:  SCALE for our sine curve.
  1772. A3:  Clear our window
  1773. A4:  Plot the first point of our sine curve
  1774. A5:  A FOR loop to generate a sine wave from -2*PI to 2*PI
  1775. A6:  Instead of  plotting dots,  we want  to connect  all the dots with
  1776.      lines.
  1777. A8:  Draws the x- and y-axis.
  1778. A9:  Marks x-axis
  1779. A10: Marks y-axis
  1780. A11: Draws the labels on x-axis. They  are integers  (f0). F  means the
  1781.      number is  displayed in  fixed format. 0 means decimal place is 0.
  1782.      So, it has no decimal place or it is integer.
  1783. A12: Draws the labels on y-axis. They  are real  number with  2 decimal
  1784.      points.
  1785. A13: Waits for 5 seconds and then refreshes our window.
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.                                 Page 19
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  SHEET User manual             By Chor-ming Lung                October 9,
  1815. 1988
  1816.  
  1817. Example 9:
  1818. _________      SPLINE.SHT
  1819.  
  1820.      This time,  we are  going to  use PLOT  DATA and SPLINE to see how
  1821. wonderful SPLINE will be. This program has a lot of subroutines. I will
  1822. explain each. To run it, enter the command "@run c1".
  1823.  
  1824. F1    : !R=0
  1825. F2    : ! FOR X=-2*PI TO 2*PI+1 STEP 2
  1826. F3    : !J1[0,R]=X:K1[0,R]= SIN(X)
  1827. F4    : !R=R+1
  1828. F5    : ! NEXT X
  1829.  
  1830.      Subprogram F1 generates 7 data sets for sine curve. The data for x
  1831. is stored in cells J1..J7 and data for y is stored in cells K1..K7.
  1832.  
  1833. D1    : ! WINDOW 1
  1834. D2    : ! CLEAR : SCALE -7,-2,7,2
  1835. D3    : ! PLOT  DATA J1..J7,K1..K7,0,1
  1836. D4    : ! GOSUB C13
  1837. D5    : ! RETURN
  1838.  
  1839.      Subroutine D1 plots the  data  stored  in  J1..J7,K1..K7  using no
  1840. marker  and  solid  line.  The  command  PLOT DATA plots data stored in
  1841. worksheet. J1..J7 and K1..K7  for x,y  respectively. 0  means using dot
  1842. instead  of  marker  for  each  point  and  1 means using solid line to
  1843. connect points.
  1844.  
  1845. D7    : ! WINDOW 1
  1846. D8    : ! SCALE -7,-2,7,2
  1847. D9    : ! ATTRIBUTE 1,1
  1848. D10   : ! SPLINE J1..J7,K1..K7,0.1
  1849. D11   : ! RETURN
  1850.  
  1851.      This subroutine draws the spline curve using color  1 (Black). The
  1852. first argument for ATTRIBUTE sets the color to 1 (Black) and using line
  1853. width 1. SPLINE uses cubic-spline method  to draw  smooth curve. J1..J7
  1854. and  K1..K7  define  the  value  for x,y. 0.1 defines the increment for
  1855. generating data on the spline-curve.
  1856.  
  1857. F7    : ! WINDOW 1
  1858. F8    : ! SCALE -7,-2,7,2
  1859. F9    : !X=-2*PI: PLOT X, SIN(X)
  1860. F10   : ! ATTRIBUTE 3,1
  1861. F11   : ! FOR X=-2*PI TO 2*PI STEP 0.1
  1862. F12   : ! LINE_TO X, SIN(X)
  1863. F13   : ! NEXT X
  1864. F14   : ! RETURN
  1865.  
  1866.      Subroutine F7 draws the actual sine curve using color 3 (Green).
  1867.  
  1868. C13   : ! LINE 0,-2,0,2: LINE -7,0,7,0: RETURN
  1869.  
  1870.      Subroutine C13 draws the x- and y-axis
  1871.  
  1872.  
  1873.                                 Page 20
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  SHEET User manual             By Chor-ming Lung                October 9,
  1885. 1988
  1886.  
  1887.  
  1888. C1    : ! GOSUB D1
  1889. C2    : ! GOSUB D7
  1890. C3    : ! GOSUB F7
  1891. C4    : ! WAIT 5
  1892. C5    : ! EXITGRAPH
  1893. C6    : ! END
  1894.  
  1895.      Our main program. First, draws the sine curve with PLOT DATA. Plot
  1896. the sine  curve with  cubic spline  routine, then draws the actual sine
  1897. curve. The sine curve using SPLINE is closer to the  actual sine curve.
  1898. Actually, if  you change  cell F2 with "STEP 1" instead of "STEP 2" and
  1899. change cells D3 and D10 for ranges J1..J14,K1..K14, then you can hardly
  1900. tell the difference between the spline-curve and the actual sine-curve.
  1901. NOTE: the actual sine-curve generates 126 points and  spline-curve uses
  1902. 14 data points! Isn't it wonderful?
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.                                 Page 21
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  SHEET User manual             By Chor-ming Lung                October 9,
  1954. 1988
  1955.  
  1956.  
  1957.                    PART II -- Spreadsheet operations
  1958.  
  1959. MENU SELECTIONS:    Briefly  describes  all  the menu selection and its
  1960.                     usage.
  1961.  
  1962. MOVING AROUND:      This session explains how to move  the working area
  1963.                     to display different part of your worksheet.
  1964.  
  1965. EDITING:            This  session  discusses  about  cell  entries  for
  1966.                     formula,  constant,  text,   BASIC   statement  and
  1967.                     command. It shows you how to use the line editor.
  1968.  
  1969. CUSTOMIZED DISPLAY: This chapter  tells you  how to change the width of
  1970.                     individual  column   and  the   display  format  of
  1971.                     individual  cell.   Block  is  introduced  in  this
  1972.                                         _____
  1973.                     chapter too. Block is  important to  many worksheet
  1974.                     commands.
  1975.  
  1976. COPY AND MOVE:      This  chapter  shows  you  how  to  reorganize your
  1977.                     worksheet. You need to  know how  to select blocks.
  1978.                     It also  discusses about absolute and relative cell
  1979.                     references.
  1980.  
  1981. ERASE CELLS:        This chapter  explains  to  you  how  to  erase the
  1982.                     unnecessary cells.
  1983.  
  1984. INSERT AND DELETE:  This session  discusses how  to delete  or insert a
  1985.                     row  or  a  column.  Column  and  row  selection is
  1986.                     different from block.
  1987.  
  1988. LOAD, SAVE, PRINT:  It explains the menu items under menu title "File".
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.                                 Page 22
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  SHEET User manual             By Chor-ming Lung                October 9,
  2024. 1988
  2025.  
  2026.                             MENU SELECTIONS
  2027.  
  2028.           The menu  titles are the strings that appear on the menu bar.
  2029.               ____________
  2030.      Menu items refer to the strings that drop  down when  a menu title
  2031.      __________
  2032.      is selected.
  2033.  
  2034.      The menu titles for SHEET looks like this:
  2035.             Desk  File  Sheet  Row/Col  Cells  Graph  Help
  2036.             ______________________________________________
  2037.  
  2038.  
  2039.  
  2040. TITLE     ITEM            Description
  2041. --------------------------------------------------------------------
  2042. Desk
  2043. Desk
  2044.           About SHEET    General information about SHEET.
  2045.  
  2046. File
  2047. File                     For a detail description of the following menu
  2048.                          items,  please  refer  to  the  chapter "LOAD,
  2049.                          SAVE, PRINT"
  2050.           New    N       Open  a  new  worksheet  window.  The N on the
  2051.                          right hand side means  that  you  can activate
  2052.                          this  menu  item  by pressing <Control-N>. You
  2053.                          have a choice for changing your  new worksheet
  2054.                          size. The  maximal number of rows can be 50 to
  2055.                          9999.
  2056.           Load   L       Load an old worksheet  file  from  disk drive.
  2057.                          You can  use <Control-L> to activate this menu
  2058.                          item.
  2059.           Load WKS       Load files in the format of  Lotus 123 release
  2060.                          1A or  2. SHEET  is not  a Lotus  clone, so it
  2061.                          will  not  translate  everything.  Whenever it
  2062.                          encounters  problem,  the  translation process
  2063.                          will be terminated.
  2064.           Load PART      Load SHEET files saved  by using  "Save PART".
  2065.                          Its file extension is PRT.
  2066.           Save   S       Save  the   whole  worksheet  file  into  your
  2067.                          diskette.
  2068.           Save WKS       It is supposed to save your worksheet in Lotus
  2069.                          123 file format. It is not working right now.
  2070.           Save PART      Save part of your worksheet into diskette. You
  2071.                          need to  select  blocks  of  cells  before you
  2072.                          activate this menu item.
  2073.           Print  P       Print part  of your worksheet to disk/printer.
  2074.                          You need to select a block before you activate
  2075.                          this menu item.
  2076.           Quit   Q       Quit to desktop.
  2077.  
  2078.  
  2079. Sheet
  2080. Sheet
  2081.           Erase          Erase your current worksheet.
  2082.           Defaults       Set  some  default  states  of  SHEET. You can
  2083.                          change the recalculation order  which is saved
  2084.                          with   your   worksheet,   change   the   TEXT
  2085.                          justication, change the  current  window name,
  2086.                          takes 32K  back for  screen redraw  and have a
  2087.  
  2088.                                 Page 23
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  SHEET User manual             By Chor-ming Lung                October 9,
  2100. 1988
  2101.  
  2102.                          look of the memory remains.
  2103.           Options        In the dialog box  of Options,  you have three
  2104.                          choices.
  2105.                               Users have  suggested for a Global format
  2106.                          for each  column. "Cell  format using previous
  2107.                          row"  means  that  whenever  you  enter  a new
  2108.                          element for the worksheet, it will try to find
  2109.                          the format  of previous row on the same column
  2110.                          and uses it as default format. So, you  do not
  2111.                          need to reformat again and again.
  2112.                               If  you  are  moving  the  worksheet with
  2113.                          arrow keys, you will  find that  moving up and
  2114.                          down  is  a  lot  faster  than moving left and
  2115.                          right. "Move  to left/right  Fast" provides an
  2116.                          option that you can move left and right faster
  2117.                          than before. One drawback  for this  option is
  2118.                          that  the   new  column   being  displayed  is
  2119.                          truncated to its own width. Hence you may have
  2120.                          problem  in  displaying  BASIC program or text
  2121.                          string which spilled over other cells.  If you
  2122.                          want  to  redraw  the  screen  to display them
  2123.                          properly, you can use the command "@exitgraph"
  2124.                          or <Alt-F> to redraw the screen.
  2125.                               Two monochrome users have suggested me to
  2126.                          give an option for  using  the  Small  font to
  2127.                          display more  rows per screen. I have make the
  2128.                          option available but it is not working yet.
  2129.           Dates               SHEET can  display  three  different Date
  2130.                          types.  The  Dates  menu item under menu title
  2131.                          Sheet provides you a new way to show your date
  2132.                          data. The components for a DATE are day, month
  2133.                          and year. Normally, day and year are displayed
  2134.                          as digits. Month can be digit, the first three
  2135.                          characters of the month or the whole alphabets
  2136.                          for  that  month  and some countries put month
  2137.                          before day and some  put day  before month. To
  2138.                          overcome these differences, the date format is
  2139.                          configurable  to   your  favour.   dd  and  yy
  2140.                          represent day and year in digit. mm represents
  2141.                          month in digit. mmm represents month  in three
  2142.                          letters  and  mmmm  represents  month  in full
  2143.                          alphabets. Here are some examples. Assume that
  2144.                          the date is March the first, 1988.
  2145.  
  2146.                          Date format:                   Display:
  2147.                     -------------------------------------------------
  2148.                          mmddyy                        030188
  2149.                          dd-mmm-yy                     01-Mar-88
  2150.                          mmmm dd,19yy                  March 01,1988
  2151.                          dd/mm/yy                      01/03/88
  2152.                          mm/dd/yy                      03/01/88
  2153.  
  2154.                NOTE:     The  file  SHEET.CFG  holds  the  defnition of
  2155.                          Date1, Date2 and Date3. It is updated whenever
  2156.  
  2157.                                 Page 24
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  SHEET User manual             By Chor-ming Lung                October 9,
  2169. 1988
  2170.  
  2171.                          you  change  the  Date format. If SHEET.CFG is
  2172.                          not  there  when  SHEET  is  loaded,  then the
  2173.                          default formats will be used.
  2174.  
  2175. Row/Col
  2176. Row/Col
  2177.           Insert  I      Insert a  row or  a column. You need to select
  2178.                          that particular row/column first. Refer to the
  2179.                          chapter   "INSERT   AND   DELETE"  for  detail
  2180.                          description.
  2181.           Delete  D      Delete a row or a column.  You need  to select
  2182.                          that particular row/column first.
  2183.           Col widths          You can change the column width in a more
  2184.                          effecient way  than just  using mouse dragging
  2185.                          method. For  example, if  you want to make the
  2186.                          column width from  column  A  to  column  O to
  2187.                          1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,  you can select
  2188.                          the menu item  "Col  widths"  from  menu title
  2189.                          "Row/Col",  enter  "A"  for the leading column
  2190.                          and 1,9,1,9,1,9,1,9,1,9,1  in  the  edit field
  2191.                          "widths".
  2192.  
  2193. Cells
  2194. Cells                    NOTE:  YOU  HAVE  TO  SELECT BLOCKS BEFORE YOU
  2195.                          ACTIVATE THE FOLLOWING MENU ITEMS.
  2196.           Reformat  R    Changes the format  of  blocks.  For  a detail
  2197.                          description,   please   refer  to  "CUSTOMIZED
  2198.                          DISPLAY"
  2199.           Erase     E    Erase cells on blocks  specified. Please refer
  2200.                          to "ERASE CELLS".
  2201.           Copy      C    Copy a  block of  cells to other block. Please
  2202.                          refer to "COPY AND MOVE"
  2203.           Move      M    Move a block of cells to other place
  2204.           Adjust    A         Adjust is  used for  changing TEXT string
  2205.                          to   BASIC   statements   or   changing   TEXT
  2206.                          justifications. The first step in using ADJUST
  2207.                          is: Select  the blocks  being ajusted and then
  2208.                          press <Control A> or  select  this  menu item.
  2209.                          You MUST not change TEXT that are not supposed
  2210.                          to be BASIC  statements  to  BASIC statements.
  2211.                          The  program   may  not   recognize  all  your
  2212.                          characters and part of  them may  be truncated
  2213.                          with a character #.
  2214.  
  2215. Graph
  2216. Graph                    This selections is not available yet.
  2217.                          This selections is not available yet.
  2218.           Selections
  2219.           Layout
  2220.           Legend
  2221.           X-axis lable
  2222.           Data Variable A
  2223.           Data Variable B
  2224.           Data Variable C
  2225.           Data Variable D
  2226.           Data Variable E
  2227.           Data Variable F
  2228.  
  2229.  
  2230.                                      Page 25
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  SHEET User manual             By Chor-ming Lung                October 9,
  2242. 1988
  2243.  
  2244. Help
  2245. Help
  2246.           Entry          Helps  for  entering  formula,  text  strings,
  2247.                          BASIC statements and commands.
  2248.           Formula        Helps for formula, especially  for calculation
  2249.                          priority
  2250.           Built-in Func  Helps for built-in functions.
  2251.           Statement      Helps for BASIC statements (v1.6)
  2252.           Limits         Helps  for  program  limit  (accuracy, maximum
  2253.                          numbe of variables and so on)
  2254.           Graphic commands Helps for graphic commands for BASIC (v1.7)
  2255.           PTEXT          Helps  for  the  graphic  command  PTEXT (PLOT
  2256.                          TEXT) (v1.7)
  2257.           Commands       Helps on other new BASIC commands (v2.0)
  2258.           Console  commands   Helps  on  screen  control  and  keyboard
  2259.                          commands. (v2.0)
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.                                 Page 26
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  SHEET User manual             By Chor-ming Lung                October 9,
  2312. 1988
  2313.  
  2314.  
  2315.                              MOVING AROUND
  2316.  
  2317.      When you start SHEET,  your screen  is divided  into menu  bar and
  2318. worksheet  window.  The  worksheet  window  can be divided into 5 major
  2319. areas. The status line is the first line under the window title.  It is
  2320.            ___________
  2321. used for  displaying current  cell's content  and worksheet status. The
  2322. editing buffer ,which is  the  line  below  status  line,  is  used for
  2323. ______________
  2324. entering or  editing the current cell. The column bar is the line below
  2325.                                            __________
  2326. the editing buffer. The row bar is located on the left hand side of the
  2327.                         _______
  2328. worksheet window. Both column and row bars are used for cell reference.
  2329. The biggest area is the working area for current worksheet.
  2330.                         ____________
  2331.  
  2332.      Each column is referred  by a  unique letter  (from A  to IU). The
  2333. first column  is A,  column B  after A,  C after  B and  so on. The one
  2334. following column Z is AA and  after AZ  comes BA,  and so  on. Each row
  2335. numbers are  sequentially ordered  from 1  to a  variety of  50 to 9999
  2336. depends on the worksheet size you  choose. A  cell in  the worksheet is
  2337. referred by  column letter  followed by row number. For example, at the
  2338. intersection of column B and row number 2 is cell B2.
  2339.  
  2340.      Each spreadsheet  can hold  255 columns  and a  variable number of
  2341. rows from  50 to 9999. It means you can access at most 2,549,745 cells.
  2342. Your screen can display a very  small amounts  of them.  Therefore, you
  2343. have to view your spreadsheet by moving the working area. The following
  2344. operations let you move your working  area by  keyboard entry  or mouse
  2345. button.
  2346.  
  2347.      <Up arrow>     If current  cell cursor is not in row number 1, the
  2348.                     cell cursor will be moved one row up.
  2349.      <Down arrow>   If current cell cursor is not  in row  number 1280,
  2350.                     the cell cursor will be moved one row down.
  2351.      <Left arrow>   If current cell cursor is not in column A, the cell
  2352.                     cursor will be moved one column left.
  2353.      <Right arrow>  If current cell cursor is  not  in  column  IU, the
  2354.                     cell cursor will be moved one column right.
  2355.      <Shift-arrows> If  possible,  the  cell  cursor  will  be moved by
  2356.                     "page" to the direction the arrow key specified.
  2357.      <Clr-Home>     This key moves the current cell cursor to A1.
  2358.  
  2359.      <F5>           When you press the function key  F5, you  can enter
  2360.                     the cell reference directly to move the cell cursor
  2361.                     to that cell. If the cell  specified is  not in the
  2362.                     working area, then the working area will be changed
  2363.                     and the new upper left cell is the cell specified.
  2364.  
  2365.      You can use the slider bars to change the working area quite fast.
  2366. Also, you  can locate a cell with mouse much faster than arrow keys. To
  2367. locate a cell with mouse:
  2368.           -    use vertical and horizontal slider bars  to move  to the
  2369.                desired working area.
  2370.           -    put  the  mouse  cursor  over the desired cell and press
  2371.                left button on your mouse.
  2372.  
  2373.  
  2374.                                 Page 27
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  SHEET User manual             By Chor-ming Lung                October 9,
  2386. 1988
  2387.  
  2388.                                 EDITING
  2389.  
  2390. Types of cell entry:
  2391. ___________________
  2392.           There are 4 different types of cell entries in SHEET: numeric
  2393.      constant, formula,  text and  BASIC statement. BASIC commands will
  2394.      be executed immediately but it will not be stored in any cell. The
  2395.      leading character  of each  entry will  differentiate one from the
  2396.      other.
  2397.  
  2398.  
  2399.           Formula: Input string starts with "+", "-", DIGIT, "." or "("
  2400.           Formula
  2401.  
  2402.           Constant: Input string starts  with "+",  "-", DIGIT,  "." or
  2403.           Constant
  2404.                "("
  2405.           Statement: Input string starts with "!"
  2406.           Statement
  2407.           Command: Input string starts with "@"
  2408.           Command
  2409.           Text: Input  string starts  with double  quote, single quote,
  2410.           Text
  2411.                "^", "\" or character other than  "+", "-",  DIGIT, ".",
  2412.                "(", "!", "@".
  2413.  
  2414.           Constant is  an arithmetic expression which does not refer to
  2415.           Constant
  2416.      other  cell(s)  or  variable(s).  A  constant  cell  will  not  be
  2417.                                           constant
  2418.      recalculated.  You  may  notice  that  most  of  your  inputs  are
  2419.      constants. Making the  distinction  between  formula  and constant
  2420.      constants                                    formula      constant
  2421.      helps speeding up the spreadsheet recalculation time.
  2422.  
  2423.           Statement  and   command  are   for  BASIC  interpreter.  The
  2424.           Statement        command
  2425.      differences between statement and command are that command will be
  2426.                          statement     command          command
  2427.      executed immediately  but will  not be  stored in current cell and
  2428.      statement will not be executed but will be  stored in  the current
  2429.      statement
  2430.      cell.
  2431.  
  2432.           Text  is  a  descriptive  string. The first character of each
  2433.           Text
  2434.      text entry has special effect for display.
  2435.           Single quote('):    The text is left justified.
  2436.           Double quote("):    If the width of  the cell  is larger than
  2437.                               the length of the text, the text is right
  2438.                               justified.
  2439.           Circumflex (^):     if the width of  the cell  is larger than
  2440.                               the  length  of  the  text,  the  text is
  2441.                               centered within the cell width.
  2442.           Back slash(\):      The text  following  back  slash  will be
  2443.                               used repetively filling the cell.
  2444.  
  2445.           If  a  text  string  starts  with character other than single
  2446.      quote, double quote, circumflex or back slash, then  the character
  2447.      selected  on  "TEXT  justification"  of menu item "Defaults" under
  2448.      menu title "Sheet" will be used as its leading character.
  2449.  
  2450.           There is a command which you  can change  the first character
  2451.      from one  of ('  " ^ \) to one of (' " ^ \ !). It is the menu item
  2452.      "Adjust" under menu title "Cells".
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.                                 Page 28
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  SHEET User manual             By Chor-ming Lung                October 9,
  2470. 1988
  2471.  
  2472.  
  2473. Rules for constructing formula:
  2474. ______________________________
  2475.      When you are entering formula, the  first character  of your entry
  2476. must be  "+","-", "0".."9",  "." or "(". The following table summarizes
  2477. all such first characters and their usage.
  2478.  
  2479.      Char Usage                                        Example
  2480. -----------------------------------------------------------------
  2481.      +    Used when the formula begins with  a cell    +A1/A2
  2482.           reference or calling built-in function       +SIN(A1)
  2483.  
  2484.      -    Used   when   the   formula  begins  with    -A1*20
  2485.           negative constant value or negative value    -12*0.2
  2486.           of  cell  reference  or negative value of    -COS(A1)
  2487.           function call
  2488.  
  2489.      0-9  Used  when  the  formula  begins  with  a    12.3*20
  2490.           constant number.
  2491.  
  2492.      .    Used  when  the  formula  begins  with  a    .05*120
  2493.           constant number.
  2494.  
  2495.      (    Used  when  the  beginning  part  of  the    (A1-A2)/A3
  2496.           formula's  natural  order  of calculation
  2497.           must be altered through the use of a pair
  2498.           of parentheses.
  2499.  
  2500.  
  2501.      NOTE: 1.
  2502.      ____      Versions before  2.0 of  SHEET did  not know that .05 is
  2503.                0.05.
  2504.            2.  If part of the expression returns a string, then it will
  2505.                treat as 0. It means you cannot do string calculation in
  2506.                any  cell.  But  the  BASIC  interpreter  can  do string
  2507.                operations.
  2508.  
  2509.             eg.     34+chr$(12)         ==>34
  2510.                     "test1"+"test2"     ==>0
  2511.                     4+len("some")       ==>8
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.                                 Page 29
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  SHEET User manual             By Chor-ming Lung                October 9,
  2541. 1988
  2542.  
  2543. Cell input:
  2544. __________
  2545.           Whenever  you  type  some  keys, the corresponding characters
  2546.      will be inserted into  the  editing  buffer.  You  may  notice the
  2547.      status  is  changed  from  "Ready"  to "Input". Your entry must be
  2548.      terminated by the following  method to  change the  status back to
  2549.      "Ready". While  you are  in "Input"  mode, the menu selections and
  2550.      window resize function are not allowed, though you can change your
  2551.      working  area  by  moving  the horizontal or vertical slider bars.
  2552.      Whenever you terminate  your  input,  you  will  get  back  to the
  2553.      working area before you do editing.
  2554.  
  2555.      Move the editing cursor:
  2556.      Move the editing cursor
  2557.      <Shift-Left arrow>  Moves the  editing cursor  to left  by 1/2 the
  2558.                          length of the editing buffer.
  2559.      <Shift-Right arrow> Moves the editing cursor  to right  by 1/2 the
  2560.                          length of the editing buffer.
  2561.           MOUSE cursor   Moves  the  mouse  cursor to the character you
  2562.                          want it  be  and  press  left  button  on your
  2563.                          mouse,  then  the  editing cursor will move to
  2564.                          that character.
  2565.      Modify your input:
  2566.      Modify your input
  2567.           <Insert>       Toggles the INSERT mode  to TYPEOVER  mode and
  2568.                          vice versa.
  2569.           <Backspace>    Erases the  character on the left hand side of
  2570.                          the editing cursor.
  2571.           <Delete>       Erases the character under the editing cursor.
  2572.      Terminate your input:
  2573.      Terminate your input:
  2574.           <Undo>         Terminates input and the  cell content  is not
  2575.                          modified.
  2576.           <Return>       Terminates input  and the cell cursor moves to
  2577.                          the direction specified  by  editing direction
  2578.                          (see below).
  2579.           <UP arrow>     Terminates input and the cell cursor moves one
  2580.                          row up if possible.
  2581.           <Down arrow>   Terminates input and the cell cursor moves one
  2582.                          row down if possible.
  2583.           <Left arrow>   Terminates input and the cell cursor moves one
  2584.                          column left if possible.
  2585.           <Right arrow>  terminates input and the cell cursor moves one
  2586.                          column right if possible.
  2587.      Miscellaneous operations:
  2588.      Miscellaneous operations:
  2589.           MOUSE          if the mouse cursor is inside the working area
  2590.                          and if  you  press  the  left  button  on your
  2591.                          mouse, the  cell coordinate  that the mouse is
  2592.                          over will be inserted into the editing buffer.
  2593.      <Control> MOUSE     It works as above  except a  comma is inserted
  2594.                          before the cell coordinate.
  2595.      <Shift> MOUSE       Instead  of  comma,  a  through  notation (..)
  2596.                          added before the cell coordinate.
  2597.           Sliders        You can change the working area  by moving the
  2598.                          vertical   or   horizontal  slider  bars.  Any
  2599.                          terminating key  will resume  the display back
  2600.                          to the working area before editing.
  2601.  
  2602.  
  2603.                                 Page 30
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  SHEET User manual             By Chor-ming Lung                October 9,
  2615. 1988
  2616.  
  2617. Modify a cell:
  2618. _____________
  2619.           To modify  a cell,  you have  to move  the cell cursor to the
  2620.      desired cell. Press the function key <F2> and use the above method
  2621.      to modify  the cell  content but you must terminate your change by
  2622.                                           ______________
  2623.      <Return>. If you change your mind, you can always <Undo>  what you
  2624.      have done.
  2625.  
  2626. Editing direction:
  2627. _________________
  2628.           When you  terminate your  input by any arrow key, the editing
  2629.      direction  will  be  changed  to  the  direction  the   arrow  key
  2630.      specified. When  you press  <Return> to  terminate your input, the
  2631.      cell cursor will move  to the  editing direction.  If you  want to
  2632.      change  the  editing  direction  to  neutral,  you  have  to press
  2633.      <Return> before your editing session.
  2634.  
  2635.           e.g.
  2636.  
  2637.  
  2638.           Cell      Entry                    Cell cursor position
  2639.      -------------------------------------------------------------
  2640.            A1       1 <Down arrow>                 A2
  2641.  
  2642.            A2       2 <Return>                     A3
  2643.  
  2644.  
  2645.           The first entry change the editing  direction to  <Down>. The
  2646.      second  entry   which  terminates  with  <Return>  is  similar  to
  2647.      terminating with <Down arrow>.
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.                                 Page 31
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  SHEET User manual             By Chor-ming Lung                October 9,
  2687. 1988
  2688.  
  2689.                           CUSTOMIZED DISPLAY
  2690.  
  2691.      SHEET can calculate number  accurate up  to 17  decimal places. In
  2692. most case, you need to display 2 decimal points only. For example, your
  2693. monthly loan payment may be 876.54321.  You  will  not  care  about the
  2694. extra digits. You just want it to display as 876.54 or $876.54. That is
  2695. the situation in which you need to change its default display format.
  2696.  
  2697.      There are two ways to change  the appearance  of your worksheets--
  2698. changing  the  width  of  individual  column and changing the format of
  2699. individual cells.
  2700.  
  2701.  
  2702. Change column width:
  2703. ___________________
  2704.      The column width of  a cell  may affect  the display.  For numeric
  2705. result, if  the format  you specify  cannot fit  into the  width of the
  2706. cell, then the cell will be filled up with "*".  For text,  you may not
  2707. be able  to do  right justification  or center the text. To display the
  2708. result correctly, you may need to change the width of the column.
  2709.  
  2710.      There are two ways to change the width  of individual  column. The
  2711. first way  uses the  mouse and  the second  way uses the menu item "Col
  2712. widths" under menu title "Row/Col".
  2713.  
  2714.      MOUSE:
  2715.           -    Move the desired column within the working area
  2716.           -    Move the mouse cursor on the white gap  after the column
  2717.                letter (e.g.  if you  want to change the width of column
  2718.                A, move the mouse cursor on  the white  gap after column
  2719.                letter A)
  2720.           -    Press the left mouse button (do not release it)
  2721.           -    To expand  the column width, drag the mouse to right and
  2722.                release the button
  2723.           -    To shrink the column width, drag  the mouse  to left and
  2724.                release the column
  2725.      Col widths:
  2726.           -    Select the  menu item  "Col widths" under the menu title
  2727.                "Row/Col".
  2728.           -    Enter the correct column letter
  2729.           -    Enter your desired column width.
  2730.           -    You can enter numbers separate by comma. Doing this will
  2731.                change  the  column  widths  beginning  from  the column
  2732.                letter specified.
  2733.  
  2734.      Note:
  2735.      Note      if your column width is only 1 character  wide, then the
  2736.                column letter will be pushed to the next column.
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.                                 Page 32
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  SHEET User manual             By Chor-ming Lung                October 9,
  2758. 1988
  2759.  
  2760.  
  2761. Default display format:
  2762. ______________________
  2763.      Text:
  2764.      Text      Depends on the first character for justification.
  2765.      Constant and Formula:
  2766.      Constant and Formula
  2767.                The number  of digits after the decimal point is six. It
  2768.                is right justified and if  possible,  a  blank  space is
  2769.                added at the rightmost place.
  2770.      Column width:  9 characters per column.
  2771.      Column width
  2772.  
  2773.  
  2774. Display format:
  2775. _______________
  2776.           There are  9 different predefined display formats for formula
  2777.                                                                 formula
  2778.      and constant types. The first one is the  default format mentioned
  2779.          constant
  2780.      above.  The  others  are  %,  Fixed, Scientific, Dollar, ,(comma),
  2781.                                %   Fixed  Scientific  Dollar  ,
  2782.      Date1, Date2, Date3.
  2783.      Date1  Date2  Date3
  2784.  
  2785.  
  2786.           Type      Usage                         Example
  2787.      --------------------------------------------------------
  2788.        Default    Display up to 6 decimal points    3.1234
  2789.        %          Use    for    interest    rate,   0.05    will    be
  2790.                   discount, tax and so on.          displayed as 5%
  2791.        Fixed      Use   for   data   which   have   1.00
  2792.                   different  decimal  places. (eg   1.50
  2793.                   1,1.5. Most likely, you want it   2.00
  2794.                   to be 1.00, 1.50)
  2795.        Scienti-   Use for display data which is a   3.24e12
  2796.        fic        big or small number.
  2797.  
  2798.        Dollar     Use for data which  are related   $1,245.12
  2799.                   to money.
  2800.        ,          Comma  format   is  similar  to   1,245.12
  2801.                   Dollar format excep there is no
  2802.                   dollar sign in front of it.
  2803.        Date1      Use for displaying date related   9-Jul-88
  2804.                   value. Its format is dd-MMM-yy.
  2805.        Date2      Its format is dd-mmm.             18-Jul
  2806.        Date3      Its format is mmm-yy.             Jul-88
  2807.        TEXT       Display formula  instead of its
  2808.                   value.
  2809.  
  2810.        HIDE       The  information  on  this cell
  2811.                   will not appear on  the working
  2812.                   area
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.                                 Page 33
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  SHEET User manual             By Chor-ming Lung                October 9,
  2836. 1988
  2837.  
  2838.  
  2839. Block:
  2840. _____
  2841.      Before we  reformat some  cells, we need to tell SHEET which cells
  2842. we intend to do that. In SHEET, those cells are called blocks. In Lotus
  2843. 123, we can define only one block at one time, but SHEET can accomodate
  2844. up to 18 blocks at one time.
  2845.  
  2846.      A block is part of the spreadsheet. It is a  rectangle which holds
  2847. at least  one cell.  To define a block, you need to select the starting
  2848.                                                                ________
  2849. cell and stopping cell  of  the  block.  The  process  of  defining the
  2850. ____     _____________
  2851. starting  cell  requires  mouse  button and <Control> key, and stopping
  2852. ______________                                                 ________
  2853. cell requires mouse button and <Shift> key.
  2854. ____
  2855.  
  2856.           Here is an example to define cell A5 as a block:
  2857.  
  2858.           -    Move the mouse cursor within cell A5
  2859.           -    Press  <Control>  key   and   the   left   mouse  button
  2860.                simultaneously
  2861.  
  2862.           You may  notice that  the selected block has been highlighted
  2863.      by reversing its color.
  2864.  
  2865.           Here is another example  to show  you how  to define  a block
  2866.      containing cells from B5 to C14 (B5..C14):
  2867.           -    Move the mouse cursor within cell B5
  2868.           -    Press   <Control>   key   and   the  left  mouse  button
  2869.                simultaneously
  2870.           -    Move the mouse cursor within cell C14
  2871.           -Press <Shift> key and the left mouse button simultaneously.
  2872.  
  2873.           In summary, to define the starting cell, you have to move the
  2874.                                     _____________
  2875.      mouse  cursor  over  the  first  cell and press <Control> and left
  2876.      mouse button simultaneously. To define the stopping cell, you have
  2877.                                                 _____________
  2878.      to move  the mouse cursor over the last cell and press <Shift> and
  2879.      left mouse button simultaneously. If no stopping cell  is provided
  2880.                                              _____________
  2881.      then the stopping cell is the starting cell.
  2882.  
  2883.           Using  above  example,  if  you  want to define block B5..B14
  2884.      instead of B5..C14
  2885.           -    Move the mouse cursor within cell B14
  2886.           -    Press <Shift>  key and  the left  mouse button simultan-
  2887.                eously.
  2888.  
  2889.           If block  B5..C14 is  the first  block you  defined, there is
  2890.      another way to select this block:
  2891.           -    move the mouse cursor within the cell B5
  2892.           -    press the left mouse button  and  drag  until  you reach
  2893.                cell C14
  2894.           -    release mouse button.
  2895.  
  2896. De-select blocks:
  2897. ________________
  2898.           Selecting any cell by a mouse button click will de-select all
  2899.      the blocks being selected.
  2900.  
  2901.  
  2902.                                 Page 34
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  SHEET User manual             By Chor-ming Lung                October 9,
  2914. 1988
  2915.  
  2916. Change display format:
  2917. _____________________
  2918.      To reformat some cells:
  2919.           -    select blocks using above method
  2920.           -    Press <Control R>
  2921.                or  find  menu  title  "Sheet"  and   choose  menu  item
  2922.                "Reformat" under it.
  2923.           -    A dialog  box will  show up.  Choose the format you want
  2924.                from it.
  2925.  
  2926.           You can also use the  command  "@REFORAMT"  to  reformat some
  2927.      cells. The command should be:
  2928.           -    @reformat FORMAT_STRING, block1, block2, ....
  2929.           -    FORMAT_STRING consists  of two  part. The  first part is
  2930.                the format  being  used,  and  the  second  part  is the
  2931.                decimal places.  The format  of a  cell can be "$", ",",
  2932.                "%", "F", "S" "D1",  "D2" and  "D3". They  represent the
  2933.                format    of    "DOLLAR",   ",",   "PERCENT",   "FIXED",
  2934.                "SCIENTIFIC", "Date1", "Date2" and "Date3" respectively.
  2935.  
  2936.           For example, if you want to  reformat cell  B2..C2 and B5..C5
  2937.      to DOLLAR with decimal place of 2, you can issue the command
  2938.                      @reformat "$2",b2..c2,b5..c5
  2939.      instead of selecting blocks and press <Control R>.
  2940.  
  2941.  
  2942.      NOTE:
  2943.      NOTE      YOU CAN  ONLY REFORMAT  THOSE CELLS WHICH EXIST. That is
  2944.                because of Sparse Matrix. After a cell has been created,
  2945.                the cell  possesses attributes. If you format some empty
  2946.                cells and insert something into those  cells after that,
  2947.                those cells appear as default. It is not a bug.
  2948.  
  2949.                You  can  set  the  option  in menu item "Options" under
  2950.                "Sheet"  to  use  the  format  of  previous  row.  Then,
  2951.                whenever you  enter a  new element for the worksheet, it
  2952.                will try to find the format of previous row on  the same
  2953.                column and  uses it  as default  format. So,  you do not
  2954.                need to reformat again and again.
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.                                 Page 35
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  SHEET User manual             By Chor-ming Lung                October 9,
  2985. 1988
  2986.  
  2987.                              COPY AND MOVE
  2988.  
  2989.           COPY and MOVE commands require two blocks. The first block is
  2990.      the source,  and the second one is destination. You have to select
  2991.      those blocks before you  activate COPY  command by  <Control C> or
  2992.      find the  menu title "Cells" and choose menu item "Copy" under it.
  2993.      To activate MOVE command, you press <Control M> or find menu title
  2994.      "Range" and choose menu item "Move" under it.
  2995.  
  2996.           You can  use the  command "@COPY source_block, dest_block" or
  2997.      "@MOVE source_block, dest_block" to do the same thing.
  2998.  
  2999.           Here is an example  showing you  how to  copy the  content on
  3000.      cell A1  to A2..A5.  Assume that  the content of A1 is "1+A2". The
  3001.      display of cell A1 should be 1.
  3002.  
  3003.  
  3004.           Key       Mouse button   Effect              Mouse cursor
  3005.                                                          position
  3006.      -----------------------------------------------------------
  3007.                                                        A1
  3008.           Control + Mouse click    Cell A1 inverted
  3009.                                                        A2
  3010.           Control + Mouse click    Cell A2 inverted
  3011.                                                        A5
  3012.           Shift +   Mouse click    Cell A2 through
  3013.                                    A5 inverted.
  3014.           Control C                An alert box
  3015.                                    display on screen
  3016.           Return or Mouse click
  3017.                     on OK.
  3018.  
  3019.           The operations prior to  <Control C>  define two  blocks. The
  3020.      first block consists of cell A1 only. The second block consists of
  3021.      cells A2 through A5. <Control C> tells SHEET  to copy  the content
  3022.      of  the  first  block  to  the  second  block. If cell A6 does not
  3023.      contain anything and you  set the  recalculation mode  to Natural,
  3024.      your display should be:
  3025.                     A              Cell content
  3026.           1              5         1+A2
  3027.           2              4         1+A3
  3028.           3              3         1+A4
  3029.           4              2         1+A5
  3030.           5              1         1+A6
  3031.  
  3032.           Natural recalculation  means formulas are calculated in their
  3033.      dependent order. Cell A1 depends on the result  of A2  (1+A2). So,
  3034.      the calculation  of A1  is postponed  until A2 gets its result. A2
  3035.      depends on  A3 and  A3 depends  on A4  and so  on. Thererfore, the
  3036.      first  formula  being  computed  is  A5. If a formula refers to an
  3037.      empty cell, a zero  will be  returned. Hence,  A5=1+A6=1+0=1, cell
  3038.      A4=1+A5=1+1=2 and A3=1+A4=1+2=3 ...
  3039.  
  3040.  
  3041.  
  3042.                                 Page 36
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  SHEET User manual             By Chor-ming Lung                October 9,
  3054. 1988
  3055.  
  3056.           One question  you may  ask: Why  the cell  reference of A2 in
  3057.      cell A1 has been changed to A3, A4, A5 and A6 in  cell A2,  A3, A4
  3058.      and A5 respectively? The answer is relative cell reference.
  3059.  
  3060. Relative and Absolue cell reference:
  3061. ___________________________________
  3062.           Cell reference  can be  absolute or  relative. By  adding a $
  3063.  
  3064.      symbol before the column letter or/and row number,  we designate a
  3065.      part of  a cell address as absolute or both parts as absolute. For
  3066.      example:
  3067.           $A2  denotes column  (A)  is  absolute  and  the  row  (2) is
  3068.                relative.
  3069.           $A$2 denotes column (A) and row (2) are both absolute.
  3070.           A$2  denotes  column  (A)  is  relative  and  the  row (2) is
  3071.                absolute
  3072.           A2   denotes column (A) and row (2) are both relative.
  3073.  
  3074.           During  COPY,  a  formula  in  source  block  which  contains
  3075.      relative  cell  references  will  be  modified.  If the formula is
  3076.      copied down, then the  relative row  number will  be increased. If
  3077.      the formula is copied to right hand side, then the relative column
  3078.      letter will be increased. If you intend to copy "1+A2"  to A2..A5,
  3079.      then you must use formula "1+A$2" instead of "1+A2".
  3080.  
  3081. NOTE:
  3082. NOTE:
  3083.           A  block  can  be  a  single  cell  (A2),  part  of  a column
  3084.      (A2..A5),part of  a  row  (B20..E20)  or  a  range  (A4..C10). The
  3085.      following  describes  how  the  program  handle different types of
  3086.      block COPY. Source is  the  first  block  and  destination  is the
  3087.      second block. Result is the range size chosen by COPY.
  3088.  
  3089.           Source              Destination         Result size
  3090.      ---------------------------------------------------------
  3091.            Single cell        any kind of block    the largest range
  3092.            column reference   any kind of block    the largest range
  3093.            row reference      any kind of block    the largest range
  3094.            range reference    any kind of block    the source range
  3095.  
  3096.  
  3097.      You can use "@COPY" to copy from source to destination too.
  3098.      You can use "@COPY" to copy from source to destination too.
  3099.  
  3100.      Examples:
  3101.           - If you want to COPY C1 to C2..C20
  3102.                * Control and mouse click on cell C1
  3103.                * Control and mouse click on cell C2
  3104.                * Shift and mouse click on cell C20
  3105.                * <Control C>
  3106.            OR: "@COPY c1,c2..c20"
  3107.           - If you want to COPY C1..C12 to D1..D12
  3108.                * Control and mouse click on cell C1
  3109.                * Shift and mouse click on cell C12
  3110.                * Control and mouse click on cell D1
  3111.                * <Control C>
  3112.            OR: "@COPY c1..c12,d1"
  3113.  
  3114.  
  3115.                                 Page 37
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  SHEET User manual             By Chor-ming Lung                October 9,
  3127. 1988
  3128.  
  3129.                               ERASE CELLS
  3130.  
  3131.           After some practice, you may find some data in your worksheet
  3132.      are no longer needed. Hence,  you  need  the  capability  to erase
  3133.      them. Before  you activate  the ERASE command, you must select the
  3134.      desired cells as blocks. Yes, you can erase  more than  one block,
  3135.      but  the  total  number  of  blocks  cannot  exceed 18. Here is an
  3136.      example showing you how to erase  cells  C1..D11,  E5,  F8  at one
  3137.      time.
  3138.  
  3139.           Key       Mouse button   Effect              Mouse cursor
  3140.                                                          Position
  3141.      ----------------------------------------------------------------
  3142.                                                        C1
  3143.           Control + Mouse button   C1 is inverted
  3144.                                                        D11
  3145.           Shift +   Mouse button   C1 through D11
  3146.                                    are inverted
  3147.                                                        E5
  3148.           Control + Mouse button   E5 is inverted
  3149.                                                        F8
  3150.           Control + Mouse button   F8 is inverted
  3151.           Control E                An alert box for
  3152.                                    ERASE command on
  3153.                                    screen
  3154.           Return or Mouse button   The screen will be
  3155.                     on OK          redrawn to show the
  3156.                                    effect of erase.
  3157.  
  3158.  
  3159. Note:
  3160. ____      Instead of  using mouse  operations, you  can use the command
  3161.           "@ERASE" to erase part of  your  worksheet.  To  do  the same
  3162.           thing as above, you can issue the command:
  3163.  
  3164.                          @erase c1..d11,e5,f8
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.                                 Page 38
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  SHEET User manual             By Chor-ming Lung                October 9,
  3197. 1988
  3198.  
  3199.                            INSERT AND DELETE
  3200.  
  3201.           INSERT and DELETE commands work with row and column only. The
  3202.      first thing before we activate INSERT  or DELETE  command, we must
  3203.      select a row/column.
  3204.  
  3205. Row/Column selection:
  3206. ____________________
  3207.      Here is an example to show you how to select column D:
  3208.           Mouse cursor position         Mouse button
  3209.      ------------------------------------------------------
  3210.           COLUMN BAR
  3211.           column letter D
  3212.                                         Click the mouse button
  3213.           After you select column D, the whole column will be inverted.
  3214.  
  3215.      This is an example showing you how to select row 3
  3216.  
  3217.  
  3218.           Mouse cursor position         Mouse button
  3219.      ------------------------------------------------------
  3220.           ROW BAR
  3221.           row number 3
  3222.                                         Click the mouse button
  3223.  
  3224.  
  3225.           After you select row 3, the whole row will be inverted.
  3226.  
  3227.  
  3228.           To delete  or insert  a row/column, you must first select the
  3229.      row/column by clicking on  the  column  or  row  bar  with desired
  3230.      column letter or row number. After that, you can press <Control I>
  3231.      or <Control D> for inserting or deleting. You can choose  the menu
  3232.      title "Row/Col"  and choose  menu item  "Insert" or "Delete" to do
  3233.      the same thing.
  3234.  
  3235. Note:
  3236. ____      INSERT and DELETE commands work with row and column only.
  3237.      -    If you intend to add some blank rows or column but you do not
  3238.           want to  add the  whole rows/columns,  then you must use MOVE
  3239.           command instead.
  3240.      -    If you intend to delete  some  cells,  use  ERASE  instead of
  3241.           DELETE.
  3242.  
  3243.  
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.                                 Page 39
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  SHEET User manual             By Chor-ming Lung                October 9,
  3268. 1988
  3269.  
  3270.                             LOAD, SAVE AND PRINT
  3271.  
  3272.           If you  take a  look of the menu title "File", you may notice
  3273.      that there are three types of  load and  save commands.  Menu item
  3274.      "Load"  will  load  the  ordinary  SHEET  files  (they have a file
  3275.      extension SHT). "Load WKS"  will  load  Lotus  123  release  1A or
  3276.      release  2  files.  "Load  PART"  is similar to Lotus file combine
  3277.      command. It is  used  for  merging  other  worksheet  with current
  3278.      worksheet.  The  file  you  "Load"  with part should be saved with
  3279.      "Save PART" command and its file extension should be PRT.
  3280.  
  3281.           Menu item "Save" will save the current file using SHT format.
  3282.      "Save  WKS"  will  save  file  in Lotus WKS format. "Save PART" is
  3283.      similar to Lotus file extract command. It is used for  saving some
  3284.      part  of  the  current  worksheet.  To  activate this command, you
  3285.      should select blocks to hold cells being output, and activate this
  3286.      command.
  3287.  
  3288.           Currently, you cannot save your worksheet in Lotus release 1A
  3289.      format. Other than that, every thing is functional.
  3290.  
  3291. File extension:
  3292. ______________
  3293.           Lotus 123 release 1A  uses WKS  as its  file extension. SHEET
  3294.      uses SHT  as its  file extension. If you enter a file name in your
  3295.      file selector dialog box, you should  include the  file extension.
  3296.      The  file  extension  for  PART  is  PRT.  If you are printing the
  3297.      spreadsheet to disk, the  file extension  for this  file should be
  3298.      PRN.
  3299.  
  3300. Load:
  3301. ____
  3302.      There are three way to load a spreadsheet:
  3303.           -    From the menu title, choose "File"
  3304.                Choose menu item "Load"
  3305.                Select your file from the file selector box
  3306.           -    <Control-L>. Press <Control> and L key simultaneously
  3307.                Select your file from the file selector box
  3308.           -    @load (This is a BASIC command).
  3309.  
  3310. Save:
  3311. ____
  3312.      There are three way to save a spreadsheet:
  3313.           -    From the menu title, choose "File"
  3314.                Choose menu item "Save"
  3315.                Enter your file in the file selector dialog box
  3316.           -    <Control-S>. Press <Control> and S key simultaneously
  3317.                Enter your file in the file selector dialog box
  3318.           -    @save "filenmae" (This is a BASIC command.)
  3319.  
  3320. Load PART:
  3321. _________
  3322.           You can  merge those  cells that  are saved  with "Save PART"
  3323.      into your current  worksheet.  To  load  those  files,  you should
  3324.      select the menu item "Load PART" from the menu title "File".
  3325.  
  3326.  
  3327.  
  3328.  
  3329.                                 Page 40
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  SHEET User manual             By Chor-ming Lung                October 9,
  3341. 1988
  3342.  
  3343.  
  3344. Save Part:
  3345. _________
  3346.           You can  save part of your worksheet to a file and then merge
  3347.      it  with  other  worksheet.  It  is  especially  useful  for BASIC
  3348.      programmer. They  may create  some BASIC  routines that are needed
  3349.      from file to file. Save them as PART and load them back  for other
  3350.      files. To  save part  of your  worksheet, you need to select those
  3351.      cells as blocks and activate the menu item  "Save PART".  The file
  3352.      extension for this kind of file is PRT.
  3353.  
  3354. Lotus files:
  3355. ___________
  3356.           In many ways, SHEET is quite similar to Lotus 123. But I must
  3357.      emphasize that I am not  writing  a  Lotus  clone.  Instead,  I am
  3358.      trying to  write a BASIC interpreter in a spreadsheet environment.
  3359.      Even though, SHEET can read Lotus  files,  you  may  not  be lucky
  3360.      enough  to  convert  all  your  existing  Lotus  files. SHEET will
  3361.      convert those functions it supports. When SHEET encounters problem
  3362.      in function convertion, it will stop loading the file. It can read
  3363.      Lotus 123 release 1A or 2 files.
  3364.           You may also notice that the converted SHT files are normally
  3365.      bigger than WKS files. There are two reason for that. First, I use
  3366.      a single data type  -- double  -- for  all constant  number. Lotus
  3367.      separates number  from integer  to double. An integer is two bytes
  3368.      long while a double is eight  bytes.  The  second  reason  is that
  3369.      Lotus stores formula in suffix order while SHEET stores formula in
  3370.      infix  order  (e.g.  3+4  is  in  infix  order,  its  suffix order
  3371.      representation is  3 4 +). Suffix order not only saves storage (in
  3372.      suffix order,  parenthesis  can  be  discarded  and  comma between
  3373.      parameters  can  be  discarded  too),  it  also  speeds up formula
  3374.      calculation. You may ask me why I use infix order? Well, it is not
  3375.      easy to write a BASIC interpreter using suffix order.
  3376.  
  3377. Print:
  3378. _____
  3379.           You can print your work sheet to a file or to printer. Before
  3380.                                                                  Before
  3381.      you print, please specify the block which you  want to  print. The
  3382.      you print, please specify the block which you  want to  print
  3383.      print routine  will print  those columns that fits on the margins.
  3384.      If some  columns on  the print  range are  not print  on the first
  3385.      pass, they will be printed on later passes.
  3386.           Note:
  3387.           Note      The information you enter for the PRINT DIALOG will
  3388.                     not be saved with  your spreadsheet  file. It means
  3389.                     you have  to type in your format each time you want
  3390.                     to print it.
  3391.  
  3392.  
  3393.           Here is an example showing how to print the block A1..E12
  3394.  
  3395.           Key       Mouse button   Effect              Mouse cursor
  3396.                                                          position
  3397.      ----------------------------------------------------------------
  3398.                                                        A1
  3399.           Control + Mouse button   A1 is inverted
  3400.                                                        E12
  3401.           Shift +   Mouse button   A1 through E12
  3402.                                    are inverted
  3403.  
  3404.                                 Page 41
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  SHEET User manual             By Chor-ming Lung                October 9,
  3416. 1988
  3417.  
  3418.           <Control P>              PRINT dialog box
  3419.                                    display
  3420.           Change dialog box contents.
  3421.           <Return>  or Mouse button
  3422.                     on OK.
  3423.  
  3424.  
  3425.           Let us examine what  the components  of the  print dialog box
  3426.      mean.  If  you  want  to  print  your worksheet to disk instead of
  3427.      printer, enter D in  the box  after "Print  to (P)rinter/(D)isk:".
  3428.      Otherwise, enter  P. If  you want  to print the formula (including
  3429.      BASIC statement) of each  cell,  then  enter  Y  for  the question
  3430.      "Print  Formula  (Y)es/(N)o"".  Otherwise, enter N. NOTE: versions
  3431.      before 2.0 prints formula  row after  row. The  new version prints
  3432.      formula  column  after  column.  It  makes  printing BASIC program
  3433.      easier.
  3434.  
  3435.                                                   Right margin-->
  3436.         <---------------------- Page width --------------------->
  3437.  ^       ********************************************************
  3438.  |       *         ^                                            *
  3439.  |       *         | Top margin and titles                      *
  3440.  |       *         v                                            *
  3441.  |       *        **************************************        *
  3442.  |       *        *                                    *        *
  3443.          *<------>*                                    *        *
  3444.  Page    * Left   *                                    *        *
  3445.  Length  * Margin *                                    *        *
  3446.          *        *                                    *        *
  3447.  |       *        *                                    *        *
  3448.  |       *        *                                    *        *
  3449.  |       *        *                                    *        *
  3450.  |       *        *                                    *        *
  3451.  |       *        *                                    *        *
  3452.  |       *        *                                    *        *
  3453.  |       *        *                                    *        *
  3454.  |       *        *                                    *        *
  3455.  |       *        **************************************        *
  3456.  |       *         ^                                            *
  3457.  |       *         | Bottom margin                              *
  3458.  |       *         v                                            *
  3459.  v       ********************************************************
  3460.  
  3461.  
  3462.           If you want to test your output before you actually print it,
  3463.      you can enter the command:
  3464.  
  3465.                          @redirect to "prn:"
  3466.                          @print_block a1..g4,4,76
  3467.  
  3468.           The commands above will print row 1 to row 4 from column A to
  3469.      column G using left margin 4 and right margin 76  to your printer.
  3470.      You can  check the  result before  you actually print it. (That is
  3471.      useful because you cannot stop PRINT when it actually prints).
  3472.  
  3473.                                 Page 42
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  SHEET User manual             By Chor-ming Lung                October 9,
  3485. 1988
  3486.  
  3487.                         PART III -- SHEET BASIC
  3488.  
  3489.      A spreadsheet is a  powerful computing  tool. It  is also  a handy
  3490. environment for handling data. Yon can add, delete and change your data
  3491. with ease, and the spreadsheet program modifies all the required places
  3492. to reflect the changes.
  3493.  
  3494.      Let the  spreadsheet handle  your data and numurical calculations,
  3495. and  let  the  BASIC  interpreter  do  the  rest.  SHEET  BASIC  can do
  3496. calculations,   string   operations,   graphics  and  text  files.  The
  3497. combination of spreadsheet and BASIC provides an ideal  environment for
  3498. using your computer productively.
  3499.  
  3500.      The following is a brief explanation of each session of PART III.
  3501.  
  3502. Cells,  Variables,   String:  This  chapter  introduces  the  new  cell
  3503.                     reference  method,  variables   and   their  naming
  3504.                     convention.
  3505.                          You cannot  assign a string to a variable, but
  3506.                     you can assign a  string to  a cell.  The rules for
  3507.                     accessing and operating strings are introduced too.
  3508.  
  3509. Flow control Statements: These statements change the execution sequence
  3510.                     of BASIC commands. The commands include:
  3511.                     IF .. THEN .. ELSE, GOTO, GOSUB ..  RETURN, LOOP ..
  3512.                     EXIT IF .. ENDLOOP, FOR .. NEXT, and RUN
  3513.  
  3514. I/O Statements:     REDIRECT TO, PRINT
  3515.  
  3516. Miscellaneous  statements:  SAVE  SCREEN, RESTORE SCREEN, WAIT, DEFINE,
  3517.                     MESSAGE
  3518.  
  3519. Text files:         GET_FILE, OPEN, CLOSE, INPUT, PRINT
  3520.  
  3521. Worksheet commands: COPY, MOVE, ERASE, REFORMAT, SORT, SWAP
  3522.  
  3523. Console commands:   CLS,  CURSORON,  CURSOROFF,  VIDEOHIGH,  VIDEONORM,
  3524.                     GOTOXY, INKEY, UNGET, INPUT
  3525.  
  3526. Graphic commands:
  3527.      Setup commands:     WINDOW, VIEWPORT, SCALE, EXITGRAPH, CLEAR
  3528.      Line/Dot commands:  ATTRIBUTE,  LINE,  LINE_TO,  PLOT,  PLOT DATA,
  3529.                          SPLINE
  3530.      Turtlegraphics:     FORWARD, TURN, TURN_TO
  3531.      Axis commands:      MARKX, MARKY, LABELX, LABELY
  3532.      Text command:       PTEXT
  3533.      Miscellaneous:      MOUSE_POS
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.                                 Page 43
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  SHEET User manual             By Chor-ming Lung                October 9,
  3554. 1988
  3555.  
  3556.                           Cells and Variables
  3557.  
  3558. Cell reference with dimension:
  3559. _____________________________
  3560.      A cell reference is a combination of column letter and row number.
  3561. This type of access method is not enough for a programming language. In
  3562. SHEET, you can use a  cell  as  a  BASE  and  move  it  horizontally or
  3563. vertically by  appending two  numbers which  are separated by comma and
  3564. embraced by "[" and "]". Each column letter has its own value. Column A
  3565. is 1,  B is  2 and  so on.  For example,  A2[3,4]. A2 is the BASE whose
  3566. coordinate is [1,2] and
  3567.  
  3568.                      A2[3,4]=[1,2]+[3,4]=[4,6]=D6.
  3569.  
  3570.      Here are some other examples:
  3571.  
  3572.           C1[4,7]   which is equivalent to  cell  G8.  C1  is  equal to
  3573.                     [3,1] and  C1[4,7]=[3,1]+[4,7] = [7,8]. Column G is
  3574.                     7. So the combination of this cell is G8.
  3575.           H123[-2,4] H123=[8,123]  and  H123[-2,4]  =  [8,123]+[-2,4] =
  3576.                     [6,127] or F127.
  3577.  
  3578. Variables:
  3579. _________
  3580.      Variables must be initialized before being used. You can define up
  3581. to 150 variables. A variable name starts with an alpha  character which
  3582. is  followed  by  alphanumeric  characters.  Up  to  15  characters are
  3583. significant. A  variable  name  must  not  be  identical  with reserved
  3584. keywords, built-in functions  and cell reference.
  3585.  
  3586.      examples:
  3587.           row=4          correct
  3588.           pi=3.1415      incorrect (PI is a predefined constant)
  3589.           a1=12          incorrect (it is cell A1)
  3590.           1and2          incorrect (the first character is not letter)
  3591.  
  3592.      There are  so many  keywords and  built-in functions,  how can one
  3593. differentiate them from the other? Keywords are embraced by leading and
  3594. trailing spaces. For example, IF is a keyword and when it is displayed,
  3595. it is " IF ". A built-in function has a leading space  before the name.
  3596. For example,  SIN(x) will  be displayed  as " SIN(X)". Variables do not
  3597. have any leading or trailing space.
  3598.  
  3599. Cell reference with variables
  3600. _____________________________
  3601.       The whole worksheet can be viewed as a two dimensional array. You
  3602. can access  any cell  by A1[c,r]  where c is the column number and r is
  3603. the row number.
  3604.      Not only you can access individual cell by using this  method, you
  3605. can also  use it  for block.  For example,  assume that  you store your
  3606. square matrix in cells a1..c3 and you want to store the inverse of this
  3607. matrix to d1..f3. You can use the following program to do this.
  3608.  
  3609. ! matrix(d1,inverse[a1..c3])
  3610. ! end
  3611.  
  3612.      Assume that  you need  to solve another square matrix in which you
  3613.  
  3614.                                 Page 44
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  SHEET User manual             By Chor-ming Lung                October 9,
  3626. 1988
  3627.  
  3628. store it in cells a1..d4. You can easily change the  argument of matrix
  3629. to:
  3630.  
  3631. ! matrix(e1,inverse[a1..d4)
  3632.  
  3633. If  you  keep  using  this  method  to solve square matrix in different
  3634. sizes, you may find it is  clumsy and  easy to  make mistakes.  Here is
  3635. another program  that makes  the whole process of changing a lot easier
  3636. for you and less error prone.
  3637.  
  3638. !n=3
  3639. ! matrix(a1[n,0],invers[a1..a1[n-1,n-1])
  3640. ! end
  3641.  
  3642. n=3 so a1[3,0]=[1,1]+[3,0]=[4,1]=d1 and
  3643.           a1[n-1,n-1]=[1,1][2,2]=[3,3]=c3.
  3644.  
  3645. All you need to change is the constant n.
  3646.  
  3647. String
  3648. ______
  3649.      You may store numerical data or TEXT string in a cell. To access a
  3650. cell  as  a  string,  you  should  add  the "$" at the end of each cell
  3651. reference. For example:
  3652.                             A1$,  A1[i,j]$
  3653.  
  3654.      String  operators   for  comparisons,   concatenation  and  string
  3655. functions  are  added  for  BASIC users. REMEMBER, string functions and
  3656. concatenation are available  only  in  BASIC  statements  and commands.
  3657. Currently, you  can assig string to  ceeells but not the 150 variables.
  3658. Two predefined string variables  are provided  for file  name and input
  3659. buffer. They  are FILENAME$  and BUF$.  You can use them but you cannot
  3660. assign new value to  them. FILENAME$  is changed  whenever you  use the
  3661. file item  selector and  BUF$ is  changed whenever  you use the command
  3662. INPUT. For  more details,  please refer  to "Text  files" for GET_FILE,
  3663. INPUT #n and "Console:" for INPUT.
  3664.  
  3665.      If an  empty cell  is referred  as a string, a null string will be
  3666. returned. If a cell with number is referred as a string, then  a string
  3667. that is  exactly being displayed for that cell will be returned. If the
  3668. cell is a TEXT string, a string excluding the leading character will be
  3669. returned. The  leading character  for a TEXT string is one of ' " ^ and
  3670. \.
  3671.  
  3672.      If you are assigning a string to a  cell, and  if the  string does
  3673. not contain  one of those leading character, then the default character
  3674. defined in "TEXT justification" of menu item "Defaults" will be used as
  3675. the leading character for that cell.
  3676.      WARNING: DO NOT MAKE ANY STRING LONGER THAN 249 CHARACTERS.
  3677.  
  3678. String operators:
  3679. String operators
  3680.      +:   string  concatenation.  For  example  "Thi"+"s  a  test" will
  3681.           return a string "This is a test".
  3682.      =:   string   assignment   or   string   equal   comparison.  E.g.
  3683.           !a1$="^123": END.  or !if a1$=b1$ then ...
  3684.  
  3685.                                 Page 45
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  SHEET User manual             By Chor-ming Lung                October 9,
  3697. 1988
  3698.  
  3699.      <>, >, <, =>, >=, =<, <=
  3700.           string  comparisons  for  not  equal, greater, less, equal or
  3701.           greater and equal or less than.
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.                                 Page 46
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  SHEET User manual             By Chor-ming Lung                October 9,
  3766. 1988
  3767.  
  3768.                         Flow control Statements
  3769.  
  3770. IF .. THEN .. ELSE ..
  3771.      Syntax:
  3772.           IF conditionn THEN statements:ELSE statements
  3773.  
  3774.      Description:
  3775.           This statement is used to make  a decision  regarding program
  3776.           flow based on the result returned by an expression.
  3777.  
  3778.      Example:
  3779.           IF A1=12 THEN A2=20:ELSE A2=30
  3780.  
  3781.      NOTE: The following statements are not valid:
  3782.                IF A1=12 THEN G3:ELSE GOTO G4
  3783.                IF A1=12 GOTO G3
  3784.      If you  have used  traditional BASICs  before, you would know that
  3785.      you can write "IF A1=12 THEN 120:ELSE GOTO 130" and "IF A1=12 GOTO
  3786.      120" They  are not  valid in  SHEET. Instead, you must change them
  3787.      to:
  3788.                IF A1=12 THEN GOTO G3:ELSE GOTO G4
  3789.                IF A1=12 THEN GOTO G3
  3790.  
  3791. GOTO
  3792.      Syntax:
  3793.           GOTO cell.
  3794.  
  3795.      Description:
  3796.           This  statement  is  used  to  branch  unconditionally  to  a
  3797.           specified cell.
  3798.  
  3799.      Example:
  3800.           GOTO A1
  3801.  
  3802. GOSUB .. RETURN
  3803.      Syntax:
  3804.           GOSUB cell
  3805.           ...
  3806.           RETURN
  3807.  
  3808.      Description:
  3809.           These statements uses in pair for branching to, and returning
  3810.           from a subroutine.
  3811.  
  3812. LOOP .. EXIT IF .. ENDLOOP
  3813.      Syntax:
  3814.           LOOP
  3815.           ...
  3816.           EXIT IF condition
  3817.           ....
  3818.           ENDLOOP
  3819.  
  3820.      Description:
  3821.           Those commands are used to execute a series  of statements in
  3822.  
  3823.                                 Page 47
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  SHEET User manual             By Chor-ming Lung                October 9,
  3835. 1988
  3836.  
  3837.           a loop until some conditions are true. Condition is a logical
  3838.           expression which may be  either  TRUE  or  FALSE.  Within the
  3839.           LOOP, multiple EXIT IFs are allowed. It is adviced not to use
  3840.           GOTO statement to break the loop.
  3841.      Example:
  3842.           The following example assigns 1 to 20 to cell A1 through A20.
  3843.                R=0
  3844.                LOOP
  3845.                A1[0,R]=R+1
  3846.                R = R+1
  3847.                EXIT IF R=20
  3848.                ENDLOOP
  3849.  
  3850. FOR .. NEXT
  3851.      Syntax:
  3852.           FOR assignment TO expression [STEP expression]
  3853.           ...
  3854.           NEXT variable_being_assigned
  3855.  
  3856.      Description:
  3857.           These commands are used to execute a series  of statements in
  3858.           a  definite  number  of  times.  STEP is optional. If no STEP
  3859.           value being provided, it is assumed to be one. In other BASIC
  3860.           interpreters, NEXT  I,J means: increases value of I, when the
  3861.                         _________
  3862.           FOR loop for I is done, then increases  value of  J. You must
  3863.           use NEXT  I: NEXT J in SHEET BASIC. The number of nesting FOR
  3864.               _______________
  3865.           loops is infinite.
  3866.  
  3867. RUN
  3868.      Syntax:
  3869.           RUN cell
  3870.  
  3871.      Description:
  3872.           RUN is similar to GOTO. The only difference is that  RUN will
  3873.           initialize the runtime stack and reset the symbol table. Most
  3874.           of the time, RUN is used to execute BASIC codes starting from
  3875.           a specified  cell. If  the cell is C1, you should enter "@run
  3876.           c1" in the editing buffer.
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.                                 Page 48
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  SHEET User manual             By Chor-ming Lung                October 9,
  3906. 1988
  3907.  
  3908.                             I/O Statements
  3909.  
  3910. REDIRECT TO
  3911.      Syntax:
  3912.           REDIRECT TO "file"
  3913.  
  3914.      Description:
  3915.                This statement changes  the  output  path  of subsequent
  3916.           PRINT  commands  to  the  specified  file.  There  are  a few
  3917.           predefined files. prn: is the printer,  con: is  your monitor
  3918.                             ____                  ____
  3919.           and aux:  is the rs-232 port. Otherwise, they are disk files.
  3920.               ____
  3921.           The default file is  con:. Except  con:, all  the file output
  3922.           are buffered. It means you may not get instant response.
  3923.                If  you  redirect  the  output  to  printer  and if your
  3924.           printer is not on, an alert box will  show up.  If you choose
  3925.           "Quit", the  BASIC program being executed will be stopped. If
  3926.           you choose "Continue",  the  subsequent  PRINT  commands will
  3927.           output to the file prior to REDIRECT TO command. Most likely,
  3928.           it is con:. You should turn your printer on before you choose
  3929.           "Try again".
  3930.  
  3931.      EXAMPLE:
  3932.           REDIRECT TO "prn:"
  3933.  
  3934.  
  3935. PRINT statement
  3936.      Syntax:
  3937.           PRINT cell/cell$/number/string[,/;...]
  3938.  
  3939.      Description:
  3940.                This command  prints numeric  or string data to the file
  3941.           specified by REDIRECT  TO  command.  Implicitly,  it  is your
  3942.           monitor. If no data following the PRINT command, a blank line
  3943.           will be printed.  String  data  must  be  enclosed  by double
  3944.           quotation  marks.   Each  datum  can  be  a  cell  reference,
  3945.           variable, string or number. If more  than one  datum is going
  3946.           to  print,  each  of  them  should  be  separated by comma or
  3947.           semicolon. If you are using comma to separated  two data, the
  3948.           second data  will be  aligned to  the next TAB position. Each
  3949.           TAB is 10 characters wide.
  3950.                If you are printing  cell content,  the format specified
  3951.           in  that  cell  is  used  exactly as display. If the cell you
  3952.           intended to print contains TEXT string, you should add "$" at
  3953.           the end  of the  cell reference.  Otherwise, you will print a
  3954.           cell with zero.
  3955.                If  a  number  is  being  printed,  the  number  will be
  3956.           surrounded  by  a  leading  space  and  a trailing space. The
  3957.           output format of variables is similar to a  number.If you are
  3958.           printing  string,   the  text   inside  the  embraced  double
  3959.           quotation marks will be outputed.
  3960.                While you are printing,  you  can  use  <Control  S> and
  3961.           <Control  Q>  to  suspend  and resume your display. BUT don't
  3962.                                                               _________
  3963.           press <Control C> to stop your PRINT session. If you do press
  3964.           _____________________________________________________________
  3965.           <Control C>  while PRINT  command is printing on console, YOU
  3966.           _____________________________________________________________
  3967.  
  3968.                                 Page 49
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  SHEET User manual             By Chor-ming Lung                October 9,
  3980. 1988
  3981.  
  3982.           WILL GET back to desktop and you need to reboot the system to
  3983.           _____________________________________________________________
  3984.           use SHEET. UES <ESC> to stop your BASIC program.
  3985.           ________________________________________________
  3986.  
  3987.      Example:
  3988.           PRINT a1,12;b1$;20;"This is a test"
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.  
  4033.  
  4034.  
  4035.  
  4036.  
  4037.  
  4038.  
  4039.                                      Page 50
  4040.  
  4041.  
  4042.  
  4043.  
  4044.  
  4045.  
  4046.  
  4047.  
  4048.  
  4049.  
  4050.  SHEET User manual             By Chor-ming Lung                October 9,
  4051. 1988
  4052.  
  4053.                        Miscellaneous statements
  4054.  
  4055.      If  you  print  to  console,  your current display may be garbled.
  4056.      Therefore, you  need  to  save  your  screen  before  printing and
  4057.      restore it after you are done.
  4058.  
  4059.      SAVE SCREEN
  4060.      Syntax:
  4061.           SAVE SCREEN
  4062.  
  4063.      Description:
  4064.                Save current  display to  SCREEN reserved  area. That is
  4065.           the same area that  is used  for FAST  screen update.  If you
  4066.           deny to reserve 32K for fast screen update, you may crash the
  4067.           system when you use this command.
  4068.  
  4069. RESTORE SCREEN
  4070.      Syntax:
  4071.           RESTORE SCREEN
  4072.  
  4073.      Description:
  4074.           Restore the screen to the old display.
  4075.  
  4076. WAIT
  4077.      Syntax:
  4078.           WAIT
  4079.           WAIT #
  4080.  
  4081.      Description:
  4082.                This statement suspends the execution of BASIC commands.
  4083.           # means an integer number. If no number follows WAIT, it will
  4084.           print "Press return to continue ..." on console  and you must
  4085.           press  <Return>  key  to  resume  its operations. The printed
  4086.           message will damage your display. Hence, you should save your
  4087.           screen before calling WAIT.
  4088.                If WAIT  followed by  an integer x, then the system will
  4089.           wait for x seconds.
  4090.  
  4091.      Example:
  4092.           WAIT 5         (System suspends for 5 seconds)
  4093.  
  4094. DEFINE
  4095.      Syntax:
  4096.           DEFINE fname(parameters) = expression
  4097.  
  4098.      Description:
  4099.                This statement let user define its  own functions. Fname
  4100.           is the  function name. Its naming convention follows the rule
  4101.           for naming variable. You can put up to 9 parameters  for each
  4102.           user  function.  Each  parameter  is  a variable separated by
  4103.           comma. Each DEFINE statement  must occupy  a single  cell and
  4104.           user  defined  function  is  useful for numerical calculation
  4105.           only.
  4106.  
  4107.  
  4108.                                 Page 51
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  SHEET User manual             By Chor-ming Lung                October 9,
  4120. 1988
  4121.  
  4122. MESSAGE
  4123.      Syntax:
  4124.           MESSAGE "text"
  4125.  
  4126.      Description:
  4127.                This  command  uses  the  GEM  alert  box  to  display a
  4128.           message. "text"  can be  a string of up to 5 lines. Each line
  4129.           is separated by "|" and the length of each line should not be
  4130.           bigger than 40.
  4131.  
  4132.      Example:
  4133.           MESSAGE "Hello|World"
  4134.  
  4135. EXAMPLE: Address label program
  4136. EXAMPLE
  4137.      Assume  that   you  store   your  address   data  in  the  current
  4138.      spreadsheet. Column A holds the  Last  name.  Column  B  holds the
  4139.      First name. Column C holds the address and D,E,F holds City, State
  4140.      and Zip respectively. The  data starts  from row  3. The following
  4141.      program will  print the  data in your address sheet to the address
  4142.      label for handling mails.  Assume  the  program  stores  from cell
  4143.      G1..G10 and you run it by "@run g1".
  4144.  
  4145. G1    : ! REDIRECT  TO "prn:"
  4146. G2    : !R=0: SAVE  SCREEN
  4147. G3    : ! LOOP
  4148. G4    : ! EXIT  IF  ISEMPTY(A3[0,R]): PRINT
  4149. G5    : ! PRINT A3[1,R]$;A3[0,R]$
  4150. G6    : ! PRINT A3[2,R]$
  4151. G7    : ! PRINT A3[3,R]$;A3[4,R]$;A3[5,R]$
  4152. G8    : ! PRINT : PRINT :R=R+1
  4153. G9    : ! ENDLOOP : WAIT
  4154. G10   : ! RESTORE  SCREEN
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168.  
  4169.  
  4170.  
  4171.  
  4172.  
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.                                 Page 52
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  SHEET User manual             By Chor-ming Lung                October 9,
  4190. 1988
  4191.  
  4192.                               Text files
  4193.  
  4194.           SHEET should  be the first spreadsheet which has the commands
  4195.      for you to access any TEXT  files. The  command is  line oriented.
  4196.      These commands  are intended  for people  who need to acquire data
  4197.      from other  sources.  There  are  two  constant  strings  that are
  4198.      related to some of the Text file commands. FILENAME$ is a constant
  4199.      string that can be changed by file item  selecto dialog  box. BUF$
  4200.      is a constant string that is modified by any INPUT statement.
  4201.  
  4202.           Using the file commands and string functions, you can do some
  4203.      thing that is impossible for user of other spreadsheet programs.
  4204.  
  4205. GET_FILE
  4206.      Syntax:
  4207.           GET_FILE def_search, name$
  4208.  
  4209.      Description:
  4210.                Use the  file  item  selector  to  find  the  file name.
  4211.           Def_search is  the default  search string. It can be a string
  4212.           with wild characters.  For  example  "\*.SHT".  name$  can be
  4213.           FILENAME$ or a cell reference.
  4214.  
  4215.      Example:
  4216.           GET_FILE "\*.*",filename$
  4217.           GET_FILE "\*.txt",a1$
  4218.  
  4219. OPEN
  4220.      Syntax:
  4221.           OPEN "o",#n,filename$
  4222.           OPEN "i",#n,a1$
  4223.  
  4224.      Description:
  4225.                Open a  file for  input or  output. "o" means output and
  4226.           "i" for input. #n  means the  channel number.  N should  be a
  4227.           number  from  0  to  9.  Filename  can be FILENAME$ or a cell
  4228.           reference.
  4229.  
  4230.      Example:
  4231.           OPEN "o",#1,FILENAME$
  4232.           OPEN "i",#2,"test.txt"
  4233.  
  4234. CLOSE
  4235.      Syntax:
  4236.           CLOSE #n[,#m,...]
  4237.  
  4238.      Description:
  4239.                Close opened files. #n , #m are the channel number. They
  4240.           should be  in the  range of  0 to  9. If  you try to close an
  4241.           unopened file, you will get an error message "Cannot close an
  4242.           unopened file".
  4243.  
  4244.      Example:
  4245.           CLOSE #1
  4246.  
  4247.                                 Page 53
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  SHEET User manual             By Chor-ming Lung                October 9,
  4259. 1988
  4260.  
  4261.  
  4262. INPUT #n
  4263.      Syntax:
  4264.           INPUT #n,buf$
  4265.  
  4266.      Description:
  4267.                Read  a  line  from  the  input  file. #n is the channel
  4268.           number. buf$ can be BUF$ or a cell reference.  If the channel
  4269.           number being  referred is an output file or an unopened file,
  4270.           you will get an error message "Channel number error".
  4271.  
  4272.      Example:
  4273.           INPUT #1, BUF$
  4274.           INPUT #1, a1$
  4275.  
  4276. PRINT #n
  4277.      Syntax:
  4278.           PRINT #n, cell/cell$/string/number[,/;....]
  4279.  
  4280.      Description:
  4281.                PRINT #n is similar to PRINT  except that  PRINT outputs
  4282.           to  the  file  specified  by  REDIRECT  TO  (implicitly  your
  4283.           terminal). PRINT  #n  outputs  to  the  channel  number being
  4284.           opened by OPEN command.
  4285.  
  4286.      Example:
  4287.           Assume that  cell a1$="This  is a  test" and b1=12.34 and the
  4288.           widths of column A and B are 9.
  4289.           PRINT #1,a1;b1      ==> "       0    12.34 " to #1
  4290.           PRINT #1,a1$;b1     ==> "This is a test   12.34 " to #1
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.  
  4300.  
  4301.  
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316.                                 Page 54
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  SHEET User manual             By Chor-ming Lung                October 9,
  4328. 1988
  4329.  
  4330.                           Worksheet commands
  4331.  
  4332.           SHEET BASIC is part of SHEET  -- the  spreadsheet program. It
  4333.      is more convenient if you can use some of those worksheet commands
  4334.      to handle data in your BASIC  program. This  new version  of SHEET
  4335.      provides  some  of  the  essential  worksheet  commands for you to
  4336.      incorporate  with  your  program.  They  are  COPY,  MOVE,  ERASE,
  4337.      REFORMAT, SORT  and SWAP. SORT and SWAP are new commands for SHEET
  4338.      too. Currently, they can be activated by BASIC commands only. They
  4339.      work fine  with cells  whose formula  do not refer to other cells.
  4340.      That is because the  cell  references  in  those  formula  are not
  4341.      updated  when  you  SWAP  them.  Next  release  should remove this
  4342.      restriction.
  4343.  
  4344. COPY
  4345.      Syntax:
  4346.           COPY block1, block2
  4347.  
  4348.      Description:
  4349.                Copy block1 to block2. A block can be a single cell or a
  4350.           rectangle portion  of the worksheet. The COPY command follows
  4351.           the rule for COPYing cells by <Ctrl-C>.
  4352.  
  4353.      Example:
  4354.           COPY a1..b3, c1
  4355.  
  4356. MOVE
  4357.      Syntax:
  4358.           MOVE block1, block2
  4359.  
  4360.      Description:
  4361.                Move block1 to block2.  It  is  similar  to  the command
  4362.           <Ctrl-M>.
  4363.  
  4364.      Example:
  4365.           MOVE a1..b3, c1
  4366.  
  4367. ERASE
  4368.      Syntax:
  4369.           ERASE block1[,block2,...]
  4370.  
  4371.      Description:
  4372.                Erase portion  of the worksheet specified by the blocks.
  4373.           Up to 18 blocks can be erased at one time.
  4374.  
  4375.      Example:
  4376.           ERASE a1..b3,c1..d3
  4377.  
  4378. REFORMAT
  4379.      Syntax:
  4380.           REFORMAT FORMAT,block1[,block2,...]
  4381.  
  4382.      Description:
  4383.                Reformat portion of the worksheet. Up  to 18  blocks can
  4384.  
  4385.                                 Page 55
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  SHEET User manual             By Chor-ming Lung                October 9,
  4397. 1988
  4398.  
  4399.           be reformat at one time. FORMAT is a string which consists of
  4400.           two part -- format and decimal places. A  format can  be "$",
  4401.           ",",  "F",  "S",  "D1",  "D2",  "D3". "$" for DOLLAR, "," for
  4402.           COMMA, "F" for FIXED, "S" for SCINETIFIC and "D1", "D2", "D3"
  4403.           for DATE1,  DATE2, and  DATE3 respectively. No decimal places
  4404.           should follow "D1","D2" and "D3".
  4405.  
  4406.      Example:
  4407.           REFORMAT "$2",A1..B3
  4408.                (reformat a1..b3 for dollar and 2 decimal places)
  4409.           REFORMAT "D1", C1..C12
  4410.                (reformat C1..c12 for Date1 format)
  4411.  
  4412. SORT
  4413.      Syntax:
  4414.           SORT "A",block, cell1[,cell2,...]
  4415.           SORT "D",block, cell1[,cell2,...]
  4416.  
  4417.      Description:
  4418.                Sort followed by "A" means sort block in ascending order
  4419.           and "D" for descending order. Only the block will be affected
  4420.           by the sort command. Cell1 points to the first column that is
  4421.           used for  comparison. Up  to 6  of these cells can be used as
  4422.           criteria for comparisons. In  comparison,  an  empty  cell is
  4423.           smaller  than  a  cell  with  numerical value and a cell with
  4424.           numerical value is smaller than a cell contains  TEXT string.
  4425.           If the  column being  compared consists  of BASIC statements,
  4426.           SORT will be stopped. Currently,  SORT  does  not  modify the
  4427.           formula on  each cell being affected. You may have trouble in
  4428.           sorting cells whose formula refers to other cells.
  4429.  
  4430.      Example:
  4431.           SORT "A",A1..B3,A1
  4432.  
  4433. SWAP
  4434.      Syntax:
  4435.           SWAP cell1, cell2
  4436.  
  4437.      Description:
  4438.                This command  swaps cell1  with cell2.  It swaps between
  4439.           two cells.  If you  want to  swap a  row with  other row, you
  4440.           should use a FOR  loop to  do it  one by  one. Again,  it has
  4441.           problem with cell whose formula refers to other cell.
  4442.  
  4443.      Example:
  4444.           SWAP a1,b2
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.  
  4453.  
  4454.                                 Page 56
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  SHEET User manual             By Chor-ming Lung                October 9,
  4466. 1988
  4467.  
  4468.                            Console commands
  4469.                            ________________
  4470.           The  Atari  monitor  emulates  the VT52 terminal. You can use
  4471.      those VT52 commands to control your output. This  version of SHEET
  4472.      provides some  of the  VT52 commands  in the SHEET BASIC. They are
  4473.      CLS, CURSORON, CURSOROFF,  VIDEOHIGH,  VIDEONORM  and  GOTOXY. One
  4474.      function  and  two  commands  for  reading  keyboard  entries  are
  4475.      provided. They are INKEY, UNGET and INPUT.
  4476.  
  4477.           Screen coordinate: (1,1) is the upper  left-corner, (80,1) is
  4478.      the  upper  right-corner,  (1,25)  is  the  bottom left-corner and
  4479.      (80,25) is the bottom right-corner.
  4480.  
  4481. CLS
  4482.      Syntax:
  4483.           CLS
  4484.  
  4485.      Description:
  4486.           Clear the current screen and move the cursor  to the position
  4487.           1,1.
  4488.  
  4489. CURSORON
  4490.      Syntax:
  4491.           CURSORON
  4492.  
  4493.      Description:
  4494.           Makes the screen cursor visible.
  4495.  
  4496. CURSOROFF
  4497.      Syntax:
  4498.           CURSOROFF
  4499.  
  4500.      Description:
  4501.           Turns the screen cursor off.
  4502.  
  4503. VIDEOHIGH
  4504.      Syntax:
  4505.           VIDEOHIGH
  4506.  
  4507.      Description:
  4508.           Makes the subsequent output characters in reverse color
  4509.  
  4510. VIDEONORM
  4511.      Syntax:
  4512.           VIDEONORM
  4513.  
  4514.      Description:
  4515.           Makes the subsequent output characters in normal color
  4516.  
  4517. GOTOXY
  4518.      Syntax:
  4519.           GOTOXY x,y
  4520.  
  4521.      Description:
  4522.                Moves the  screen cursor  to position  x,y. x  is in the
  4523.  
  4524.                                 Page 57
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  SHEET User manual             By Chor-ming Lung                October 9,
  4536. 1988
  4537.  
  4538.           range of 1 to 80 and y is in the range of 1 to 25.
  4539.  
  4540. INKEY
  4541.      Syntax:
  4542.           a=INKEY
  4543.  
  4544.      Description:
  4545.                It is a function that returns the ASCII number of  a key
  4546.           being pressed. If no key or special keys are being pressed -1
  4547.           will be returned. Arrow keys for  Up, Down,  Left, Right have
  4548.           value of  129,130,131 and  132 respectively . Arrow keys with
  4549.           Shift  keys  for  Up,  Down,  Left,  Right  have   values  of
  4550.           133,134,135 and 136.
  4551.  
  4552.      Example:
  4553.           A=INKEY
  4554.  
  4555. UNGET
  4556.      Syntax:
  4557.           UNGET x
  4558.  
  4559.      Description:
  4560.           Put x back to the input stream for later INPUT uses.
  4561.  
  4562.      Example:
  4563.           A=INKEY:.... :UNGET a
  4564.  
  4565. INPUT
  4566.      Syntax:
  4567.           INPUT buf$
  4568.  
  4569.      Description:
  4570.                buf$  can  be  either  BUF$  or  a  cell reference. This
  4571.           routine calls the standard C function gets to get your input.
  4572.           If  you  UNGET  a  character before calling this command, the
  4573.           UNGET character cannot be altered or displayed but it will be
  4574.           the first character in your buf$.
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.                                 Page 58
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  SHEET User manual             By Chor-ming Lung                October 9,
  4605. 1988
  4606.  
  4607.                            Graphic commands
  4608.                            ________________
  4609.  
  4610.      Your  monitor  can  be  used  to  display pictures. A picture is a
  4611. collection of picture elements (pixels). Some  people prefer  to call a
  4612. pixel a  dot. Normal  graphic commands in other BASIC languages provide
  4613. you a mean to change each pixel in your display.  The addressing method
  4614. they used  are called  Raster coordinate.  The left top-corner is (0,0)
  4615. and the right bottom-corner  is (639,399),  (639,199) or  (319,199) for
  4616. high, medium and low resolution.
  4617.      In real world, we are dealing with Cartesian coordinate instead of
  4618. Raster coordinate. The left bottom-corner is  the minimal  point we can
  4619. use  for  display  and  the  right top-corner is the maximal point. The
  4620. graphic commands provided by SHEET BASIC  use the  Cartesian coordinate
  4621. and those commands will translate Cartesian points to pixels.
  4622.      SHEET  BASIC  is  not  the  first  BASIC interpreter which provide
  4623. scientific graphics (at least True BASIC is a few years earlier). But I
  4624. think it  is the first BASIC provides cubic spline curves. Cubic spline
  4625. is a method scientists use to draw smooth curves.
  4626.      The graphic commands are highly relocatable  and they  work on any
  4627. resolution. Hence,  it is  possible to use 16 colors to plot your graph
  4628. in low resolution.
  4629.      The graphics commands are separated into the following categories:
  4630.           Setup commands:
  4631.           Setup commands:     WINDOW  or  VIEWPORT,  SCALE,  EXITGRAPH,
  4632.                               CLEAR
  4633.           Line/Dot commands:
  4634.           Line/Dot commands:  ATTRIBUTE,  LINE,   LINE_TO,  PLOT,  PLOT
  4635.                               DATA, SPLINE
  4636.           Turtlegraphics:
  4637.           Turtlegraphics      FORWARD, TURN, TURN_TO
  4638.           Axis commands:
  4639.           Axis commands       MARKX, MARKY, LABELX, LABELY
  4640.           Text command:
  4641.           Text command:       PTEXT
  4642.           Miscellaneous:
  4643.           Miscellaneous:      MOUSE_POS
  4644.  
  4645.      CONVENTION:
  4646.      CONVENTION     Optional  parameters  are  bracketed.   #  means  a
  4647.                     number. (x,y),  (x1,y1) and (x2,y2) are measured in
  4648.                     Cartesian coordinate. An  r  added  before  x  or y
  4649.                     means the point is in Raster coordinate.
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.                                 Page 59
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  SHEET User manual             By Chor-ming Lung                October 9,
  4682. 1988
  4683.  
  4684.  
  4685. Setup commands:
  4686. ______________
  4687.      WINDOW or  VIEWPORT defines  the part of the screen being used for
  4688. graphic output. They are the  only  commands  whose  parameters  are in
  4689. Raster coordinate. SCALE defines the scaling factors that translate the
  4690. Cartesian corrdinate data into location on  your display.  CLEAR cleans
  4691. up the  area defined  by WINDOW or VIEWPORT. WINDOW and VIEWPORT change
  4692. the clipping area. The last command after your graph is  done should be
  4693. EXITGRAPH  which  resets  the  clipping  area  to  the  current window.
  4694. Otherwise, you may have an illusion that your system is locked. In case
  4695. you  feel  your  system  is  locked,  you should try <Esc> first to see
  4696. whether a BASIC program  is running.  If the  system is  still lock-up,
  4697. enter the  command "@EXITGRAPH" in blind and you should have the system
  4698. back.
  4699.  
  4700.      WINDOW:
  4701.      ______
  4702.           Syntax:
  4703.                WINDOW [# [,rx1,ry1,rx2,ry2] ]
  4704.  
  4705.           Description:
  4706.                     If no parameter provides for this command, then the
  4707.                current window will be used for graphic output.
  4708.                     SHEET supports up to 4 windows. Each window has its
  4709.                own number ranging from 1 to 4. This  number corresponds
  4710.                to the  number you  press ALT-1,  ALT-2, ALT-3 or ALT-4.
  4711.                So, you can use any window for graphics output.
  4712.                     If  raster  parameters  provide,  then  the  window
  4713.                specified will  be resized  to those coordinates and the
  4714.                work area of  that  window  will  be  used  for graphics
  4715.                output. If  a window changes it size, AES will ask SHEET
  4716.                to redraw it. So, you may need to run your program twice
  4717.                to get the graph.
  4718.                     If the window number specified has not been opened,
  4719.                then you won't see the graph, but the  BASIC interpreter
  4720.                will not stop.
  4721.  
  4722.           Examples:
  4723.                WINDOW                   using the current window
  4724.                WINDOW 1                 using window 1
  4725.                WINDOW 1,0,20,350,120    reposition and resize window 1
  4726.  
  4727.           Hints:
  4728.                     If your  program involves a lot of calculation, and
  4729.                you don't want to  run  the  program  twice  to  get the
  4730.                graph, you  can stop  your program by <Esc> key when you
  4731.                see the window has been resized and then  enter the same
  4732.                run command  again in  blind. So, you have better to put
  4733.                your WINDOW command on the first line.
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.                                 Page 60
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  SHEET User manual             By Chor-ming Lung                October 9,
  4753. 1988
  4754.  
  4755.  
  4756.      VIEWPORT:
  4757.      ________
  4758.           Syntax:
  4759.                VIEWPORT rx1,ry1,rx2,ry2
  4760.  
  4761.           Description:
  4762.                     WINDOW lets you to borrow  the  working  area  of a
  4763.                spreadsheet window.  VIEWPORT command  lets you put your
  4764.                picture  anywhere  in  your   screen.   If   the  raster
  4765.                parameters  are  0,0,0,0  then  the whole screen will be
  4766.                used for graphic display. It is desirable if you want to
  4767.                test  the  graph  on  medium  resolution and display the
  4768.                final graph on low resolution.
  4769.  
  4770.           Examples:
  4771.                VIEWPORT 0,0,0,0
  4772.                VIEWPORT 0,0,350,120
  4773.  
  4774.  
  4775.      SCALE:
  4776.      _____
  4777.           Syntax:
  4778.                SCALE xmin, ymin, xmax, ymax
  4779.  
  4780.           Description:
  4781.                     SCALE setup the scaling factors which  are used for
  4782.                mapping Cartesian  coordinate data  to Raster coordinate
  4783.                pixels.  xmin,ymin  specifies  the   left  bottom-corner
  4784.                coordinate  and  xmax,ymax  the  right  top-corner.  You
  4785.                should make the scale a little bit larger  than what you
  4786.                want to leave some spaces for texts.
  4787.  
  4788.      CLEAR:
  4789.      _____
  4790.           Syntax:
  4791.                CLEAR
  4792.  
  4793.           Description:
  4794.                     This command  clears the screen specified by WINDOW
  4795.                or VIEWPORT commands.
  4796.  
  4797.      EXITGRAPH:
  4798.      _________
  4799.           Syntax:
  4800.                EXITGRAPH
  4801.  
  4802.           Description:
  4803.                     WINDOW  and  VIEWPORT  commands   will  change  the
  4804.                clipping area. EXITGRAPH resets the clipping area to the
  4805.                current window and refreshes  it  (sometimes  your graph
  4806.                may overwrite part of the current window).
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.                                 Page 61
  4815.  
  4816.  
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.  
  4825.  SHEET User manual             By Chor-ming Lung                October 9,
  4826. 1988
  4827.  
  4828. Line/Dot commands:
  4829. _________________
  4830.      Each line  posseses some  attributes. It  has color, width and its
  4831. type. A line can be a solid, or broken line. This is the type of a line
  4832. and there are 6 line types defined.
  4833.      A dot  has color and width. Instead of dot, sometimes you may want
  4834. to display your data  using  markers.  There  are  6  different markers
  4835. defined in SHEET BASIC graphic commands.
  4836.      SHEET BASIC  is part  of the  spreadsheet SHEET. You may have your
  4837. data stored in the spreadsheet. There are two special commands  to plot
  4838. data stored in cells. They are PLOT DATA and SPLINE.
  4839.  
  4840.      ATTRIBUTE:
  4841.      _________
  4842.           Syntax
  4843.                ATTRIBUTE color#,width
  4844.  
  4845.           Description:
  4846.                     ATTRIBUTE  command  changes  the color and width of
  4847.                subsequent graphic  commands.  The  default  color  is 2
  4848.                which is red and the default width is 1.
  4849.  
  4850.      LINE:
  4851.      ____
  4852.           Syntax:
  4853.                LINE x1,y1,x2,y2[,linetype]
  4854.  
  4855.           Description:
  4856.                     This command  draws a line from (x1,y1) to (x2,y2).
  4857.                If no type specified, it is  supposed to  be solid line.
  4858.                The parameter type is a number ranging from 1 to 6.
  4859.                     linetype:
  4860.                          1:   solid line
  4861.                          2:   long dashes
  4862.                          3:   dots
  4863.                          4:   dash-dots
  4864.                          5:   dashes
  4865.                          6:   dash-dot-dot
  4866.  
  4867.      LINE_TO:
  4868.      _______
  4869.           Syntax:
  4870.                LINE_TO x1,y1[,type]
  4871.  
  4872.           Description:
  4873.                     This  command   draws  a  line  from  the  previous
  4874.                position  to  (x1,y1).   The   last   line/dot  commands
  4875.                specified the previous position. If the program is newly
  4876.                executed, the previous position is (0,0).
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.                                 Page 62
  4888.  
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  SHEET User manual             By Chor-ming Lung                October 9,
  4899. 1988
  4900.  
  4901.      PLOT:
  4902.      ____
  4903.           Syntax:
  4904.                PLOT x,y[,marker#]
  4905.  
  4906.           Description:
  4907.                     If no marker number  specified,  PLOT  command will
  4908.                draw a dot on the position (x,y). The markers chosen for
  4909.                SHEET BASIC are model after Lotus 123.
  4910.                     MARKER:
  4911.                          1:   square
  4912.                          2:   +
  4913.                          3:   diamond
  4914.                          4:   up-triangle
  4915.                          5:   x
  4916.                          6:   down-triangle
  4917.  
  4918.      PLOT DATA:
  4919.      _________
  4920.           Syntax:
  4921.                PLOT DATA xrange, yrange[,marker#, linetype]
  4922.  
  4923.           Description:
  4924.                     The data are stored  in the  spreadsheet. PLOT DATA
  4925.                accesses x,y pairs from the xrange and yrange specified.
  4926.                It will plot data from the first row to the  last row in
  4927.                the range.  Please refers  to PLOT for marker number and
  4928.                LINE for linetype. NOTE: if your  data are  quite dense,
  4929.                the linetype other than 1 may not break the line the way
  4930.                you specified.
  4931.  
  4932.      SPLINE
  4933.      ______
  4934.           Syntax:
  4935.                SPLINE xrange, yrange,increment
  4936.  
  4937.           Description:
  4938.                     Given n points (knots), mathematicians can  find n-
  4939.                1 different  cubic polynomials  that pass  through the n
  4940.                  _________
  4941.                points. This curve  generated  by  those  polynomials is
  4942.                called  spline-curve.  It  is  a smooth curve and it may
  4943.                represent the  data  more  closely  than  connecting the
  4944.                points with  lines. Increment should be smaller than any
  4945.                subinterval of the n  points. NOTE:  To use  SPLINE, you
  4946.                                              NOTE:  To use  SPLINE, you
  4947.                must provide at least 4 points.
  4948.                must provide at least 4 points.
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.  
  4955.  
  4956.  
  4957.  
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963.                                 Page 63
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973.  
  4974.  SHEET User manual             By Chor-ming Lung                October 9,
  4975. 1988
  4976.  
  4977. Turtlegraphics:
  4978. ______________
  4979.      Turtlegraphics is quite interesting. I add these commands just for
  4980. fun. Only three commands are provided though.
  4981.  
  4982.      FORWARD:
  4983.      _______
  4984.           Syntax:
  4985.                FORWARD distance
  4986.  
  4987.           Description:
  4988.                     FORWARD command in LOGO  uses pixel  as measurement
  4989.                for  distance.   SHEET  BASIC  uses  the  scale  factors
  4990.                specified by SCALE  as  measurement  for  distance. This
  4991.                command moves the drawing pen specified by the parameter
  4992.                distance. Distance can be  negative  which  make FORWARD
  4993.                acts as BACK in LOGO.
  4994.  
  4995.           Example:
  4996.                FORWARD 5.2
  4997.  
  4998.      TURN, TURN_TO:
  4999.      ____  _______
  5000.           Syntax:
  5001.                TURN degree
  5002.                TURN_TO degree
  5003.  
  5004.           Description:
  5005.                     They  are  the  only  commands in SHEET BASIC using
  5006.                degrees instead  of radians.  Degree 0  points to North.
  5007.                East is  90 degree,  South is  180 and West is 270. TURN
  5008.                turns the  active  turtle  by  the  amount  specified in
  5009.                rotation.  TURN  is  similar  to  LEFT  if the degree is
  5010.                positive and RIGHT if the degree is negative. TURN_TO is
  5011.                similar to  SETHEADING in LOGO, which sets the direction
  5012.                of the active turtle to a specified angle.
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.                                 Page 64
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  SHEET User manual             By Chor-ming Lung                October 9,
  5047. 1988
  5048.  
  5049. Axis command:
  5050. ____________
  5051.      It is easy to draw the  x-axis and  y-axis by  using LINE command,
  5052. but you  may also want to know where x=3 on the x-axis. MARKX and MARKY
  5053. commands help you to mark your axes with measurement. LABELX and LABELY
  5054. let you add the number 3 under the mark.
  5055.  
  5056.      MARKX/MARKY:
  5057.      ___________
  5058.           Syntax:
  5059.                MARKX y_origin, xmin, xmax, xinc, xstep
  5060.                MARKY x_origin, ymin, ymax, yinc, ystep
  5061.  
  5062.           Description:
  5063.                     An example  may help  me to explain better. Suppose
  5064.                that you are drawing an x-y  graph for  your income from
  5065.                1970  to  1988  and  your  income  ranges from 12,000 to
  5066.                40,000.
  5067.                          SCALE 1969, 0, 1989, 45000
  5068.                Making the x-axis one year larger on both sides give you
  5069.                some blank  spaces. You do not care about amount smaller
  5070.                than 12,000. The following command draws the x-axis.
  5071.                          LINE 1969,12000,1989,12000
  5072.                Your y_origin starts from 12000. xmin  is 1970  and xmax
  5073.                is 1988.  You want  to mark  each year and have a bigger
  5074.                mark on each five year. Here is the command:
  5075.                          MARKX 12000,1970,1988,1,5
  5076.                MARKY works similarly.
  5077.  
  5078.                NOTE: xstep should be a multiple of xinc.
  5079.  
  5080.      LABELX/LABELY:
  5081.      _____________
  5082.           Syntax:
  5083.                LABELX y_origin, xmin, xmax, xinc, format
  5084.                LABELY x_origin, ymin, ymax, yinc, format
  5085.  
  5086.           Description:
  5087.                     I am using the same example on MARKX. Now, you want
  5088.                to add  the year 1970 to 1988 on your graph. The command
  5089.                to do this is:
  5090.                          LABELX 12000,1970,1988,1,"f0"
  5091.                You may find some  of the  numbers are  overlapped. Then
  5092.                you should adjust xinc.
  5093.  
  5094.                Format is a string that specified what kind of format we
  5095.                are going to use  for displaying  the labels. Currently,
  5096.                there are  two formats  supported by  LABELX and LABELY.
  5097.                They are FIXED andCIENTIFIC. Theee string starts with an
  5098.                f or  F means  the labels  are FIXED  number. The number
  5099.                following f/F is the decimal place.  A scientific format
  5100.                starts  with  an  s/S.  The  format string ("f0") on the
  5101.                example means that we are displaying integers.
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.                                 Page 65
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  SHEET User manual             By Chor-ming Lung                October 9,
  5119. 1988
  5120.  
  5121. Text command:
  5122. ____________
  5123.  
  5124.      PTEXT:
  5125.      _____
  5126.           Syntax:
  5127.                PTEXT x,y,string[,color, effects, rotation, height]
  5128.  
  5129.           Description:
  5130.                     PTEXT plots string on the location (x,y). There are
  5131.                some special effects:
  5132.                     1:   bold face
  5133.                     2:   light
  5134.                     4:   italic
  5135.                     8:   underline
  5136.                     16:  outline
  5137.                     32:  shadowed
  5138.                If you  want to  use more  than one special effects, you
  5139.                can do that by adding the  number for  each effects. For
  5140.                example, if  you want  to plot the string with bold face
  5141.                and underline, you should use 9 (1+8) for the effects.
  5142.  
  5143.                Rotation  changes  the  direction  the  characters being
  5144.                displayed.
  5145.                     0:        East
  5146.                     900:      North
  5147.                     1800:     West
  5148.                     2700:     South
  5149.  
  5150.                Height of  a font  may be  changed but you may not get a
  5151.                good result. The following  height  numbers  provide the
  5152.                best result for small and normal fonts.
  5153.                     Color monitor:
  5154.                          small font:    4
  5155.                          normal font:   6
  5156.                     Monochrome monitor:
  5157.                          small font:    6
  5158.                          normal font:   13
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.                                 Page 66
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  SHEET User manual             By Chor-ming Lung                October 9,
  5190. 1988
  5191.  
  5192. Miscellaneous:
  5193. _____________
  5194.  
  5195.  
  5196.      MOUSE_POS:
  5197.      _________
  5198.           Syntax:
  5199.                MOUSE_POS x,y
  5200.  
  5201.           Description:
  5202.                     x,y  should   be  variables   or  cell  references.
  5203.                MOUSE_POS will wait for you to press the  left button on
  5204.                your  mouse.  If  your  mouse cursor is within the block
  5205.                specified by WINDOW or  VIEWPORT, then  the Cartesian of
  5206.                the mouse  cursor will  be stored on x,y. Otherwise, the
  5207.                Raster coordinate is stored on x,y.
  5208.                     This command  is useful  for finding  the value for
  5209.                WINDOW,  VIEWPORT  or  PTEXT.  It is also useful to find
  5210.                some data points from your graph.
  5211.  
  5212.           Hints:
  5213.                     Mouse click response time varies not  in a constant
  5214.                way (refer  to problems part). You may better add a WAIT
  5215.                                                                    ____
  5216.                1 statement after the MOUSE_POS. So, user can  press the
  5217.                _
  5218.                button  a  little  bit  longer  without caing problem.
  5219.                Also, MOUSE_POS will keep  polling until  you press your
  5220.                mouse  button.  It  means  your  system is suspended for
  5221.                mouse click. You cannot break its  operation by pressing
  5222.                <Esc>. You  have better  add an ALERT or MESSAGE telling
  5223.                user to press the mouse button.
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.                                 Page 67
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  SHEET User manual             By Chor-ming Lung                October 9,
  5263. 1988
  5264.  
  5265.                        Tips on using SHEET BASIC
  5266. Interrupt:
  5267. Interrupt
  5268.           You can stop your BASIC program by pressing <Esc> key.
  5269.  
  5270. Using previous row format:
  5271. Using previous row format
  5272.           If  your  BASIC  program  generates  a  lot  of  data  to the
  5273.      worksheet,  you  should  choose  "Using previous format" from menu
  5274.      item "Options" to non.  It will  speed up  a little  of your BASIC
  5275.      program.
  5276.  
  5277. Error:
  5278. Error
  5279.           When the BASIC interpreter encounters error, it will tell you
  5280.      what is wrong and where the offending code is. You  can use  F2 to
  5281.      edit that  line and re-run it again. If your offending cell is for
  5282.      example G12, instead of re-run it,  you  can  use  "@goto  g12" to
  5283.      continue your program. It may save you some time.
  5284.  
  5285. Multiple statements:
  5286. Multiple statements
  5287.           You  can  enter  more  than  one  statement  in  a cell. Each
  5288.      statement must be separated by colon. Entering multiple statements
  5289.      in  one  cell  will  save  some  memory,  but don't enter too many
  5290.      because your editing buffer can hold 250 characters only.
  5291.  
  5292. Garbled screen:
  5293. Garbled screen
  5294.           If you output some data to your monitor,  your current screen
  5295.      display will  be garbled.  In case  you forget to save your screen
  5296.      before you print, you  can rebuild  your display  by the following
  5297.      steps:
  5298.           -    Select the menu bar and choose "About SHEET"
  5299.           -    Press return when the dialog shown up.
  5300.           -    If the  number of  windows being  opened is less than 4,
  5301.                you can choose "New" to open up a new worksheet and then
  5302.                close it.
  5303.           -    If the  number is  4, then you must move your window out
  5304.                of the screen and move it back.
  5305.  
  5306. Adjust:
  5307. Adjust
  5308.           When I wrote the first SHEET  BASIC  program,  I  felt  it is
  5309.      clumsy  to  enter  "!"  at  the  beginning of each statement and I
  5310.      forgot to enter "!" in some cells. If you have  the same problems,
  5311.      you can use the following technique to enter BASIC statement.
  5312.           As we know, each BASIC statement starts with an alpha letter.
  5313.      SHEET will treat any  cell entry  starts with  an alpha  letter as
  5314.      TEXT string.  You can  enter your  BASIC codes  as text string and
  5315.      then adjust them to BASIC statements. The steps to adjust codes:
  5316.           -    select blocks to cover the desired cells
  5317.           -    Press <Control A> and choose "BASIC  (!)" to  adjust the
  5318.                text string to BASIC statements.
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.                                 Page 68
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  SHEET User manual             By Chor-ming Lung                October 9,
  5338. 1988
  5339.  
  5340.                      Appendix A BUILT-IN FUNCTIONS
  5341.                      _____________________________
  5342.  
  5343.  
  5344. Math:
  5345. ____
  5346.      General functions:
  5347.           ABS(x):   Absolute function of x
  5348.           INT(x):   Integer part of x (e.g. +int(12.4) = 12)
  5349.           FRAC(x):  Fraction part of x (e.g. +frac(12.4) = 0.4)
  5350.           FACT(x):  Factorial of x. X < 34
  5351.           SQR(x):   Square function of x
  5352.           SQRT(x):  Square root of x
  5353.  
  5354.      Trigo & logarithm functions:
  5355.           SIN(x):   Sine function of x. X is measured in radian
  5356.           COS(x):   Cosine function of x.
  5357.           TAN(x):   Tangent function of x.
  5358.           ASIN(x):  Arc sine function of x
  5359.           ACOS(x):  Arc cosine function of x
  5360.           ATAN(x):  Arc tangent of x
  5361.           LOG(x):   Logarithm base 10
  5362.           LN(x):    Logarithm base e
  5363.           EXP(x):   Exponent of x
  5364.           RAD_DEG(x): Radian to degree
  5365.           DEG_RAD(x): Degree to radian
  5366.  
  5367.      DATE functions:
  5368.           DATE(mm,dd,yy): Function for calculating Julian days.
  5369.           DAY(x):   Day of x. X is Julian day
  5370.           MONTH(x): Month of x
  5371.           YEAR(x):  Year of x
  5372.           NOTE: 1.  You  can  use  the  following  formula  to find the
  5373.                     weekday of the date:
  5374.                           (date(mm,dd,yy)+1) mod 7
  5375.                     0 if Sunday, 1 if Monday and so on.
  5376.                 2.  You can  use  the  following  formula  to  find the
  5377.                     number of days on a specific month.
  5378.                     case 1: mm<12       date(mm+1,1,yy)-date(mm,1,yy)
  5379.                     case 2: mm=12       date(1,1,yy+1)-date(mm,1,yy)
  5380.  
  5381.      Matrix functions:
  5382.                A matrix  in a  worksheet is a block embraced by "[" and
  5383.           "]". For example, to make A1..C3  as a  matrix, it  should be
  5384.           [A1..C3].  Versions  before  2.0 of SHEET restrict individual
  5385.           matrix size within 64K. This limit has been removed.
  5386.  
  5387.                Matrix operators include *,+ and -. There is no priority
  5388.           for those  matrix operators.  Formula is calculated from left
  5389.           to right. Parenthesis can be used  to change  the calculation
  5390.           order.
  5391.  
  5392.                There are  only two  matrix functions.  They are INVERSE
  5393.           and TRANSPOSE. Their arguments must be  a matrix  or a matrix
  5394.           operations grouped by parenthesis.
  5395.  
  5396.                The sequence of activating matrix operations is:
  5397.  
  5398.                                 Page 69
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  SHEET User manual             By Chor-ming Lung                October 9,
  5410. 1988
  5411.  
  5412.  
  5413.                     MATRIX(cell, matrix_operations)
  5414.  
  5415.           Cell:  The  cell  reference  of  the  MATRIX  is  the leading
  5416.                location where matrix operations put their result.
  5417.           Matrix_operations: Matrix operations can  be matrix functions
  5418.                or combination of matrix operators.
  5419.  
  5420.           For  example,  to  store  the  inverse  of matrix [a1..c3] in
  5421.           matrix  [d1..f3],  you  should  store  the  following formula
  5422.           somewhere:
  5423.                       +MATRIX(d1,inverse[a1..c3])
  5424.  
  5425.  
  5426. Statistics:
  5427. __________
  5428.      AVERAGE(  any  number  of  parameters  ):  Average  of parameters.
  5429.                Parameters  can  be   a   single   cell   reference,  an
  5430.                expression, a block of cells.
  5431.      MEDIAN( any number of parameters ): Median of parameters.
  5432.      STD( any number of parameters): Standard deviation of parameters.
  5433.      VAR( any number of parameters): Variance of parameters.
  5434.      SQR_SUM( any number of parameters): Square sum of parameters.
  5435.  
  5436.  eg. +AVERAGE(A1..F4,234,12+24.5,H2+34*sin(pi))
  5437.  
  5438.  
  5439. Miscellaneous:
  5440. _____________
  5441.      MAX(any number of parameters): Maximum value of parameters.
  5442.      MIN(any number of parameters): Minimum value of parameters.
  5443.      SUM(any number of parameters): Sum of all parameters.
  5444.      RAND: Random number between 0 and 1.
  5445.      IFF(condition,true_value, false_value): IF function
  5446.      ISEMPTY(cell): return 1 if cell is empty, otherwise 0
  5447.      TRUE: it is equal to 1
  5448.      FALSE: it is equal to 0
  5449.      ALERT     ALERT(default, "[icon#][text][exit]")
  5450.                Uses the alert box to get user's response.
  5451.        icon#:
  5452.           0:   no icon
  5453.           1:   NOTE icon (!)
  5454.           2:   WAIT icon (?)
  5455.           3:   STOP icon (stop sign)
  5456.        text:
  5457.           text string  can be  up to 5 lines. Each line is separated by
  5458.           "|". You cannot have more than 40 characters per line. If you
  5459.           use  icon,  then  the  number  of  character per line must be
  5460.           lesser than  40. Keep  your character  per line  less than 30
  5461.           will be safe.
  5462.        exit:
  5463.           Up to 3 exit button can be defined. Each of them is separated
  5464.           by "|".
  5465.  
  5466.       eg.
  5467.           !A3=ALERT(1,"[1][This is a test|Wow][Ok|Cancel]")
  5468.  
  5469.                                 Page 70
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  SHEET User manual             By Chor-ming Lung                October 9,
  5481. 1988
  5482.  
  5483.      COL_WIDTH COL_WIDTH(block)
  5484.                Returns the  total column  widths that  holds the block.
  5485.                For example, if column width of A is 8 and B is 12 and C
  5486.                is 4:
  5487.           eg   COL_WIDTH(a1)            ==> 8
  5488.                COL_WIDTH(b1..c1)        ==> 16
  5489.  
  5490.      LAST_ROW  LAST_ROW(cell,r)
  5491.                Returns the value stores in the  last row  on the column
  5492.                the cell  is. r  tells you  where the  last row is. r is
  5493.                zero origin. For example, if the last row of column B is
  5494.                12 and cell B12 has a value of 123.45:
  5495.           eg   LAST_ROW(b20,row)        ==> 123.45 and row=11
  5496.                You can access the last cell by using B1[0,row]
  5497.  
  5498.      LAST_COL  LAST_COL(cell,c)
  5499.                Returns the  value stores  in the last column on the row
  5500.                the cell is. c tells you where the last column  is. c is
  5501.                zero origin. For example, if the last column of row 4 is
  5502.                H and cell H4 has a value of 456.77:
  5503.           eg   LAST_COL(a4,col)         ==> 456.77 and col=7
  5504.                You can access the last cell by using a4[col,0]
  5505.  
  5506.      SEARCH    SEARCH(STRING,block,r,c)
  5507.                A boolean function to find  out  whether  STRING  in the
  5508.                block and  r,c tell  you where  the cell is. r and c are
  5509.                zero origin so you can access the cell by using a1[c,r].
  5510.                NOTE: the  comparison is  case insensitive and a cell of
  5511.                the block  which has  a substring  includes STRING, then
  5512.                the location  of that cell will be stored in r and c. If
  5513.                search fails, r and c will not be changed.
  5514.           eg.  Assume    that    cell   A5$="What",b5$="is",c5$="your",
  5515.                d5$="name?".
  5516.                SEARCH("You",a5..d5,r,c) ==> 1  and r=4,  c=2. To access
  5517.                the cell that holds a substring of "YOU", you should use
  5518.                a1[c,r]$ (it is c5$ in this case).
  5519.  
  5520.  
  5521. Finance:
  5522. _______
  5523.      Future growth:
  5524.           GRATE(a time series data): Average growth rate.
  5525.           GBASE(a time series data): Adjusted base value
  5526.           GFUTURE(grate,gbase,  predict  time):  Future values based on
  5527.                grate and gbase
  5528.  
  5529.           A time  series  data  is  data  being  collected  in  a fixed
  5530.           frequency of  time. They  may be  gathered yearly, quarterly,
  5531.           monthly or daily. For  example, you  income is  a time series
  5532.           data  that  is  increased  yearly. For a more detail example,
  5533.           refer to the example file "FG.SHT"
  5534.  
  5535.      Investment:
  5536.           INVEST_PV(final value, interest, compound  frequency, terms):
  5537.                Present value of investment
  5538.  
  5539.                                 Page 71
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.  
  5549.  
  5550.  SHEET User manual             By Chor-ming Lung                October 9,
  5551. 1988
  5552.  
  5553.           INVEST_FV(present   value,   interest,   compound  frequency,
  5554.                terms): Future value of investment
  5555.           INVEST_INTEREST(present   value,    final   value,   compound
  5556.                frequency, terms):Compound interest of investment
  5557.           INVEST_TERM(present  value,  final  value, interest, compound
  5558.                frequency): Terms of investment.
  5559.  
  5560.           Please  refer  to  the  file  "INVEST.SHT"  for  using  those
  5561.           functions.
  5562.  
  5563.      Loan:
  5564.           LOAN_PAY(amount  borrowed,  interest,total  terms,  number of
  5565.                terms per year): Payment for each term.
  5566.           LOAN_AMOUNT(payment, interest, total terms,  terms per year):
  5567.                Amount borrowed.
  5568.           LOAN_TERM(amount  borrowed,   payment,  interest,  terms  per
  5569.                year): Total number of terms for loan.
  5570.  
  5571.           Please  refer  to  the   file  "LOAN.SHT"   for  using  those
  5572.           functions.
  5573.  
  5574.      Withdraw:
  5575.           WDRAW_SAVE(amount  withdrawn,   interest,  terms,  terms  per
  5576.                year): Initial Investment
  5577.           WDRAW_AMOUNT(amount saved, interest, terms,  terms per year):
  5578.                Amount withdrawn.
  5579.           WDRAW_TERM(amount  saved,  amount  withdrawn, interest, terms
  5580.                per year): Total terms
  5581.  
  5582.           Please refer  to  the  file  "WITHDRAW.SHT"  for  using those
  5583.           functions.
  5584.  
  5585.      Deposit:
  5586.           DEPOSIT_FV(amount,  interest,  total  terms, terms per year):
  5587.                Final value for deposit
  5588.           DEPOSIT_AMOUNT(final value, interest, total  terms, terms per
  5589.                year): Regular deposit
  5590.           DEPOSIT_TERM(amount, final  value, interest, terms per year):
  5591.                Total number of terms.
  5592.  
  5593.           Please  refer  to  the  file  "DEPOSIT.SHT"  for  using those
  5594.           functions.
  5595.  
  5596.  
  5597.  
  5598. String functions:
  5599. _________________
  5600.      FILENAME$ FILENAME$ is a string variable that can only be modified
  5601.                by file selector dialog box.
  5602.  
  5603.      BUF$      BUF$ is  a string  variable that  can be  changed by the
  5604.                command INPUT only.
  5605.  
  5606.      MID$:     MID$(STRING,s,len)
  5607.                Returns  a  substring  of  STRING,  starting from s with
  5608.  
  5609.                                 Page 72
  5610.  
  5611.  
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618.  
  5619.  
  5620.  SHEET User manual             By Chor-ming Lung                October 9,
  5621. 1988
  5622.  
  5623.                length len. If s is larger than the length of the string
  5624.                STRING, then  a substring range error occur. If len+s is
  5625.                larger than the length  of STRING,  then up  to the last
  5626.                character will be returned.
  5627.           eg   MID$("12345678",4,3)     ==> "456"
  5628.                MID$("12345678",14,3)    ==> substring range error
  5629.                MID$("12345678",4,20)    ==> "45678"
  5630.  
  5631.      LEFT$:    LEFT$(STRING,len)
  5632.                Returns  a  substring  of  STRING,  starting from 1 with
  5633.                length len. If len is larger  than the  actual length of
  5634.                STRING, the whole STRING will be returned.
  5635.           eg   LEFT$("12345678",4)      ==> "1234"
  5636.                LEFT$("12345678",20)     ==> "12345678"
  5637.  
  5638.      RIGHT$:   RIGHT$(STRING,len)
  5639.                Returns  a  substring  of  STRING,  from  the  far right
  5640.                portion of STRING with length len. If len is larger than
  5641.                the length of STRING, then substring range error occurs.
  5642.           eg.  RIGHT$("12345678",4)     ==> "5678"
  5643.                RIGHT$("12345678",20)    ==> substring range error
  5644.  
  5645.      SPACE$:   SPACE$(num)
  5646.                Returns a string with num of blank spaces. num must be a
  5647.                positive integer.
  5648.           eg.  SPACE$(4)                ==> "    "
  5649.  
  5650.      CHR$:     CHR$(num)
  5651.                Returns a string with  one character  whose ASCII number
  5652.                is equal to num. num is in the range of 0 to 255.
  5653.           eg   CHR$(82)                 ==> "R"
  5654.  
  5655.      STR$:     STR$([FORMAT,]value)
  5656.                Changes a  number value  to a  string equivalent to that
  5657.                value. FORMAT is optional. It is a string which consists
  5658.                of  three  part  --  width, format, decimal point. It is
  5659.                equivalent to  return a  cell string  with column width,
  5660.                format and decimal place.
  5661.           eg   STR$(1234.5)             ==> "1234.5"
  5662.                STR$("12$2",1234.5)      ==> "    $1234.50"
  5663.  
  5664.      VAL:      VAL(STRING)
  5665.                Returns the  value of  STRING. This  function will strip
  5666.                off characters other than "E", digits, "+", "-"  and "."
  5667.                first and do the translation later.
  5668.           eg   VAL("abc123.45")         ==> 123.45
  5669.                VAL(".23e-2")            ==> 0.0023
  5670.                VAL(".23ae-2")           ==> 0.0023
  5671.  
  5672.      LEN:      LEN(STRING)
  5673.                Returns the  length of the STRING. An empty string has a
  5674.                len of zero.
  5675.           eg   LEN("")                  ==> 0
  5676.                LEN("123456")            ==> 6
  5677.  
  5678.                                 Page 73
  5679.  
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686.  
  5687.  
  5688.  
  5689.  SHEET User manual             By Chor-ming Lung                October 9,
  5690. 1988
  5691.  
  5692.  
  5693.      POS:      POS(STRING1,STRING2,start)
  5694.                Return the position of  any  character  of  STRING1 from
  5695.                STRING2  beginning  from  start.  All  the  character of
  5696.                STRING1 and STRING2 will be changed to upper case first.
  5697.                A zero  will be returned if none has been found or start
  5698.                is larger than the len of STRING2.
  5699.           eg   POS(" ", "What is this?",1)==> 5
  5700.                     A space in position 5.
  5701.                POS("ts","What is this?",1)==>4
  5702.                     "t" is in position 4
  5703.                POS("ts","What is this?",5)==>7
  5704.                     "s" is in position 7
  5705.                POS("AT","What is this?",1)==>3
  5706.                     "A" is in position 3. Case insensitive.
  5707.                POS(",-","What is this?",1)==>0
  5708.  
  5709.  
  5710.  
  5711.  
  5712.                         Appendix B CONTROL KEYS
  5713.                         _______________________
  5714.  
  5715. Non-editing:
  5716. ___________
  5717.      <Esc>               stops a running BASIC program.
  5718.      <Up arrow>          moves cell cursor one row up.
  5719.      <Down arrow>        moves cell cursor one row down.
  5720.      <Left arrow>        moves cell cursor one column left.
  5721.      <Right arrow>       moves cell cursor one column right.
  5722.      <Shift><arrows>     moves cell  cursor to  the direction specified
  5723.                          by the arrow key by page.
  5724.      <Return>            changes the editing direction to neutral.
  5725.      <Control><A>        adjusts  TEXT  string  to  BASIC statements or
  5726.                          text justification.
  5727.      <Control><N>        creates a new sheet
  5728.      <Control><L>        loads a sheet file
  5729.      <Control><S>        saves current spreadsheet
  5730.      <Control><P>        prints current spreadsheet
  5731.      <Control><Q>        exits to desktop
  5732.      <Control><I>        inserts a row or a column
  5733.      <Control><D>        deletes a row or a column
  5734.      <Control><R>        reformats cells
  5735.      <Control><E>        erases cells
  5736.      <Control><C>        copies cells
  5737.      <Control><M>        moves cells
  5738.      <Control><mouse click> defines the starting cell of a block
  5739.      <Shift><mouse click> defines the stopping cell of a block
  5740.      <Alternate><1>      switches to the first window
  5741.      <Alternate><2>      switches to the second window
  5742.      <Alternate><3>      switches to the third window
  5743.      <Alternate><4>      switches to the fourth window
  5744.      <Alternate><F>      refreshes the current window.
  5745.      <Alternate><C>      recalculates the spreadsheet by column
  5746.      <Alternate><N>      recalculates the spreadsheet by natural order
  5747.      <Alternate><R>      recalculates the spreadsheet by row
  5748.  
  5749.                                 Page 74
  5750.  
  5751.  
  5752.  
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  SHEET User manual             By Chor-ming Lung                October 9,
  5761. 1988
  5762.  
  5763.      <F2>                modifies the current cell's content
  5764.      <F5>                Goto a specified cell.
  5765.  
  5766. Editing:
  5767. _______
  5768.      <Up arrow>          terminates and moves cell  cursor one  row up.
  5769.                          The editing direction changes to up direction.
  5770.      <Down arrow>        terminates and moves cell cursor one row down.
  5771.                          The editing direction changes to down.
  5772.      <Left arrow>        terminates and moves  cell  cursor  one column
  5773.                          left. The editing direction changes to left.
  5774.      <Right arrow>       terminates  and  moves  cell cursor one column
  5775.                          right. The editing direction changes to right.
  5776.      <Shift><Left arrow> moves editing cursor to left.
  5777.      <Shift><Right arrow> moves editing cursor to right.
  5778.      <Return>            terminates  and  moves  cell   cursor  to  the
  5779.                          direction specified by editing direction.
  5780.      <Mouse click>       if  the  mouse  cursor is within working area,
  5781.                          the coordinate of the cell under  mouse cursor
  5782.                          will be  inserted into  editing buffer; if the
  5783.                          mouse cursor is within  the editing  line, the
  5784.                          editing  cursor  will  move  to  the character
  5785.                          under the mouse cursor.
  5786.      <Control><mouse click> if the mouse cursor is within working area,
  5787.                          a comma  and the  coordinate of the cell under
  5788.                          mouse cursor  will  be  inserted  into editing
  5789.                          buffer.
  5790.      <Shift><mouse click> if the mouse cursor is within working area, a
  5791.                          through symbol ".." and the coordinate  of the
  5792.                          cell under  mouse cursor will be inserted into
  5793.                          editing buffer.
  5794.  
  5795.  
  5796.  
  5797.  
  5798.                    Appendix C Program specification:
  5799.                    ________________________________
  5800.  
  5801.           SHEET is written in  Mark Williams  C. The  accuracy for real
  5802.      number (double)  in Mark  Williams C is up to 17 digits (Lotus 123
  5803.      is up to 15 digits). The range  of  calculation  is      -1E-37 to
  5804.      1E+37.   Each spreadsheet can accomdate up to 2,549,745 (255*9999)
  5805.      cells and the spreadsheet is implemented  by using  Sparse Matrix.
  5806.      Any input to a cell will be tokenized before it is being inserted.
  5807.      This program support up to 4 windows. The BASIC interpreter can be
  5808.      used to handle graphics, string, and ASCII text files.
  5809.  
  5810.      Accuracy:
  5811.      Accuracy       up to 17 digits
  5812.      Range:
  5813.      Range          -1E-37 to  1E+37 (If you find 1e+37 in a cell, that
  5814.                     means the calculation for that cell is not correct)
  5815.      Arithmetic operators:
  5816.      Arithmetic operators
  5817.                     "+", "-", "*", "/", "^", MOD
  5818.      Logical operators:
  5819.      Logical operators:
  5820.                     AND, OR, NOT,  "=",  "<>",  ">",  "<",  ">=", "<=",
  5821.                     "=>", "=<"
  5822.      Built-In functions:
  5823.      Built-In functions
  5824.  
  5825.                                 Page 75
  5826.  
  5827.  
  5828.  
  5829.  
  5830.  
  5831.  
  5832.  
  5833.  
  5834.  
  5835.  
  5836.  SHEET User manual             By Chor-ming Lung                October 9,
  5837. 1988
  5838.  
  5839.           Math:     SIN, COS, TAN, ASIN, ACOS, ATAN, LOG, EXP, LN, ABS,
  5840.                     INT, FRAC, SQR, SQRT, DATE, FACT, RAD_DEG, DEG_RAD,
  5841.                     PI (constant)
  5842.           Statistics:
  5843.                     AVERAGE, MEDIAN, STD, VAR, SQR_SUM
  5844.           Miscellaneous:
  5845.                     MAX,  MIN,  SUM,  COUNT,  TODAY,  DAY, MONTH, YEAR,
  5846.                     TRUE, FALSE (TRUE and FALSE are constant, TRUE is 1
  5847.                     and  FALSE  is  0),  IFF, ISEMPTY, ALERT, LAST_ROW,
  5848.                     LAST_COL, SEARCH.
  5849.           Finance:  GRATE,   GBASE,   GFUTURE,   INVEST_PV,  INVEST_FV,
  5850.                     INVEST_INTEREST,       INVEST_TERM,       LOAN_PAY,
  5851.                     LOAN_AMOUNT,  LOAN_TERM,  WDRAW_SAVE, WDRAW_AMOUNT,
  5852.                     WDRAW_TERM,       DEPOSIT_FV,       DEPOSIT_AMOUNT,
  5853.                     DEPOSIT_TERM
  5854.           String:   MID$, CHR$, LEFT$, RIGHT$, SPACE$, STR$,  VAL, LEN,
  5855.                     ASC, FILENAME$(a string variable used for file item
  5856.                     selector) and BUF$(a string  variable  used  by the
  5857.                     command INPUT).
  5858.           Matrix:   MATRIX, TRANSPOSE, INVERSE, *, +, -
  5859.  
  5860.      Priority:
  5861.      Priority
  5862.           Lowest: - AND, OR
  5863.                   - "+", "-"
  5864.                   - "*", "/", "^", MOD
  5865.                   - number,  cell  reference,  variable, function call,
  5866.                     NOT, "+", "-" (unary operator)
  5867.           Highest:- Parenthesis
  5868.      Constants:
  5869.      Constants      PI(0.31415926535897932e+01), TODAY(Julian days when
  5870.                     you press TODAY), TRUE(1), FALSE(0).
  5871.      Cell reference:  A cell  can be  referred by using its spreadsheet
  5872.      Cell reference
  5873.                     coordinate (e.g. D1) If you add  a "$"  in front of
  5874.                     the row  number (in  this example 1) or in front of
  5875.                     the column letter (D) then you make it  an absolute
  5876.                     reference. If  you add  "$" at  the end of the cell
  5877.                     reference, then you are using it  as a  string. You
  5878.                     can use  a cell  as BASE  and move it vertically or
  5879.                     horizontally by  appending  two  numbers  which are
  5880.                     separated by comma and embraced by "[" and "]". The
  5881.                     first number increases  the  BASE  horizontally and
  5882.                     the  second  number  increases the BASE vertically.
  5883.                     For example A2[3,4]. You  can separate  A2 to [1,2]
  5884.                     (Column A  has a  value of  1, B  has 2 and so on).
  5885.                     A2[3,4] = [1,2]+[3,4]=[4,6]=D6.
  5886.      Variables:
  5887.      Variables      Up to 150 variables  can  be  defined.  This number
  5888.                     includes the  user defined function. It is intended
  5889.                     for BASIC usage. For the time being, you cannot use
  5890.                     those variables to hold any string.
  5891.  
  5892.  
  5893.  
  5894.                       Appendix D Lotus and SHEET
  5895.                       __________________________
  5896.  
  5897.  
  5898.  
  5899.                                 Page 76
  5900.  
  5901.  
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.  
  5909.  
  5910.  SHEET User manual             By Chor-ming Lung                October 9,
  5911. 1988
  5912.  
  5913.           In Lotus,  you must  add a  '@' symbol  before every function
  5914.      name. In SHEET, no special symbol  is required  to put  before the
  5915.      function name. However, if a function name is the first element of
  5916.      your formula, a '+' or '('  is required  to differentiate  it from
  5917.      TEXT.
  5918.           Lotus requires  you to  put #  symbol to  embrace the logical
  5919.      operators. For example , "+A1 #AND# A2". It  is invalid  in SHEET.
  5920.      Actually, you will get 2 bombs if you enter the above formula. You
  5921.      should avoid adding special character in  your formula.  The valid
  5922.      form is "+A1 AND A2".
  5923.           Lotus  @COUNT  function  will  count  any  cell  containing a
  5924.      numeric value or a label. SHEET will count only numeric value. For
  5925.      example,
  5926.                A
  5927.                _         B
  5928.                          _
  5929.           1
  5930.           _       12  This is a test
  5931.      @COUNT(A1..B1) will return 2 and COUNT(A1..B1) will return 1.
  5932.           Lotus @DATE function asks for arguments (YYYY,MM,DD) and DATE
  5933.      function in SHEET asks for (MM,DD,YY). The first  day of  @DATE is
  5934.      1-Jan-1900 while the first day of DATE is 1-Jan-4712 B.C.
  5935.           Here is a list of Lotus functions which have equivalent SHEET
  5936.      functions but using different names.
  5937.  
  5938.      @FV(amount,interest,terms) = DEPOSIT_FV(amount,interest,terms,1)
  5939.      @RATE(fv,pv,term) = INVEST_INTEREST(pv,fv,12,term*12)
  5940.      @TERM(pmt,int,fv) = DEPOSIT_TERM(pmt,fv,int,12)
  5941.      @PMT(amount,interest,terms) = LOAN_PAY(amount,interest,terms,12)
  5942.  
  5943.  
  5944.  
  5945.                        Appendix E Recalculation
  5946.                        ________________________
  5947.  
  5948.      Natural:
  5949.      Natural   Recalculates each cell  in  the  dependent  order. NOTE:
  5950.                some spreadsheet programs use dependent list to find the
  5951.                dependent order and they  can quickly  recalculate those
  5952.                cells  being  affected.  SHEET  uses recursive method to
  5953.                recalculates  cells.  The  effect  is  that,  it blindly
  5954.                recalculate every  cell which contains formula and it is
  5955.                slower than using dependent  list. The  positive side is
  5956.                that, you have more memory to use than those spreadsheet
  5957.                programs. This is a trade-off between speed and space.
  5958.      Row:
  5959.      Row:      Recalculate each row in the ascending order.
  5960.      Column:
  5961.      Column:   Recalculate each column in the ascending order.
  5962.  
  5963.      Manual:
  5964.      Manual    The spreadsheet stops automatic  recalculation. User has
  5965.                to press <ALT-N>, <ALT-R> or <ALT-C> for natural, row or
  5966.                column   recalculation,   where   <ALT-N>   means  press
  5967.                <Alternate> key with character key <N> simultaneously.
  5968.      Note:     It  is  no  longer  true  that  natural recalculation is
  5969.                slower than row or column recalculation.
  5970.  
  5971.  
  5972.  
  5973.  
  5974.  
  5975.  
  5976.  
  5977.                                 Page 77
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988.  SHEET User manual             By Chor-ming Lung                October 9,
  5989. 1988
  5990.  
  5991.  
  5992.                         Appendix F FILE FORMAT
  5993.                         ______________________
  5994.  
  5995. Header for SHT:
  5996. Header for SHT
  5997.      -    270 bytes reserved data.
  5998.        Currently, there are a few bytes have been used.
  5999.           -    2 bytes for file version number, current version is 1.4
  6000.           -    1 bytes for screen type when the file saved. 1 for color
  6001.                monitor and 0 for monochrome monitor.
  6002.           -    2 bytes for maximum row number.
  6003.      -    40  bytes  for  window  title.  (39  characters  with  a null
  6004.           character)
  6005.      -    2 bytes: check-sum of the window  title to  make sure  we are
  6006.           handling the right work sheet.
  6007.      -    256 bytes for width of each columns
  6008.      -    2 bytes for window type (It is useless)
  6009.      -    8 bytes for current window size
  6010.      -    4 bytes for working area top row, top column
  6011.      -    4 bytes for current cell cursor address
  6012.      -    2 bytes for current recalculation mode
  6013.  
  6014. Cell contents for SHT format:
  6015. Cell contents for SHT format
  6016.      -    1 bytes for cell type (use this byte with 0x23 to do bit-wise
  6017.                and. If it is not 0, then it is NUMBER).
  6018.      -    2 bytes for length
  6019.        - IF NUMBER:
  6020.           2 bytes for row #, 1 byte for column #.
  6021.           2 bytes for attribute and 1 byte for decimal place
  6022.           8 bytes for calculating result.
  6023.        - IF NOT NUMBER (it may be TEXT or STATEMENT, its  decimal place
  6024.                and calculating result are not needed)
  6025.           2 bytes for row#, 1 byte for column #.
  6026.           2 bytes for attribute (it may be blank cell)
  6027.      -    IF length <> 0, length bytes of tokens.
  6028.      -    The last cell type and length are 0 and 0.
  6029.  
  6030. Header for PRT:
  6031. Header for PRT
  6032.      - 4 bytes holding "PART"
  6033.  
  6034. Cell contents for PART format:
  6035. Cell contents for PART format
  6036.      -    4 bytes for cell row, column
  6037.      -    2 bytes for display attribute
  6038.      -    2 bytes for decimal place
  6039.      -    2 bytes for tokens length
  6040.      -    8 bytes for calculated result
  6041.      -    tokens length bytes of actual tokens
  6042.  
  6043.  
  6044.  
  6045.                           Appendix G Problems
  6046.                           ___________________
  6047.  
  6048.      A user told me his cell cursor keep flashing
  6049.        ans:    It won't happen very often. It seems it happens when the
  6050.                system is newly bootup and you load SHEET right away. In
  6051.  
  6052.                                 Page 78
  6053.  
  6054.  
  6055.  
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  SHEET User manual             By Chor-ming Lung                October 9,
  6064. 1988
  6065.  
  6066.                SHEET, you  can locate  the cell  cursor by mouse click.
  6067.                You can also select a  block  by  prolonging  your mouse
  6068.                click (drag). When you press your mouse to move the cell
  6069.                cursor, SHEET  first  moves  your  cell  cursor  to that
  6070.                position  and  inverts  the  color  of  that cell. Mouse
  6071.                response time seems a  lot  faster  when  the  system is
  6072.                newly bootup.  Because of  the fast response time, SHEET
  6073.                thinks you are  still  pressing  your  mouse  button. It
  6074.                thinks you  are trying  to select  a block then. That is
  6075.                the reason why your cell cursor on and off. In  case you
  6076.                have this  problem, you  should choose  some of the help
  6077.                dialogs. 4 or 5 of  them  should  slow  down  your mouse
  6078.                response  time.  Another  method  found  by  a  user  is
  6079.                provided here. After the  system is  booted, you  type a
  6080.                key and then load your SHEET program.
  6081.  
  6082.      Why some of my input characters are being truncated?
  6083.         ans:   For  versions  before  2.0,  if  you  type  any  illegal
  6084.                character in your formula,  you will  be bombed  out and
  6085.                you  must  reboot  your  system  to  use SHEET. This new
  6086.                version of SHEET  prevents  this  problem  but  the rest
  6087.                characters after the illegal character will be truncated
  6088.                and a "#" symbol will be added at the end of the illegal
  6089.                formula. You should rewrite your formula.
  6090.  
  6091.  
  6092.  
  6093.  
  6094.  
  6095.  
  6096.  
  6097.  
  6098.  
  6099.  
  6100.  
  6101.  
  6102.  
  6103.  
  6104.  
  6105.  
  6106.  
  6107.  
  6108.  
  6109.  
  6110.  
  6111.  
  6112.  
  6113.  
  6114.  
  6115.  
  6116.  
  6117.  
  6118.  
  6119.  
  6120.  
  6121.                                 Page 79
  6122.  
  6123.  
  6124.  
  6125.  
  6126.  
  6127.  
  6128.  
  6129.  
  6130.  
  6131.  
  6132.  SHEET User manual             By Chor-ming Lung                October 9,
  6133. 1988
  6134.  
  6135.                            Biorthym program
  6136.                            ________________
  6137.  
  6138.  
  6139.      A   German   doctor   found   that  our  emotional,  physical  and
  6140. intellectual  conditions  change   in   sine   curves   with  different
  6141. frequencies. Emotional condition changes in 23 days per cycle, physical
  6142. 28 days, and intellectual 33 days. They are called biorthym.
  6143.  
  6144.      The following SHEET BASIC program uses the data  found to generate
  6145. the biorthym  curves for you. You should enter your name in cell B1 and
  6146. your birthday in B2 using +DATE(mm,dd,yy), then you  can run  it by the
  6147. command "@run e1".
  6148.  
  6149. E1    : !B3= TODAY
  6150. E2    : !B4=B3-B2+1:START= DATE( MONTH( TODAY),1, YEAR( TODAY))-B2
  6151. E3    : ! IF B3<0 THEN  MESSAGE "Date entry error": END
  6152. E4    : !EMOTION=START MOD 23
  6153. E5    : !PHYSICAL=START MOD 28
  6154. E6    : !INTELLECTUAL=START MOD 33
  6155. E7    : ! WINDOW 1,0,11,417,199
  6156. E8    : ! SCALE -4,-1.5,33,1.1
  6157. E9    : ! CLEAR :EC=2*PI/23:PC=2*PI/28:IC=2*PI/33
  6158. E10   : ! FOR X=1 TO 31
  6159. E11   : !Z1=EMOTION*EC:EMOTION=EMOTION+1
  6160. E12   : !Z2=PHYSICAL*PC:PHYSICAL=PHYSICAL+1
  6161. E13   : !Z3=INTELLECTUAL*IC:INTELLECTUAL=INTELLECTUAL+1
  6162. E14   : ! PLOT X, SIN(Z1),1: PLOT X, SIN(Z2),2: PLOT X, SIN(Z3),3
  6163. E15   : ! NEXT X
  6164. E16   : ! LINE 1,0,31,0
  6165. E17   : ! LINE 1,-1,1,1
  6166. E18   : ! MARKX 0,1,31,1
  6167. E19   : ! MARKY 1,-1,1,0.1,0
  6168. E20   : ! LABELX 0,2,30,2,"f0"
  6169. E21   : ! LABELY 1,-1,1,0.1,"f1"
  6170. E22   : ! PTEXT 11,-1.2,B1,1,1
  6171. E23   : ! PLOT -2,-1.35,1: PTEXT -1,-1.4,"Emotional"
  6172. E24   : ! PLOT 8,-1.35,2: PTEXT 9,-1.4,"Physical"
  6173. E25   : ! PLOT 20,-1.35,3: PTEXT 21,-1.4,"Intellectual"
  6174. E26   : ! EXITGRAPH
  6175. E27   : ! END
  6176.  
  6177. Explanations:
  6178. E1:  Set the current date on cell B3.
  6179. E2:  B4 holds the days of your life. Variable START holds the days from
  6180.      your birth to the first  day  of  current  month.  The  plus  1 in
  6181.      calculating  B4  means  that  your  first day is counted as 1. But
  6182.      biorthym calculates the first day as 0. (Sine curve starts  from 0
  6183.      to 2*PI).
  6184. E3:  This is  unnecessary. I  just want  to show  you how  to display a
  6185.      message.
  6186. E4:  Since our emotional condition changes in  a cycle  of 23  days, we
  6187.      can calculate  the condition  of the first day of current month by
  6188.      using the operator MOD.
  6189. E5:  Similar to E4
  6190. E6:  Similar to E4
  6191.  
  6192.                                 Page 80
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202.  
  6203.  SHEET User manual             By Chor-ming Lung                October 9,
  6204. 1988
  6205.  
  6206. E7:  Setup our graphic window
  6207. E8:  Setup the scaling factor.  Making  the  scaling  factors  a little
  6208.      larger than  what they actually are will provide some blank spaces
  6209.      for texts.
  6210. E9:  Clear  the  window  area.  EC  is  emotional  constant.  Emotional
  6211.      condition changes  in 23  days per cycle. Each cycle is 2*PI long.
  6212.      PC for physical condition and IC for intellectual condition.
  6213. E10: A FOR loop to draw your graph. I  just assume  each month  have 31
  6214.      days. You may want to change 31 to its actual days.
  6215. E11~E13:  Simple calculation for your conditions.
  6216. E14: Plot emotional  condition with  marker 1,  physical with marker 2,
  6217.      and intellectual with marker 3
  6218. E16~E17: Plot the x-axis and y-axis
  6219. E18: Draw marks on x-axis
  6220. E19: Draw marks on y-axis
  6221. E20: Draw label on x-axis. It is integer.
  6222. E21: Draw label on y-axis. It is real with 1 decimal place.
  6223. E22: Plot your name on screen. (B1 holds your name)
  6224. E23~E25: Plot texts showing the meaning for each marker.
  6225. E26: Legal way to return to your current window
  6226. E27: END program.
  6227.  
  6228.  
  6229.  
  6230.  
  6231.  
  6232.  
  6233.  
  6234.  
  6235.  
  6236.  
  6237.  
  6238.  
  6239.  
  6240.  
  6241.  
  6242.  
  6243.  
  6244.  
  6245.  
  6246.  
  6247.  
  6248.  
  6249.  
  6250.  
  6251.  
  6252.  
  6253.  
  6254.  
  6255.  
  6256.  
  6257.  
  6258.  
  6259.  
  6260.  
  6261.                                 Page 81
  6262.  
  6263.  
  6264.  
  6265.  
  6266.  
  6267.  
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  SHEET User manual             By Chor-ming Lung                October 9,
  6273. 1988
  6274.  
  6275.                            Calendar program
  6276.                            ________________
  6277.  
  6278.           The file name of  this  program  is  "CAL.SHT".  This program
  6279.      generates a month calendar and leaves some spaces for your monthly
  6280.      activity. Here is the listing. To run it, enter "@run q1"
  6281.  
  6282. Q1     :!MON=10:YR=88:IBM= FALSE
  6283. Q2     :!WEEKDAY=( DATE(MON,1,YR)+1) MOD 7
  6284. Q3     :! IF (MON<12) THEN TDAY= DATE(MON+1,1,YR)- DATE(MON,1,YR): ELSE
  6285. TDAY= DATE(1,1,YR+1)- DATE(MON,1,YR)
  6286. Q4     :! IF IBM THEN  GOSUB Q34: ELSE  GOSUB Q42
  6287. Q5     :! ERASE A1..O64
  6288. Q6     :!B3$="^Sun":D3$="^Mon":F3$="^Tue":H3$="^Wed"
  6289. Q7     :!J3$="^Thu":L3$="^Fri":N3$="^Sat"
  6290. Q8     :!LINES=(WEEKDAY+TDAY)/7
  6291. Q9     :!LINES= INT(LINES)+( FRAC(LINES)>0)
  6292. Q10    :!WIDTH=60/LINES
  6293. Q11    :! FOR I=0 TO 62
  6294. Q12    :! FOR J=0 TO 14 STEP 2:A2[J,I]$= CHR$(VERT): NEXT J
  6295. Q13    :! NEXT I
  6296. Q14    :! FOR I=0 TO 12
  6297. Q15      :! IF  (I MOD  2)=0 THEN B2[I,0]$="\"+ CHR$(HOR):B4[I,0]$="\"+
  6298. CHR$(HOR): ELSE B2[I,0]$="\"+ CHR$(MDOWN):B4[I,0]$="\"+ CHR$(PLUS)
  6299. Q16    :! NEXT I
  6300. Q17        :!A2$=  CHR$(TLEFT):O2$=  CHR$(TRIGHT):A4$= CHR$(PLEFT):O4$=
  6301. CHR$(PRIGHT)
  6302. Q18    :! FOR I=1 TO LINES
  6303. Q19    :!L=I*WIDTH: COPY A4..O4,A4[0,L]
  6304. Q20    :! NEXT I
  6305. Q21    :! FOR J=0 TO 12 STEP 2:C64[J,0]$= CHR$(MUP): NEXT J
  6306. Q22    :!A64$= CHR$(BLEFT):O64$= CHR$(BRIGHT)
  6307. Q23    :!L=1:J=1:M=WEEKDAY*2
  6308. Q24    :! FOR I=WEEKDAY TO WEEKDAY+TDAY+1
  6309. Q25    :! IF (I MOD 7)=0 THEN L=L+WIDTH:M=0
  6310. Q26    :!B4[M,L]=J:J=J+1:M=M+2: IF J=TDAY THEN I=42
  6311. Q27    :! NEXT I
  6312. Q28    :! SAVE  SCREEN : REDIRECT  TO "prn:"
  6313. Q29    :! PRINT  SPACE$((80- LEN(V1$))/2);V1$: PRINT
  6314. Q30    :! PRINT_BLOCK A2..O64,4,76
  6315. Q31    :! WAIT 2: RESTORE  SCREEN
  6316. Q32    :! END
  6317. Q34    :!MDOWN=194:MUP=193
  6318. Q35    :!PLEFT=195:PRIGHT=180
  6319. Q36    :!PLUS=197:VERT=179:HOR=196
  6320. Q37    :!TLEFT=218:TRIGHT=191
  6321. Q38    :!BLEFT=192:BRIGHT=217
  6322. Q39    :! RETURN
  6323. Q42    :!MDOWN=45:MUP=45
  6324. Q43    :!PLEFT=124:PRIGHT=124
  6325. Q44    :!PLUS=43:VERT=124:HOR=45
  6326. Q45    :!TLEFT=43:TRIGHT=43
  6327. Q46    :!BLEFT=43:BRIGHT=43
  6328. Q47    :! RETURN
  6329.  
  6330.  
  6331.                                 Page 82
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340.  
  6341.  
  6342.  SHEET User manual             By Chor-ming Lung                October 9,
  6343. 1988
  6344.  
  6345. Explanation:
  6346. Explanation
  6347. Q1   Set the  month and  year we interest about in the variable mon and
  6348.      yr. You cannot use month and year for  the variable  names because
  6349.      they are names for built-in functions. IBM is TRUE if your printer
  6350.      can print the IBM graphic characters. If you change the  month and
  6351.      year in  cell Q1,  please change the string in cell V1 at the same
  6352.      time.
  6353. Q2:  WEEKDAY stores the weekday of the first day of the  month. WEEKDAY
  6354.      is 0 if it is Sunday and 1 for Monday and so on.
  6355. Q3:  TDAY is the total number of days in the specified month. It can be
  6356.      calculated easily by subtracting the first date of one month after
  6357.      mon from the first date of mon.
  6358. Q4:  Initializes some constants depend on whether IBM is TRUE or FALSE.
  6359. Q5:  Erase cells from A1 through O64
  6360. Q6:  Row 2 and 4 holds the frame for the title of weekdays. Row 3 holds
  6361.      the title.
  6362. Q8:  Normally, we need 4, 5 or 6 lines to hold  a monthly  calendar. To
  6363.      calculate how many lines are need for our current month, we can do
  6364.      it by adding the WEEKDAY and TDAY and divides it by 7.
  6365. Q9:  This is a little  bit  tricky.  FRAC  is  a  function  returns the
  6366.      fractional part  of a numerical value. In this case, LINES from Q8
  6367.      is equal to 5.285714. FRAC(LINES) returns 0.285714. It  is greater
  6368.      than zero.  TRUE is  1 and  0 is  FALSE. (FRAC(LINES)>0) returns a
  6369.      value of 1 and the INT(LINES) returns a value of  5. So  we need 6
  6370.      lines to hold our current monthly calendar.
  6371. Q10: The width  for each line is 60/LINES. Since the value of LINES can
  6372.      be 4,5 or 6. So, width is an integer.
  6373. Q11~Q22 Fills the frame for  our  calendar.  TLEFT,  is  the  TOP left-
  6374.      corner, TRIGHT  is the TOP right-corner, BLEFT is the Bottom left-
  6375.      corner and BRIGHT is  the Bottom  right-corner. VER  is a vertical
  6376.      bar, HOR  is a  horizontal bar.  PLEFT is  a T character turns -90
  6377.      degree and PRIGHT is a T character turns 90 degrees. MDOWN is  a T
  6378.      character and  MUP is  a T  character turns  180 degrees. They are
  6379.      used to join lines in the edges. PLUS is a + character.
  6380. Q23~Q27 Fills the Date into the calendar.
  6381. Q28~Q31 prints the calendar to your printer.
  6382. Q32: You should always end your program with END.
  6383. Q34~Q39: Defines constants for IBM=TRUE
  6384. Q42~Q47: Defines constants for IBM=FALSE
  6385.  
  6386.  
  6387.  
  6388.  
  6389.  
  6390.  
  6391.  
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.  
  6400.  
  6401.                                 Page 83
  6402.  
  6403.  
  6404.  
  6405.  
  6406.  
  6407.  
  6408.  
  6409.  
  6410.  
  6411.  
  6412.  SHEET User manual             By Chor-ming Lung                October 9,
  6413. 1988
  6414.  
  6415.  
  6416.                                  Roots
  6417.                                  _____
  6418.  
  6419.  
  6420.      ROOTS.SHT is  a sample  program which  finds roots  for any single
  6421. variable functions.  There are some techniques which are not covered in
  6422. other sample programs. You should study it even you have no interest in
  6423. finding roots for a function.
  6424.  
  6425. B1    : !XMIN=-5:YMIN=-5:XMAX=5:YMAX=100:ST=0.1:ERR=0.000001
  6426. B2    : ! DEFINE F(X)=3*X*X-2
  6427. B3            :   !   IF      ALERT(2,"[0][Which   resolution  you  are
  6428. in?][Medium|High]")=2  THEN    WINDOW  0,0,20,639,399:  ELSE     WINDOW
  6429. 0,0,11,639,199
  6430. B4    : ! SCALE XMIN,YMIN,XMAX,YMAX
  6431. B5    : ! CLEAR
  6432. B6    : ! PLOT XMIN,F(XMIN)
  6433. B7    : ! FOR X=XMIN TO XMAX STEP ST
  6434. B8    : ! LINE_TO X,F(X)
  6435. B9    : ! NEXT X
  6436. B10   : ! LINE XMIN,0,XMAX,0: LINE 0,YMIN,0,YMAX
  6437. B11   : !X= ALERT(1,"[0][Can you see any|root in your graph?][Yes|No]")
  6438. B12    : ! IF X=2 THEN  MESSAGE "Change your minimum and|maximum values
  6439. and try again": EXITGRAPH
  6440. B13   : ! IF X=2 THEN  END
  6441. B14   : ! MESSAGE "Locate mouse  cursor|to the  left of  a|root in your
  6442. graph"
  6443. B15   : ! MOUSE_POS AX,AY
  6444. B16    :  ! MESSAGE "Locate mouse cursor|to the right of a|root in your
  6445. graph"
  6446. B17   : ! MOUSE_POS BX,BY
  6447. B18   : ! LOOP
  6448. B19   : !AY=F(AX):BY=F(BX)
  6449. B20   : ! EXIT  IF ( ABS(AY)<ERR OR  ABS(BY)<ERR)
  6450. B21   : !HALF=(AX+BX)/2:HY=F(HALF)
  6451. B22   : ! IF (AY*HY<0) THEN BX=HALF: ELSE AX=HALF
  6452. B23   : ! ENDLOOP
  6453. B24   : ! IF  ABS(AY)<ERR THEN A1=AX: ELSE A1=BX
  6454. B25   : ! EXITGRAPH
  6455. B26   : ! END
  6456.  
  6457.      For solving different functions, you should adjust B1, B2.
  6458.  
  6459. Explanations:
  6460. Explanations
  6461.  
  6462. B1:  min,ymin,xmax,ymax setup the scaling factors. ST is step value for
  6463.      plot the function. ERR is the error tolerance. If you want to have
  6464.      a more accurate result, you should make ERR smaller.
  6465. B2:  The function we are  trying  to  find  roots  for.  Remember, each
  6466.      function definition should have its own cell
  6467. B3:  Open  the  largest  window  on Medium or High resolution. Remember
  6468.      WINDOW 0 is the current window.  The rest  numbers are  the raster
  6469.      coordinate.
  6470. B4:  Set the scaling factors.
  6471. B5:  Clear our window
  6472.  
  6473.                                 Page 84
  6474.  
  6475.  
  6476.  
  6477.  
  6478.  
  6479.  
  6480.  
  6481.  
  6482.  
  6483.  
  6484.  SHEET User manual             By Chor-ming Lung                October 9,
  6485. 1988
  6486.  
  6487. B6:  Plot the first point
  6488. B7:  Plot the rest of the graph.
  6489. B10: Draw the x- and y-axes.
  6490. B11: A root  on a  graph is  the place where it hits the x-axis. If you
  6491.      see the curve hits the x-axis, you should answer Yes.
  6492. B12: If the curve does not hit x-axis, then  leave a  reminder for user
  6493.      to change  the plotting  range. If  you set up a large value for x
  6494.      range, and you still can't see the root, then the function defined
  6495.      may not have a root. You cannot use this program to find it.
  6496. B13: EXITGRAPH  command  is  not  working  quite well. It does not like
  6497.      anything following  it. I  still don't  know why.  The END command
  6498.      should follow  EXITGRAPH, but there is a bug which force us to end
  6499.      the program this way.
  6500. B14: If you see a root, you can use the mouse to locate the left handed
  6501.      side value  for the root. This message just reminds user to select
  6502.      the left handed side value for the root. You may need to hold your
  6503.      mouse a little longer that usual.
  6504. B15: User input the left handed side value by pointing the mouse cursor
  6505.      to the  left of  the point  that hits  the x-axis,  and click your
  6506.      mouse button. You can point to anywhere on the left handed side of
  6507.      the root.
  6508. B16~B17:We need the right handed  side  value.  The  program  should be
  6509.      stopped quite fast. If you see nothing happen for a long time, you
  6510.      should press the mouse button again.  If it  is still  waiting for
  6511.      mouse button, <Esc> key will not stop the program.
  6512. B18: A loop using bi-section method to find the root of a function.
  6513. B24: If we found the root, we put it in cell A1
  6514. B25: Normal exit
  6515. B26  End of the program.
  6516.  
  6517.  
  6518.  
  6519.  
  6520.  
  6521.  
  6522.  
  6523.  
  6524.  
  6525.  
  6526.  
  6527.  
  6528.  
  6529.  
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.