home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / MAGGIE22.ARJ / magg22st.msa / GOODIES / TEXTURES.ZIP / TEXTURES / PASCAL.TXT next >
Text File  |  1997-01-06  |  2KB  |  74 lines

  1. Notes on reading Pascal source code
  2. -----------------------------------
  3.  
  4. These are some notes to explain  how Pascal source code is structured,
  5. and to give  some  tips  on  how  to  convert  it  to  other languages
  6. (especially C or BASIC)
  7.  
  8. A ready-compiled test program should be  available: please run this in
  9. ST low resolution!
  10.  
  11.  
  12. Pascal Structure
  13. ----------------
  14.  
  15. Due to the way Pascal is  compiled  the  structure may seem strange to
  16. those used to languages such as BASIC. The basic structure is:
  17.  
  18. PROGRAM name of program;
  19.  
  20. TYPE data structure declarations
  21.  
  22. CONST constant declarations
  23.  
  24. VAR variable declarations
  25.  
  26. FUNCTION/PROCEDURE subprogram code
  27.  
  28. BEGIN
  29.   main program code
  30. END.
  31.  
  32. This should be fairly familiar to  anyone  with experience of C. Other
  33. notes:
  34.  
  35. 1) All variables and data  structures  must  be declared unlike GFA or
  36. STOS. Then all subroutines are  declared and described, including what
  37. must go in and out from  the  routine (ie. its parameters) and finally
  38. there is the  main  core  of  the  program  itself.  Program cores and
  39. functions are all contained within BEGIN and END commands.
  40.  
  41. 2)  The  number  type  "real"  denotes  any  variable  that  does  not
  42. necessarily hold an integer. "Integer" is  the equivalent of a% in GFA
  43. or a normal variable in STOS.
  44.  
  45. 3) In this example "records" should used for each point on the lattice
  46. - but to aid conversion to BASIC  I have used a 3-dimensional array of
  47. numbers.  It  could  also  be  replaced  by  3  data  arrays  eg.  DIM
  48. xgrad(20,20), ygrad(20,20), val(20,20).
  49.  
  50. 4) Pascal functions may have their  own local variables, and pass back
  51. one value to the main program.  This  is  best converted by means of a
  52. DEF FN statement  (especially  in  GFA  -  STOS  will  probably need a
  53. subroutine)
  54.  
  55. 5) The code is designed for HighSpeed Pascal or Turbo Pascal on the PC
  56. (yuk!)  so  I've  commented  the  lines  that  initialise  Pascal-only
  57. graphics routines. These should be  replaced  by  your own routines in
  58. other languages.
  59.  
  60. 6) The semicolon is used to  separate  statements; just ignore them if
  61. they are missing (this  depends  on  what  Pascal  deems a "statement"
  62. which is different from C or BASIC)
  63.  
  64. 7) Other functions: "trunc" equivalates  to  "int" in BASIC (takes the
  65. integer part) and "mod" finds the modulus.
  66.  
  67.  
  68.  
  69.  
  70. Steve Tattersall
  71. s.j.tattersall@cms.salford.ac.uk
  72.  
  73.  
  74.