Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
MODULE Arithmetic;
|
||||
IMPORT CPmain,Console,RTS;
|
||||
|
||||
VAR
|
||||
x,y : INTEGER;
|
||||
arg : ARRAY 128 OF CHAR;
|
||||
status : BOOLEAN;
|
||||
|
||||
|
||||
PROCEDURE Error(IN str : ARRAY OF CHAR);
|
||||
BEGIN
|
||||
Console.WriteString(str);Console.WriteLn;
|
||||
HALT(1)
|
||||
END Error;
|
||||
|
||||
|
||||
BEGIN
|
||||
IF CPmain.ArgNumber() < 2 THEN Error("Give me two integers!") END;
|
||||
CPmain.GetArg(0,arg); RTS.StrToInt(arg,x,status);
|
||||
IF ~status THEN Error("Can't convert '"+arg+"' to Integer") END;
|
||||
CPmain.GetArg(1,arg); RTS.StrToInt(arg,y,status);
|
||||
IF ~status THEN Error("Can't convert '"+arg+"' to Integer") END;
|
||||
Console.WriteString("x + y >");Console.WriteInt(x + y,6);Console.WriteLn;
|
||||
Console.WriteString("x - y >");Console.WriteInt(x - y,6);Console.WriteLn;
|
||||
Console.WriteString("x * y >");Console.WriteInt(x * y,6);Console.WriteLn;
|
||||
Console.WriteString("x / y >");Console.WriteInt(x DIV y,6);Console.WriteLn;
|
||||
Console.WriteString("x MOD y >");Console.WriteInt(x MOD y,6);Console.WriteLn;
|
||||
END Arithmetic.
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
MODULE Arithmetic;
|
||||
IMPORT StdLog,DevCommanders,TextMappers;
|
||||
|
||||
PROCEDURE DoArithmetic(x,y: INTEGER);
|
||||
BEGIN
|
||||
StdLog.String("x + y >");StdLog.Int(x + y);StdLog.Ln;
|
||||
StdLog.String("x - y >");StdLog.Int(x - y);StdLog.Ln;
|
||||
StdLog.String("x * y >");StdLog.Int(x * y);StdLog.Ln;
|
||||
StdLog.String("x / y >");StdLog.Int(x DIV y);StdLog.Ln;
|
||||
StdLog.String("x MOD y >");StdLog.Int(x MOD y);StdLog.Ln;
|
||||
END DoArithmetic;
|
||||
|
||||
PROCEDURE Go*;
|
||||
VAR
|
||||
params: DevCommanders.Par;
|
||||
s: TextMappers.Scanner;
|
||||
p : ARRAY 2 OF INTEGER;
|
||||
current: INTEGER;
|
||||
BEGIN
|
||||
current := 0;
|
||||
params := DevCommanders.par;
|
||||
s.ConnectTo(params.text);
|
||||
s.SetPos(params.beg);
|
||||
s.Scan;
|
||||
WHILE(~s.rider.eot) DO
|
||||
IF (s.type = TextMappers.int) THEN
|
||||
p[current] := s.int; INC(current);
|
||||
END;
|
||||
s.Scan;
|
||||
END;
|
||||
IF current = 2 THEN DoArithmetic(p[0],p[1]) END;
|
||||
END Go;
|
||||
END Arithmetic.
|
||||
Loading…
Add table
Add a link
Reference in a new issue