Listing: 1 (*======================================================== 2 == JPI-TopSpeed Modula-2 V2 == 3 == demo program: == 4 == == 5 == Simple RS232 Demo showing rs module == 6 == == 7 ========================================================*) 8 MODULE RsDemo; 9 (*======*) 10 11 IMPORT Window,rs,IO,Str,Lib; 12 13 TYPE ConnectType = RECORD 14 ConnectStr : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 15 NoCon1Str : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 16 NoCon2Str : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 17 NoCon3Str : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 18 NoCon4Str : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 19 NoCon5Str : ARRAY [0..15] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 20 END; ***** ^ not supported yet 21 22 23 CONST PortNr = 1; BaudRate = 1200; 24 WT = Window.WinDef ( 0,0, Window.ScreenWidth-1,23, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 25 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 26 Window.SingleFrame,Window.White,Window.Black ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 27 28 WT2 = Window.WinDef ( 0,0, 50,2, ***** ^ not supported yet ***** ^ not supported yet 29 Window.White,Window.Black,TRUE,TRUE,FALSE,TRUE, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 30 Window.SingleFrame,Window.White,Window.Black ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 31 32 HangupStr = '~~~~+++~~~AT H0!'; ***** ^ not supported yet 33 34 InitString= 'AT E1 S7=60 S0=0 V1 X1 !~~AT D '; ***** ^ not supported yet 35 36 Connect = ConnectType('CONNECT','NO CARRIER','BUSY','NO DIAL TONE', ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 37 'NO ANSWER',''); ***** ^ not supported yet ***** ^ not supported yet 38 39 40 VAR W,W2 : Window.WinType; ***** ^ not supported yet 41 42 PROCEDURE SendModemContr( str : ARRAY OF CHAR ); ***** ^ not supported yet 43 VAR i : CARDINAL; 44 BEGIN 45 FOR i := 0 TO Str.Length(str)-1 DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ FOR needs integer variable and bounds 46 IF str[i]='~' THEN ***** ^ not supported yet ***** ^ not supported yet 47 Lib.Delay(500); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 48 ELSIF str[i]='!' THEN ***** ^ not supported yet ***** ^ not supported yet 49 rs.Send( CHR(13),1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 50 ELSIF str[i]='`' THEN ***** ^ not supported yet ***** ^ not supported yet 51 rs.Break( 500 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 52 ELSE 53 rs.Send( str[i],1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 54 Lib.Delay(100); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 55 END; 56 END; 57 END SendModemContr; ***** ^ not supported yet 58 59 60 61 PROCEDURE HangUp; 62 BEGIN 63 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 64 IO.WrStr('Hanging up please wait'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 65 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 66 SendModemContr( HangupStr ); ***** ^ not supported yet ***** ^ not supported yet 67 IO.WrStr('ok'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 68 END HangUp; ***** ^ not supported yet 69 70 PROCEDURE DoConnect(ns:ARRAY OF CHAR):BOOLEAN; ***** ^ not supported yet 71 VAR str : ARRAY[0..100] OF CHAR; p : CARDINAL; c : CHAR; ***** ^ not supported yet ***** ^ not supported yet 72 BEGIN 73 IO.WrStr('Dialing'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 74 SendModemContr( InitString ); ***** ^ not supported yet ***** ^ not supported yet 75 SendModemContr( ns ); ***** ^ not supported yet ***** ^ not supported yet 76 SendModemContr( '!' ); ***** ^ not supported yet ***** ^ not supported yet 77 p :=0; 78 LOOP 79 IF rs.RxCount()#0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 80 rs.Receive(str[p],1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 81 IF str[p]=CHR(13) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 82 str[p] := 0C; ***** ^ not supported yet ***** ^ not supported yet 83 p := 0; 84 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 85 IO.WrStr(str); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 86 IF Str.Pos(str,Connect.ConnectStr)#MAX(CARDINAL) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 87 RETURN TRUE; 88 ELSIF (Str.Pos(str,Connect.NoCon1Str)#MAX(CARDINAL)) AND (Connect.NoCon1Str[0]#0C) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 89 (Str.Pos(str,Connect.NoCon2Str)#MAX(CARDINAL)) AND (Connect.NoCon2Str[0]#0C) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 90 (Str.Pos(str,Connect.NoCon3Str)#MAX(CARDINAL)) AND (Connect.NoCon3Str[0]#0C) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 91 (Str.Pos(str,Connect.NoCon4Str)#MAX(CARDINAL)) AND (Connect.NoCon4Str[0]#0C) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 92 (Str.Pos(str,Connect.NoCon5Str)#MAX(CARDINAL)) AND (Connect.NoCon5Str[0]#0C) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 93 Lib.Delay(1000); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 94 RETURN FALSE; 95 END; 96 ELSE 97 p := p+1; 98 END; 99 END; 100 END; 101 END DoConnect; ***** ^ not supported yet 102 103 104 VAR c : CHAR; 105 ns : ARRAY[0..29] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 106 BEGIN 107 rs.Install(PortNr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 108 rs.Init( BaudRate,8,rs.None,TRUE,FALSE ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 109 W2 := Window.Open(WT2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 110 111 IO.WrStr('Number to dial: '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 112 ns := ''; ***** ^ not supported yet ***** ^ incompatible assignment 113 Window.InputStr(ns); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 114 IO.WrLn; ***** ^ not supported yet ***** ^ not supported yet 115 IF NOT DoConnect(ns) THEN ***** ^ not supported yet ***** ^ not supported yet 116 IO.WrStr('No connection'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 117 HangUp; ***** ^ not supported yet 118 HALT; ***** ^ undeclared identifier 119 END; 120 Window.Close(W2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 121 Window.GotoXY(1,25);IO.WrStr('Press F2 To Hang-up and exit program'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 122 W := Window.Open(WT); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 123 LOOP 124 IF IO.KeyPressed() THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 125 c := IO.RdKey(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 126 127 (*Exit on F2*) 128 129 IF (c=0C) AND (CHR(60)=IO.RdKey()) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 130 HangUp; ***** ^ not supported yet 131 EXIT 132 END; 133 WHILE rs.TxFree()=0 DO END; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 134 rs.Send( c,1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 135 END; 136 IF rs.RxCount()#0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 137 rs.Receive(c,1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 138 IF c>=CHR(80H) THEN DEC(c,80H) END; (* strip top bit *) ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 139 IO.WrChar(c); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 140 END; 141 END; 142 143 END RsDemo. 248 errors