Jump to content
Excelsior Forums


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About kaztkc

  • Rank
  • Birthday 01/01/01
  1. Of course you set all run-time checks TRUE, I guess (See 5.1 of the User's Guide). If I were you, I would dump all data having something to do with 'in-process dialog box,' before and after calling the dialog box. If you find some unexpected values, find out when it was overwritten. Another way is reducing the program to a minimal one, e.g. one that just write what is read, without any change, and one that write out the data after only one step processed, etc. Perhaps making and inspecting a command-line version first will be a good idea.
  2. No, you are not an idiot. See my post `IOChan.RawWrite cooks' (20 September 2005 - 11:31 PM) although it is about XDS Modula-2. And, if you like to hear, IOChan.RawRead has the same problem, i.e. you get CR/LF when the file has only LF. My anser: Import Windows module and write RawWrite yourself. PROCEDURE RawWrite(cid: ChanId; from: ADDRESS; locsToWrite: CARDINAL); VAR res: CARDINAL; BEGIN IF Windows.WriteFile(cid^.Handle, from, locsToWrite, res, NIL) THEN (*nothing*) ELSE (*put error message if you like*) HALT() END END RawWrite; But this means that you rewrite all other file i/o procedures including open and close, as well as the entire InOut module. I did it. I hope the new version be better, but I think I will keep using my own library for the sake of compatibility and simplicity.
  3. I made the case simpler, so inspect this one. 1 MODULE test; 2 3 FROM InOut IMPORT WriteString; 4 5 MODULE Local; 6 IMPORT WriteString; 7 EXPORT XYZ, Select; 8 9 TYPE 10 XYZ= (x, y, z); 11 PROCEDURE Select(which: XYZ); 12 BEGIN 13 IF which = x THEN 14 WriteString("x selected.") 15 ELSIF which = y THEN 16 WriteString("y selected.") 17 ELSE 18 WriteString("z selected.") 19 END 20 END Select; 21 END Local; 22 23 BEGIN (*main module*) 24 Select(z) 25 END test. XDS Modula-2 v2.40 [x86, v1.50] - build 10.05.2005 Compiling "test.mod" * [test.mod 21.10 E022] * identifier "x" was already defined at test.mod[21.10] END Local$; errors 1, no warnings, lines 25, time 0.00
  4. Hi, I'm having a trouble in exporting an enumerate type from a local module. This is the simplified version of my code. I want to export SortMode type defined in line 10, but it causes an error at the end of local module. Grammatically it's correct, is it not? 1 MODULE test; 2 3 FROM InOut IMPORT WriteString; 4 5 MODULE Comparison; 6 IMPORT WriteString; 7 EXPORT SortModes, InOrder, InOrderIni; 8 9 TYPE 10 SortModes = (SortByCode, IgnoreCase, DecimalVal); 11 CmpProcs = PROCEDURE (VAR CHAR, VAR CHAR): BOOLEAN; 12 13 VAR 14 InOrder: CmpProcs; 15 Mode: SortModes; 16 17 PROCEDURE InOrderAsc(VAR ch0, ch1: CHAR): BOOLEAN; 18 BEGIN 19 RETURN FALSE END InOrderAsc; 20 21 PROCEDURE InOrderAscIg(VAR ch0, ch1: CHAR): BOOLEAN; 22 BEGIN 23 RETURN FALSE END InOrderAscIg; 24 25 PROCEDURE InOrderAscNum(VAR ch0, ch1: CHAR): BOOLEAN; 26 BEGIN 27 RETURN FALSE END InOrderAscNum; 28 29 PROCEDURE InOrderIni(Mode: SortModes; EndStr: CHAR; BeginCol: CARDINAL); 30 BEGIN 31 IF Mode = IgnoreCase THEN 32 InOrder := InOrderAscIg; WriteString("IgnoreCase selected.") 33 ELSIF Mode = DecimalVal THEN 34 InOrder := InOrderAscNum; WriteString("DecimalVal selected.") 35 ELSE 36 InOrder := InOrderAsc; WriteString("SortByCode selected.") 37 END 38 END InOrderIni; 39 40 END Comparison; 41 42 (* main module *) 43 44 BEGIN (*main*) 45 InOrderIni(IgnoreCase, 0C, 0); 46 END test. XDS Modula-2 v2.40 [x86, v1.50] - build 10.05.2005 Compiling "test.mod" * [test.mod 40.15 E022] * identifier "SortByCode" was already defined at test.mod[40.15] END Comparison$; errors 1, no warnings, lines 46, time 0.02
  5. I have a problem in detecting EOF of stdin when it is piped. The following is a simple version of cat, which handles only StdInChan. MODULE simplcat; FROM STextIO IMPORT ReadChar, SkipLine, WriteChar, WriteLn; FROM SIOResult IMPORT ReadResults, ReadResult; VAR ch: CHAR; BEGIN ReadChar(ch); WHILE ReadResult() <> endOfInput DO IF ReadResult() = endOfLine THEN WriteLn(); SkipLine() ELSE WriteChar(ch) END; ReadChar(ch) END END simplcat. Compile this module on Windows XP, type simplcat <simplcat.mod and you will have no problem. But reading from pipeline, e.g. simplcat <simplcat.mod | simplcat type simplcat.mod | simplcat etc. will, after printing all the lines, cause RTS exception. Errinfo.$$$ is like this: d:\work\simplcat.exe #RTS: unhandled exception #4: IOException.hardDeviceError 0000006DH 00000226 00000000 d:\work\simplcat.exe 00001CD8 00000000 d:\work\simplcat.exe 00001BA4 00000000 d:\work\simplcat.exe 000031D9 00000000 d:\work\simplcat.exe 00004116 00000000 d:\work\simplcat.exe 000019C1 00000000 d:\work\simplcat.exe 000024C3 00000000 d:\work\simplcat.exe 00001FDA 00000000 d:\work\simplcat.exe 00000065 00000000 d:\work\simplcat.exe I have no idea who is to blame, you or Microsoft. Does it occur only in Japan, maybe? Could you try the module on your XP computer? Other observations: The error does not occur if ReadToken is used instead of ReadChar. But it does occur if ReadRestLine is used. I downloaded XDS on May 31, 2005. My system is Windows XP Home Edition Service Pack 2 from Microsoft Japan.
  6. See "Report on the Programming Language Modula-2" in Wirth's PROGRAMMING IN MODULA-2. 8.2.3. Set Operators shows that you can apply +, -, *, and / to BITSET expressions. Thus, cast your INTEGER (or anything) to BITSET, and + will give you bitwise OR * bitwise AND / bitwise XOR.
  7. TextIO.ReadChar(ArgChan(), ch) behaves differently from e.g. TextIO.ReadChar(StdInChan(), ch). That is, it ignores spaces, so that calling it repeatedly, you will get allthewordswithoutonesinglespace. Compile this code in Win version MODULE Test; FROM TextIO IMPORT ReadChar, WriteChar; FROM ProgramArgs IMPORT ArgChan, IsArgPresent; FROM StdChans IMPORT StdOutChan; ? VAR ? ? ?ch: CHAR; BEGIN ? WHILE IsArgPresent() DO ? ? ?ReadChar(ArgChan(), ch); ? ? ?WriteChar(StdOutChan(), ch) END END Test. and type ? test all the words without one single space, you will see. I feel it somewhat inconvenient, esp. when I need precise control such as discerning plain strings and quoted ones.
  8. According to ISO Modula-2 Library Reference 1.3.3, IOChan.RawWrite is supposed to "transfer data location by location with no translation or interpretation," but actually it converts LF (12C) into CR LF. I hope it be fixed in the next release.