home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG028.ARK / ALGINTRO.TXT < prev    next >
Text File  |  1984-04-29  |  8KB  |  271 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                            I.  ALGOL-M LANGUAGE DESCRIPTION
  10.  
  11.  
  12.  
  13.  
  14.              A.  FEATURES OF THE ALGOL-M LANGUAGE
  15.  
  16.  
  17.                  Although ALGOL-M was modeled after ALGOL-60, no  attempt
  18.  
  19.              was  made  to make it a formal subset of ALGOL-60.  This was
  20.  
  21.              done intentionally in order  to  provide  a  language  which
  22.  
  23.              would   be   best   suited  to  the  needs  of  applications
  24.  
  25.              programmers using microcomputer systems.  However, the basic
  26.  
  27.              structure  of ALGOL-M is similar enough to ALGOL-60 to allow
  28.  
  29.              simple conversion of  programs  from  one  language  to  the
  30.  
  31.              other.   This  was considered particularly important in view
  32.  
  33.              of the  fact  that  the  standard  publication  language  is
  34.  
  35.              ALGOL-60.    Therefore,  there  exists  a  large  source  of
  36.  
  37.              applications programs and library procedures  which  can  be
  38.  
  39.              simply converted to execute under ALGOL-M.
  40.  
  41.  
  42.                  1.  Type Declarations
  43.  
  44.                      ALGOL-M supports three types of variables: integers,
  45.  
  46.              decimals,   and  strings.  Integers may be any value between
  47.  
  48.              -16,383 and +16,383.  Decimals may be declared with up to 18
  49.  
  50.              digits  of  precision and strings may be declared as long as
  51.  
  52.              255 characters.  The default precision for decimals  is  ten
  53.  
  54.              digits and the default length for strings is ten characters.
  55.  
  56.              Decimal and string variable lengths may be integer variables
  57.  
  58.              which can be assigned actual values at run-time.
  59.  
  60.                      Another form of declaration in ALGOL-M is the  array
  61.  
  62.  
  63.                                           1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.              declaration.  Arrays may  have up  to  255  dimensions  with
  70.  
  71.              each dimension ranging from       0 to +16,383.  The maximum
  72.  
  73.              8080  microprocesor  address  space  of  63k  bytes   limits
  74.  
  75.              practical   array   sizes  to  something  smaller  than  the
  76.  
  77.              maximum.  Dimension bounds may be integer variables with the
  78.  
  79.              actual  values  assigned at run-time.  Arrays may be of type
  80.  
  81.              integer, decimal or string.
  82.  
  83.  
  84.                  2.  Arithmetic Processing
  85.  
  86.                      Integer and  binary  coded  decimal  arithmetic  are
  87.  
  88.              supported  under  ALGOL-M.   Integers may be used in decimal
  89.  
  90.              expressions and will be converted to decimals  at  run-time.
  91.  
  92.              The  integer  and  decimal  comparisons  of  less-than  (<),
  93.  
  94.              greater-than (>), equal-to  (=),  not-equal-to  (<>),  less-
  95.  
  96.              than-or-equal-to (<=), and greater-than-or-equal-to (>=) are
  97.  
  98.              provided.  Additionally, the logical operators AND,  OR  and
  99.  
  100.              NOT are available.
  101.  
  102.  
  103.                  3.  Control Structures
  104.  
  105.                      ALGOL-M control structures consist  of  BEGIN,  END,
  106.  
  107.              FOR, IF THEN, IF THEN ELSE, WHILE, CASE and GOTO constructs.
  108.  
  109.              Function and  procedure  calls  are  also  used  as  control
  110.  
  111.              structures.   ALGOL-M  is  a block stuctured language with a
  112.  
  113.              block normally bracketed by a BEGIN and an END.  Blocks  may
  114.  
  115.              be  nested  within  other  blocks to nine levels.  Variables
  116.  
  117.              which are declared within a block  can  only  be  referenced
  118.  
  119.              within that block or a block nested within that block.  Once
  120.  
  121.              program control proceeds outside  of  a  block  in  which  a
  122.  
  123.              variable   has  been  declared,  the  variable  may  not  be
  124.  
  125.  
  126.                                           2
  127.  
  128.  
  129.  
  130.  
  131.  
  132.              referenced and, in fact, run-time  storage  space  for  that
  133.  
  134.              variable no longer exists.
  135.  
  136.                      Functions, when called, return an  integer,  decimal
  137.  
  138.              or  string  value  depending  on  the  type of the function.
  139.  
  140.              Procedures  do  not  return  a  value  when  called.    Both
  141.  
  142.              functions  and  procedures  may have zero or more parameters
  143.  
  144.              which are call by value and both may be called recursively.
  145.  
  146.  
  147.                  3.  Input/Output
  148.  
  149.                      The ALGOL-M WRITE statement  causes  output  to  the
  150.  
  151.              console on a new line.  The desired output is specified in a
  152.  
  153.              write  list  which  is  enclosed  in  parentheses.    String
  154.  
  155.              constants  may be used in a write list and are characterized
  156.  
  157.              by being enclosed in quotation marks.   Any  combination  of
  158.  
  159.              integer,  decimal  and  string  variables or expressions may
  160.  
  161.              also be used in a write list.  A WRITEON statement  is  also
  162.  
  163.              available  which  is  essentially  the  same  as  the  WRITE
  164.  
  165.              statement except that output continues on the same  line  as
  166.  
  167.              the output from a previous WRITE or WRITEON statement.  When
  168.  
  169.              a total of 80 characters have been written to the console, a
  170.  
  171.              new line is started automatically.  A TAB option may also be
  172.  
  173.              used in the write list which causes the  following  item  in
  174.  
  175.              the  write  list  to  be  spaced  to the right by a specifed
  176.  
  177.              amount.
  178.  
  179.                      Console input is accomplished by the READ  statement
  180.  
  181.              followed  by  a  read  list  of  any combination of integer,
  182.  
  183.              decimal and string variables enclosed  in  parentheses.   If
  184.  
  185.              embedded  blanks  are  desired  in  the  input  for a string
  186.  
  187.  
  188.  
  189.                                           3
  190.  
  191.  
  192.  
  193.  
  194.  
  195.              variable, the console input must be  enclosed  in  quotation
  196.  
  197.              marks.   A  READ  statement will result in a halt in program
  198.  
  199.              execution at run-time until the input values  are  typed  at
  200.  
  201.              the  console  and  a carriage return is sent.  If the values
  202.  
  203.              typed at the console match the read list in number and type,
  204.  
  205.              program  execution  continues.   If an error as to number or
  206.  
  207.              type of variables from the console occurs, program execution
  208.  
  209.              is again halted until values are re-entered on the console.
  210.  
  211.  
  212.                  5.  Disk Access
  213.  
  214.                      ALGOL-M programs may read data from,  or write  data
  215.  
  216.              to,   one  or more disk files which may be located on one or
  217.  
  218.              more disk drives.  When file input  or  output  is  desired,
  219.  
  220.              the  appropriate  READ  or  WRITE  statement  is modified by
  221.  
  222.              placing a filename  identifier  immediately  after  READ  or
  223.  
  224.              WRITE.   The  actual name of the file may be assigned to the
  225.  
  226.              file name identifier when the program is written or  it  may
  227.  
  228.              be assigned at run-time.  Various disk drives are referenced
  229.  
  230.              by the letters  A  through  Z.   A  specific  drive  may  be
  231.  
  232.              specified by prefixing the actual file name with the desired
  233.  
  234.              drive letter followed by a colon.  Additionally,  if  random
  235.  
  236.              file  access  is  desired,  the  file name identifier may be
  237.  
  238.              followed by a comma and an integer constant or variable.
  239.  
  240.              This integer value specifies the record within the file which 
  241.  
  242.              is to be used for input/output.
  243.  
  244.  
  245.                      Prior to the use of a file name identifier in a READ
  246.  
  247.              or  WRITE statement, the file name identifier must appear in
  248.  
  249.              a file declaration statement.  The file name identifier  can
  250.  
  251.  
  252.  
  253.                                           4
  254.  
  255.  
  256.  
  257.  
  258.  
  259.              only be referenced within the same block (or a lower  block)
  260.  
  261.              as  the  file  declaration.   Files  are normally treated as
  262.  
  263.              unblocked sequential files.  However, if blocked  files  are
  264.  
  265.              desired,  the  record  length may optionally be specified in
  266.  
  267.              brackets after the  file  name  identifier  in  the  file
  268.  
  269.              declaration statement.
  270.  
  271.