Pascal Notes

In ancient times when computers were starting to be used by engineers and scientists, two popular languages used for this were Fortran and Algol. When C and Java, etc., were developed they generally used some of the syntax style of Fortran, whereas Pascal, developed by Prof. Wirth, used the style of Algol. When I started programming I used Fortran, but I switched to Pascal in 1984, because (a) someone hired me to use Pascal, and (b) I could get a complete Turbo Pascal compiler for my own little computer for $50, whereas other languages cost hundreds and were slower and harder to use. Now from the beginning Turbo Pascal had rather slow real-number calculations, so I programmed critical parts of DMSolver in assembler using the X87 instructions (which are 32-bit) and these are still there.

By 1988 or so Turbo Pascal had become more flexible in that parts of a program could be put in separate files called "Units" which could be linked together (using its own very logical linker), and in about 1995 Delphi was created which enabled the Pascal programmer to create graphical user interfaces for Windows 95, using its own set of units which interfaced with Windows. Free Pascal development was started in Europe in about 2003 and after some false starts and a "coming back to life" the Lazarus-ide eventually came along resembling Delphi but able to be obtained in Windows, Linux, and Apple Mac versions.

I will make a few remarks about Pascal vs other languages:

Pascal code is case independent in contrast to c/c++ which are not.

Your DMSolver code is automatically placed in the proper place in Unit DMSUser by the DMSolver system, and you do not have to know anything about units unless you use the "add-in" units which are not part of basic DMSolver (or if you want to write your own units).

A "subroutine" in Fortran or Basic is called called a "procedure" in Pascal. Functions have the same name in all languages. For solving simultaneous systems DMSolver language needs some special procedures called "Mproc" (Module procedure) and "Xproc" (procedure which computes one or more simultaneous "X" variables) as well as regular procedures (functions can be used too if you wish). DMSolver gives you a "template" file showing you where various things go.

The variables between parentheses in a procedure in Pascal are called "parameters" as opposed to some other languages which call them "arguments". In Pascal calls they may either be passed "by value" (in which case you can make them constants if you want, and no result is passed back at the end of the procedure) or passed "by reference" in which case the resulting value is passed back to the calling program code similar to traditional Fortran. To get "by reference" in Pascal you simply prefix the parameter name with "VAR" as in variable a: "var a:double;" for an 8-byte real variable value passed in and then back out in a call. If there is no "var" before the name ("a:double") an 8-byte real is passed in by value and nothing is passed out. For DMSolver Xprocs we pass the input simultaneous variables into the procedure using VARIN instead of VAR and the computed output is passed out using VAROT instead of VAR. Simultaneous variables in DMSolver are a special type XVR although within Xprocs you treat them like 8-byte reals.

"Structures" in c/c++ are called "Records" in Pascal.

A Pascal procedure or function enforces an orderly arrangement compared with c/c++: first there is the heading with parameters, then you may have one or more parts starting with TYPE defining Record and Array types. Mixed with these you can have CONST and VAR parts defining constants and variables to be used within the procedure/function. Then at last there is begin...end; containing all of the executable statements and no TYPE, CONST, VAR definitions whatsoever. begin....end is the equivalent of {....} in c/c++.

With Pascal you can have TYPE, CONST, or VAR definition parts entirely outside procedures and functions. These are global to the unit.

The first thing you have to remember about Pascal and DMSolver is that every type, procedure, function, or variable has to be defined first before it is used.

In Pascal semicolons are used to separate executable statements whereas in c/c++ there is a different usage, apparently to end statements or parts of statements. The Pascal compiler will keep flagging excess c/c++ semicolons until the correct usage is obtained.

Of course global types, constants, and variables can be shared between units. I don't want to complicate this discussion more, but there are standard types, variables, functions, and procedures which are provided to the DMSolver user. They are all defined in the proprietary Unit DMSPROCS and listed in the Programmers' Manual pdf which includes the add-ins. But you also get a file DMSdoc.html which contains introductory material, explains the various menus, source code basics, etc., with links from a table of contents to topics.

For an elementary introduction to Pascal, see the website which seems to have more annoying advertizements than formerly.