Notes on reading Pascal source code ----------------------------------- These are some notes to explain how Pascal source code is structured, and to give some tips on how to convert it to other languages (especially C or BASIC) A ready-compiled test program should be available: please run this in ST low resolution! Pascal Structure ---------------- Due to the way Pascal is compiled the structure may seem strange to those used to languages such as BASIC. The basic structure is: PROGRAM name of program; TYPE data structure declarations CONST constant declarations VAR variable declarations FUNCTION/PROCEDURE subprogram code BEGIN main program code END. This should be fairly familiar to anyone with experience of C. Other notes: 1) All variables and data structures must be declared unlike GFA or STOS. Then all subroutines are declared and described, including what must go in and out from the routine (ie. its parameters) and finally there is the main core of the program itself. Program cores and functions are all contained within BEGIN and END commands. 2) The number type "real" denotes any variable that does not necessarily hold an integer. "Integer" is the equivalent of a% in GFA or a normal variable in STOS. 3) In this example "records" should used for each point on the lattice - but to aid conversion to BASIC I have used a 3-dimensional array of numbers. It could also be replaced by 3 data arrays eg. DIM xgrad(20,20), ygrad(20,20), val(20,20). 4) Pascal functions may have their own local variables, and pass back one value to the main program. This is best converted by means of a DEF FN statement (especially in GFA - STOS will probably need a subroutine) 5) The code is designed for HighSpeed Pascal or Turbo Pascal on the PC (yuk!) so I've commented the lines that initialise Pascal-only graphics routines. These should be replaced by your own routines in other languages. 6) The semicolon is used to separate statements; just ignore them if they are missing (this depends on what Pascal deems a "statement" which is different from C or BASIC) 7) Other functions: "trunc" equivalates to "int" in BASIC (takes the integer part) and "mod" finds the modulus. Steve Tattersall s.j.tattersall@cms.salford.ac.uk