intro to PROCEDUREs, functions and var-parameters

This commit is contained in:
antranigv 2017-06-08 20:39:56 +04:00
parent 290ea11c03
commit f483b3630f
No known key found for this signature in database
GPG key ID: 60686B14DAB81456
6 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,10 @@
VOC = /opt/voc/bin/voc
all:
$(VOC) -m VarParam.Mod
clean:
rm *.c
rm *.h
rm *.o
rm *.sym

View file

@ -0,0 +1,22 @@
MODULE varparam;
IMPORT Out;
VAR
a, b : INTEGER;
PROCEDURE swapVals(VAR x, y : INTEGER);
VAR tmp : INTEGER;
BEGIN
tmp := x; x := y; y := tmp;
END swapVals;
BEGIN
a := 6; b := 9;
Out.String("initial "); Out.Ln;
Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln;
swapVals(a, b);
Out.String("after swap"); Out.Ln;
Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln;
END varparam.