DEADSOFTWARE

DswHostProcs: fix argument passing again
[cpc.git] / src / generic / Dsw / Mod / EchoMain.cp
1 MODULE DswEchoMain;
3 (* encoding converter test *)
5 IMPORT Kernel, HostLang, Console, Strings;
7 PROCEDURE Init;
8 CONST maxBuf = 256;
9 VAR i, j, res: INTEGER; p, x: ARRAY maxBuf OF CHAR;
10 BEGIN
11 IF Kernel.trapCount # 0 THEN Kernel.Quit(1) END;
12 i := 1;
13 WHILE i < Kernel.argc DO
14 HostLang.HostToString(Kernel.argv[i]$, p, TRUE, res);
15 Console.WriteStr(p);
16 IF res # 0 THEN
17 Console.WriteLn;
18 Console.WriteStr("Error: "); Console.WriteChar(CHR(ORD("0") + res MOD 10));
19 Console.WriteLn;
20 Kernel.Quit(1)
21 END;
22 INC(i)
23 END;
24 IF i > 1 THEN Console.WriteLn END;
26 i := 1;
27 WHILE i < Kernel.argc DO
28 HostLang.HostToString(Kernel.argv[i]$, p, TRUE, res);
29 j := 0;
30 WHILE p[j] # 0X DO
31 Strings.IntToStringForm(ORD(p[j]), 16, 4, "0", FALSE, x);
32 Console.WriteStr(x);
33 Console.WriteStr(" ");
34 INC(j)
35 END;
36 INC(i)
37 END;
38 IF i > 1 THEN Console.WriteLn END;
39 Kernel.Quit(0)
40 END Init;
42 BEGIN
43 Kernel.Start(Init)
44 END DswEchoMain.