Article View: comp.lang.modula2
Article #577CODE! PLEASE!
From: Greg Vigneault
Date: Sun, 23 Aug 1992 11:09
Date: Sun, 23 Aug 1992 11:09
75 lines
3182 bytes
3182 bytes
In message-ID <16937.2A8EC01C@puddle.fidonet.org>
Subj: CODE! PLEASE!
Jai.Braatz@p1.f401.n208.z1.fidonet.org (Jai Braatz) writes...
JB> I've asked this here several times before, and I seem to never
> get a response. Is it my end? Can someone post small but
> complete pieces of Modula-2 code (like a hello world program
> and something that reads in numbers from a file or something)
> for me to look at as an example? PLEASE?
(*****************************************************************)
MODULE Hello;
FROM InOut IMPORT WriteCard, WriteLn, WriteString;
VAR loopc : CARDINAL;
anystring : ARRAY [0..16] OF CHAR;
BEGIN
anystring := " world!"; (* string assignment *)
FOR loopc := 1 TO 20 (* write the string 20 times *)
DO
WriteCard( loopc, 2 ); (* loop count *)
WriteString( " Hello," ); (* a string constant *)
WriteString( anystring ); (* a string variable *)
WriteLn; (* new line *)
END;
(* do it 20 more times, using WHILE *)
WHILE ( loopc > 0 )
DO
WriteCard( loopc, 2 ); (* loop count *)
WriteString( " Hello," ); (* a string constant *)
WriteString( anystring ); (* a string variable *)
WriteLn; (* new line *)
DEC( loopc ); (* count down *)
END;
END Hello.
(*****************************************************************)
(*****************************************************************)
MODULE ReadNumber;
FROM InOut IMPORT ReadCard, Write, WriteCard,
WriteLn, WriteString;
VAR aCard, loopc : CARDINAL;
BEGIN
loopc := 1;
REPEAT
WriteString( "Enter a number (99..199): " );
ReadCard( aCard );
WriteLn;
INC( loopc );
UNTIL (aCard >= 99) AND (aCard <= 199) OR (loopc > 5);
IF (loopc > 5) (* 5 unsuccessful tries? *)
THEN
WriteString( "You failed the 99..199 test!" );
Write( 7C ); (* beep *)
ELSE
WriteString( "Thanks, you entered " );
WriteCard( aCard, 1 );
WriteLn;
END;
END ReadNumber.
(*****************************************************************)
Greg_
Aug.23.1992.Toronto.Canada. greg.vigneault@bville.gts.org
Technical Details
Message-ID:
<80.492.uupcb@bville.gts.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!geac!r-node!bville!greg.vigneaultShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!geac!r-node!bville!greg.vigneault From: greg.vigneault@bville.gts.org (Greg Vigneault) Newsgroups: comp.lang.modula2 Subject: CODE! PLEASE! Message-ID: <80.492.uupcb@bville.gts.org> Date: 23 Aug 92 11:09:00 GMT Distribution: world Organization: Baudeville BBS - Toronto, Canada 416-283-0114/6059* *v32bis/HST Reply-To: greg.vigneault@bville.gts.org (Greg Vigneault) Lines: 75