| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi. Is anyone here using xds modula-2 on a linux platform. I have some questions to ask and I was hoping this would be a useful forum. There does not seem to be much traffic here anyway. |
|
#2
| |||
| |||
| MODULE xdsseqfileio; IMPORT SeqFile, STextIO, TextIO, SWholeIO, SIOResult, IOConsts; CONST flags = SeqFile.text + SeqFile.old; VAR out,in : SeqFile.ChanId; res : SeqFile.OpenResults; i,c : CARDINAL; str : ARRAY [0..255] OF CHAR; rdreslt : IOConsts.ReadResults; BEGIN SeqFile.OpenWrite(out,"seqfile.txt",flags,res); (* write flag is implied *) IF res = SeqFile.opened THEN FOR i:=0 TO 9 DO TextIO.WriteString(out,"Hello"); TextIO.WriteLn(out); END; SeqFile.Close(out); STextIO.WriteString(' Open and write successful.'); STextIO.WriteLn; ELSE STextIO.WriteString("Open error"); STextIO.WriteLn; c := ORD(res); STextIO.WriteString(' res Field result, as a cardinal, is: '); SWholeIO.WriteCard(c,10); STextIO.WriteLn; END; (* SeqFile.OpenRead(in,"seqfile.txt",flags,res); (* read flag is implied *) IF res = SeqFile.opened THEN STextIO.WriteString(' Open for Reading successful.'); STextIO.WriteLn; FOR i:=0 TO 9 DO TextIO.ReadString(in,str); TextIO.SkipLine(in); STextIO.WriteString(str); STextIO.WriteLn; END; SeqFile.Close(in); STextIO.WriteString(' Fixed Read finished.'); STextIO.WriteLn; ELSE STextIO.WriteString("Open error"); STextIO.WriteLn; c := ORD(res); STextIO.WriteString(' res Field result, as a cardinal, is: '); SWholeIO.WriteCard(c,10); STextIO.WriteLn; END; *) SeqFile.OpenRead(in,"seqfile.txt",flags,res); (* read flag is implied *) IF res = SeqFile.opened THEN STextIO.WriteString(' 2nd open for Reading successful.'); STextIO.WriteLn; c := 0; LOOP TextIO.ReadRestLine(in,str); STextIO.WriteString(str); STextIO.WriteLn; TextIO.SkipLine(in); rdreslt := SIOResult.ReadResult(); STextIO.WriteString(' SIOResult = '); i:= ORD(rdreslt); SWholeIO.WriteCard(i,2); STextIO.WriteLn; IF rdreslt <> IOConsts.allRight THEN EXIT END; INC(c); IF c>20 THEN EXIT END; STextIO.WriteString(str); STextIO.WriteLn; END; SeqFile.Close(in); STextIO.WriteString(' 2nd Read finished.'); STextIO.WriteLn; STextIO.WriteString(' number of lines is:'); SWholeIO.WriteCard(c,10); STextIO.WriteLn; ELSE STextIO.WriteString("2nd Open status error"); STextIO.WriteLn; c := ORD(res); STextIO.WriteString(' res Field result, as a cardinal, is: '); SWholeIO.WriteCard(c,10); STextIO.WriteLn; END; END xdsseqfileio. This is a simple test for me to understand how to do simple file i/o in Linux. I use stony brook for winxp, but I did not get their linux product before they left the market. The problem I am having is that the rdresult, variable to store SIOResult.ReadResult(), is not allRight after the first iteration. I know the file exists and can be read by the first loop that just reads 10 times. And I can display the file from the command prompt. I don't know what 2 do now? Thanks, Rob |
|
#3
| |||
| |||
| On 19 jan, 16:47, Rob Solomon <ag...@drrob1.com> wrote: > MODULE xdsseqfileio; > IMPORT *SeqFile, STextIO, TextIO, SWholeIO, SIOResult, IOConsts; > CONST flags = SeqFile.text + SeqFile.old; > VAR > * out,in *: SeqFile.ChanId; > * res * * : SeqFile.OpenResults; > * i,c * * : CARDINAL; > * str * * : ARRAY [0..255] OF CHAR; > * rdreslt : IOConsts.ReadResults; > BEGIN > * SeqFile.OpenWrite(out,"seqfile.txt",flags,res); *(* write flag is > implied *) > * IF res = SeqFile.opened THEN > * * FOR i:=0 TO 9 DO > * * * TextIO.WriteString(out,"Hello"); > * * * TextIO.WriteLn(out); > * * END; > * * SeqFile.Close(out); > * * STextIO.WriteString(' Open and write successful.'); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("Open error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > (* > * SeqFile.OpenRead(in,"seqfile.txt",flags,res); *(* read flag is implied > *) > * IF res = SeqFile.opened THEN > * * STextIO.WriteString(' Open for Reading successful.'); > * * STextIO.WriteLn; > * * FOR i:=0 TO 9 DO > * * * TextIO.ReadString(in,str); > * * * TextIO.SkipLine(in); > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * END; > * * SeqFile.Close(in); > * * STextIO.WriteString(' Fixed Read finished.'); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("Open error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > *) > * SeqFile.OpenRead(in,"seqfile.txt",flags,res); *(* read flag is implied > *) > * IF res = SeqFile.opened THEN > * * STextIO.WriteString(' 2nd open for Reading successful.'); > * * STextIO.WriteLn; > * * c := 0; > * * LOOP > * * * TextIO.ReadRestLine(in,str); > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * * TextIO.SkipLine(in); > * * * rdreslt := SIOResult.ReadResult(); > * * * STextIO.WriteString(' SIOResult = '); > * * * i:= ORD(rdreslt); > * * * SWholeIO.WriteCard(i,2); > * * * STextIO.WriteLn; > * * * IF rdreslt <> IOConsts.allRight THEN EXIT END; > * * * INC(c); > * * * IF c>20 THEN EXIT END; > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * END; > * * SeqFile.Close(in); > * * STextIO.WriteString(' 2nd Read finished.'); > * * STextIO.WriteLn; > * * STextIO.WriteString(' number of lines is:'); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("2nd Open status error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > > END xdsseqfileio. > > This is a simple test for me to understand how to do simple file i/o in > Linux. *I use stony brook for winxp, but I did not get their linux > product before they left the market. > > The problem I am having is that the rdresult, variable to store > SIOResult.ReadResult(), is not allRight after the first iteration. *I > know the file exists and can be read by the first loop that just reads > 10 times. *And I can display the file from the command prompt. > > I don't know what 2 do now? > > Thanks, > Rob PROCEDURE OpenWrite (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet; VAR res: OpenResults); Here is a partial copy of doc Module SeqFile <snipped> Inclusion of the write flag in the parameter flags is implied. .... if the read flag is included in the request, the Reread operation is available. Copyright © 1999-2000 Excelsior, LLC. Maybe with read Flag ?? JP2R |
|
#4
| |||
| |||
| On 19 jan, 16:47, Rob Solomon <ag...@drrob1.com> wrote: > MODULE xdsseqfileio; > IMPORT *SeqFile, STextIO, TextIO, SWholeIO, SIOResult, IOConsts; > CONST flags = SeqFile.text + SeqFile.old; > VAR > * out,in *: SeqFile.ChanId; > * res * * : SeqFile.OpenResults; > * i,c * * : CARDINAL; > * str * * : ARRAY [0..255] OF CHAR; > * rdreslt : IOConsts.ReadResults; > BEGIN > * SeqFile.OpenWrite(out,"seqfile.txt",flags,res); *(* write flag is > implied *) > * IF res = SeqFile.opened THEN > * * FOR i:=0 TO 9 DO > * * * TextIO.WriteString(out,"Hello"); > * * * TextIO.WriteLn(out); > * * END; > * * SeqFile.Close(out); > * * STextIO.WriteString(' Open and write successful.'); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("Open error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > (* > * SeqFile.OpenRead(in,"seqfile.txt",flags,res); *(* read flag is implied > *) > * IF res = SeqFile.opened THEN > * * STextIO.WriteString(' Open for Reading successful.'); > * * STextIO.WriteLn; > * * FOR i:=0 TO 9 DO > * * * TextIO.ReadString(in,str); > * * * TextIO.SkipLine(in); > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * END; > * * SeqFile.Close(in); > * * STextIO.WriteString(' Fixed Read finished.'); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("Open error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > *) > * SeqFile.OpenRead(in,"seqfile.txt",flags,res); *(* read flag is implied > *) > * IF res = SeqFile.opened THEN > * * STextIO.WriteString(' 2nd open for Reading successful.'); > * * STextIO.WriteLn; > * * c := 0; > * * LOOP > * * * TextIO.ReadRestLine(in,str); > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * * TextIO.SkipLine(in); > * * * rdreslt := SIOResult.ReadResult(); > * * * STextIO.WriteString(' SIOResult = '); > * * * i:= ORD(rdreslt); > * * * SWholeIO.WriteCard(i,2); > * * * STextIO.WriteLn; > * * * IF rdreslt <> IOConsts.allRight THEN EXIT END; > * * * INC(c); > * * * IF c>20 THEN EXIT END; > * * * STextIO.WriteString(str); > * * * STextIO.WriteLn; > * * END; > * * SeqFile.Close(in); > * * STextIO.WriteString(' 2nd Read finished.'); > * * STextIO.WriteLn; > * * STextIO.WriteString(' number of lines is:'); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * ELSE > * * STextIO.WriteString("2nd Open status error"); > * * STextIO.WriteLn; > * * c := ORD(res); > * * STextIO.WriteString(' res Field result, as a cardinal, is: '); > * * SWholeIO.WriteCard(c,10); > * * STextIO.WriteLn; > * END; > > END xdsseqfileio. > > This is a simple test for me to understand how to do simple file i/o in > Linux. *I use stony brook for winxp, but I did not get their linux > product before they left the market. > > The problem I am having is that the rdresult, variable to store > SIOResult.ReadResult(), is not allRight after the first iteration. *I > know the file exists and can be read by the first loop that just reads > 10 times. *And I can display the file from the command prompt. > > I don't know what 2 do now? > > Thanks, > Rob Hello Bob, just made a cut and paste on XDS windows. On winXP your pgm compile and works normaly... . Now I've just toyed with linux systems on the occasion - but I know a problem is always the rights you have to read / write and do things on your (own :+) machine. So are you running your program in a directory where you are alowed to write ? JPD |
|
#5
| |||
| |||
| That's funny. I installed the xds windows compiler, and I got the same result on WinXP as linux; that is, SIOResult.ReadResult did not return a useful value. On linux, I am compiling from my home directory to avoid priv problems. I got around the problem for the example by testing for 0 length string returned from TextIO.ReadString. This will not work in long term because it will not distinguish an empty line from endoffile. SeqFile.OpenRead(in,"seqfile.txt",flags,res); IF res = SeqFile.opened THEN STextIO.WriteString(' 2nd open for Reading successful.'); STextIO.WriteLn; c := 0; LOOP TextIO.ReadRestLine(in,str); rdreslt := SIOResult.ReadResult();<== not working as it should STextIO.WriteString(str); STextIO.WriteLn; TextIO.SkipLine(in); i:= ORD(rdreslt); SWholeIO.WriteCard(i,2); STextIO.WriteLn; |
|
#6
| |||
| |||
| I found my problem. I was using the wrong procedure to check status. I needed to use IOResult, not SIOResult. IMPORT IOResult; This now works. Thanks for listening. > That's funny. I installed the xds windows compiler, and I got the same > result on WinXP as linux; that is, SIOResult.ReadResult did not return a > useful value. On linux, I am compiling from my home directory to avoid > priv problems. > > I got around the problem for the example by testing for 0 length string > returned from TextIO.ReadString. This will not work in long term > because it will not distinguish an empty line from endoffile. > > SeqFile.OpenRead(in,"seqfile.txt",flags,res); > IF res = SeqFile.opened THEN > STextIO.WriteString(' 2nd open for Reading successful.'); > STextIO.WriteLn; > c := 0; > LOOP > TextIO.ReadRestLine(in,str); > rdreslt := SIOResult.ReadResult();<== not working as it should > STextIO.WriteString(str); > STextIO.WriteLn; > TextIO.SkipLine(in); > i:= ORD(rdreslt); > SWholeIO.WriteCard(i,2); > STextIO.WriteLn; > |
|
#7
| |||
| |||
| Rob Solomon wrote: > Hi. Is anyone here using xds modula-2 on a linux platform. > > I have some questions to ask and I was hoping this would be a useful > forum. Excelsior also has a forum specific to their compilers at http://www.excelsior-usa.com/forum/index.php?board=6.0 john > > There does not seem to be much traffic here anyway. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.