DUPNAMES is a program that appears on page 52 of the book "Pascal Primer" by David Fox and Mitchell Waite. It demonstrates the difference of global and local variables. The program has been ported from UCSD Pascal for the Apple II to the Atari Pascal Language System for the Atari 8-bit computers.
I'm using the Altirra 3.10 Atari 8-bit emulator. I'm editing the code using AtariWriter 80 (AtariWriter80_b_XE-working.ATR). Note that if you use AtariWriter to edited your source code, you will need to use CONTROL+S to save your file in straight ASCII rather than the SAVE Menu option which includes some AtariWriter header info. I'm compiling, linking, running the program using the Atari Pascal Language System.
To port it, the following changes where made:
- Screen cleared with WRITE(CHR(125)) instead of PAGE(OUTPUT)
- ClearScreen procedure name was changed to ClrScrn do to a naming conflict
The link command looks like:
LINKER V1.0
*D2:DUPNAMES,PASLIB/S
When you run the program, it looks like:
The program demonstrates that global variable Sum is different than the local variable Sum. In the Add procedure, the local variable Sum takes precedence over the global variable Sum.
No comments:
Post a Comment