home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED2.LZH / UNITS / STPASCAL.DOC < prev    next >
Text File  |  1991-03-26  |  6KB  |  194 lines

  1.  
  2.                           HighSpeed Pascal
  3.                           ----------------
  4.  
  5.    STPASCAL.DOC - information about the usage of the ST Pascal unit
  6.  
  7.  
  8. 1. Introduction
  9. ---------------
  10. The ST Pascal unit (STPASCAL.UNI) implements a large set of constants,
  11. variables, types, functions and procedures found in the ST Pascal
  12. libraries PASLIB, PASGEM and PASTRIX. They are included in the HighSpeed
  13. Pascal package for your benefit, so that you won't have to waste too
  14. much time rewriting your ST Pascal applications for the HighSpeed Pascal.
  15. We shall in the following show what a typical ST Pascal program rewrite
  16. implies. For a complete listing of the unit's interface section, please
  17. consult the on-line help.
  18.  
  19. NOTE : Although the greatest possible effort has been made to ensure
  20. that the unit operates exactly as the original ST Pascal libraries, we
  21. can not guarantee that all converted programs will behave exactly as
  22. they do with the ST Pascal. If you are experiencing trouble, please
  23. send us a note describing the problem - if possible with a listing too
  24. - so that we can update the unit.
  25.  
  26.  
  27. 2. How to rewrite an ST Pascal program
  28. --------------------------------------
  29. In order to rewrite an ST Pascal program two steps have to be
  30. performed:
  31.  
  32. 1. Correcting strictly compiler related issues
  33. 2. Removing the $I files and incorporate the STPASCAL unit
  34.  
  35.  
  36. 2.1. Compiler related changes
  37. -----------------------------
  38. The steps are :
  39.  
  40. 1. Rewrite Shl and Shr expressions :
  41.  
  42.    An ST Pascal statement like this :
  43.  
  44.           i := Shl(2,4)
  45.  
  46.    must be rewritten like this :
  47.  
  48.           i := 2 Shl 4
  49.  
  50.   or into :
  51.  
  52.           i := ST_Shl(2,4)
  53.  
  54. 2. Rewrite all LOOP..END statements
  55.  
  56. 3. Change compiler options where required; modules require quite a lot
  57.    of rewriting (splitting 'em up into INTERFACEs and IMPLEMENTATIONs
  58.    etc.)
  59.  
  60. 4. See what you can do with the special directives BIOS, XBIOS, GEMDOS
  61.    etc... Quite a few of 'em can be found in other HighSpeed Pascal units
  62.    such as the DOS unit.
  63.  
  64. 5. Change calls to IO_Check to the corresponding {$I+} and {$I-}
  65.    directives
  66.  
  67. 6. The ST Pascal implements a file system based on the original Wirth
  68.    philosophy of PUTting and GETting - from a system programmer's view
  69.    a quite logical way, but a bit more tricky to deal with when it
  70.    comes to formatted output etc. Therefore, HighSpeed Pascal implements
  71.    the nowadays most commonly used method of READing and WRITEing. The
  72.    actual code rewrite to perform isn't very difficult; it merely
  73.    involves this : All references to a file pointer (say, f^) will have
  74.    to be changed into a variable holding the file pointer's value.
  75.    After that, all PUTs must be changed into WRITEs of the previously
  76.    mentioned variable and all GETs will have to be changed into the
  77.    corresponding READs :
  78.  
  79.    ST Pascal :                      HighSpeed Pascal :
  80.    ---------------------------------------------------
  81.  
  82.    VAR f : FILE OF Integer;             VAR f : FILE OF Integer;
  83.                                             i : Integer;
  84.    ...                                  ...
  85.      Rewrite(f, 'JUNK.TMP');            Rewrite(f, 'JUNK.TMP');
  86.      f^ := 1234;                        i := 1234;
  87.      Put(f);  { write 1234 to file }    Write(f, i { or 1234 } );
  88.      Reset(f);                          Reset(f);
  89.      WriteLn(f^);                       Read(f, i);
  90.      Get(f);                            WriteLn(i);
  91.      Close(f);                          Close(f);
  92.      Erase(f);  { <-- note this --> }   Erase('JUNK.TMP');
  93.  
  94. 7. The ST Pascal ReadV and WriteV procedures do not exist as the Turbo
  95.    Pascal procedures Str and Val were inherited, so they require
  96.    rewriting too - but that's a really simple one :
  97.  
  98.    ST Pascal :                      HighSpeed Pascal :
  99.    ---------------------------------------------------
  100.  
  101.    VAR s : String;                      VAR s     : String;
  102.        r : Real;                            r     : Real;
  103.                                             dummy : Integer;
  104.    BEGIN                                BEGIN
  105.      s := '123.45';                       s := '123.45';
  106.      ReadV(s, r);                         Val(s, r, dummy);
  107.      r := 54.321;                         r := 54.321;
  108.      WriteV(s, r);                        Str(r, s);
  109.  
  110.    To sum it up : Changing ReadV into Val and adding a dummy parameter
  111.    and changing WriteV into Str and swapping parameters.
  112.  
  113. 6. Try to compile and fix whatever else you come across (shouldn't be
  114.    much, though)
  115.  
  116.  
  117. 2.2. Incorporating the STPASCAL unit
  118. ------------------------------------
  119. First of all, you have to remove the following $Include directives (if
  120. they exist) :
  121.  
  122. {$I GEMCONST}
  123. {$I GEMTYPE}
  124. {$I GEMSUBS}
  125. {$I TRIXCONS}
  126. {$I TRIXTYPE}
  127. {$I TRIXSUBS}
  128.  
  129. Then, after the PROGRAM heading, you include the following line :
  130.  
  131. USES STPascal;
  132.  
  133. A final warning is in order : Not everything in PASTRIX is implemented,
  134. so you'll perhaps need to declare a bit of things on your own.
  135.  
  136. As a final example, we give the "before" and "after" header of a
  137. program :
  138.  
  139. Before :
  140. --------
  141.  
  142. PROGRAM MyProg;
  143.  
  144. CONST
  145.   {$I GEMCONST}
  146.   MyConst = 0;
  147.  
  148. TYPE
  149.   {$I GEMTYPE}
  150.   MyType  = (hello, good_bye);
  151.  
  152. {$I GEMSUBS}
  153. PROCEDURE MyProc;
  154. ...
  155.  
  156.  
  157. After :
  158. -------
  159.  
  160. PROGRAM MyProg;
  161.  
  162. USES STPascal;
  163.  
  164. CONST
  165.   MyConst = 0;
  166.  
  167. TYPE
  168.   MyType  = (hello, good_bye);
  169.  
  170. PROCEDURE MyProc;
  171. ...
  172.  
  173.  
  174. 3. Implementation notes
  175. -------------------------
  176.  
  177. The following restrictions exist in the current implementation :
  178.  
  179. * IO_Result return codes don't correspond to those documented in the ST
  180.   Pascal manual as the original function, together with IO_Check, are
  181.   tightly interfaced with the ST Pascal runtime section. Instead,
  182.   IO_Result returns exactly the same error codes as the HighSpeed Pascal
  183.   IOResult.
  184. * There is a limitation on the number of menus a program can have. In
  185.   total, 20 menus with 20 titles each are available. If you create more
  186.   of either, the program will abort.
  187.  
  188.  
  189. 3.1. New since version 1.0
  190. --------------------------
  191.  
  192. Put_Screen, Get_Screen, Read_Screen, Write_Screen, ST_Shl, ST_Shr and
  193. associated types, constants etc.
  194.