DOS_M2.DOC 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. DOS TopSpeed Modula-2 with Objects Release notes version 3.10
  2. ================================== ==========================
  3. This document contains information on the following:
  4. 1. DIFFERENCES FROM TOPSPEED VERSION 2.00
  5. 2. ERRATA
  6. 3. OBJECT-ORIENTED GRAPHICS INTERFACE
  7. 4. TOPSPEED EXTENSIONS
  8. 5. COMMON QUESTIONS AND ANSWERS
  9. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  10. 1. DIFFERENCES FROM TOPSPEED VERSION 2.00
  11. ==========================================
  12. Major improvements and alterations to the TopSpeed Modula-2
  13. compiler and code generator since the previous version include
  14. the following:
  15. þ More memory models are available, including an automatic code
  16. and data overlaying model.
  17. þ TopSpeed Modula-2 now supports Microsoft Windows version 3.
  18. þ Support for third-party libraries has been improved,
  19. particularly in the area of floating-point code generation
  20. (via the standard_float pragma). A large model stack-frame
  21. library is now supplied with TopSpeed Modula-2, which is
  22. likely to be of use when linking to third party libraries
  23. compiled for use with other vendors' C compilers.
  24. þ TopSpeed Modula-2's object-oriented features have been
  25. enhanced, to support multiple inheritance and linking to C++
  26. classes. The syntax of class declarations have been changed;
  27. the supplied utility program NEWCLASS may be used to translate
  28. object-oriented source code designed for the previous release
  29. of TopSpeed Modula-2.
  30. 2. ERRATA
  31. ==========
  32. Reference manual p 17:
  33. The FIXREAL Real type should have the following numeric range:
  34. -2^63 to 2^63 -1
  35. Reference manual p 18 paragraph 1:
  36. This paragraph should read as follows:
  37. Modula-2 has one predefined enumeration type defining
  38. truth values:
  39. TYPE
  40. BOOLEAN = (FALSE, TRUE);
  41. Reference manual p 43:
  42. A type transfer function is considered well-behaved if the sizes
  43. of the transfer type and the value type are the same, or if a
  44. proper VAL conversion is performed. If the value type size is more
  45. than the transfer type size then the remaining last bytes of the
  46. value are ignored. If it is shorter, the last bytes of the resulting
  47. value are undefined.
  48. Reference manual p 72:
  49. Line 18 of Example 1 should read as follows:
  50. RETURN(c1 IS classTwo)
  51. Reference manual p 109:
  52. The default value of separators should read as follows:
  53. Str.CHARSET {
  54. CHR(9),
  55. CHR(10),
  56. CHR(13),
  57. CHR(26),
  58. CHR(32),
  59. }
  60. Reference manual p 126:
  61. The values returned by the GetDrive procedure are
  62. 1 for Drive A, 2 for Drive B, etc.
  63. Reference manual p 136 line 29:
  64. This line should read:
  65. Name : PathTail;
  66. Reference manual p 137:
  67. The example should read as follows:
  68. (*
  69. This example also illustrates the use
  70. of ReadNextEntry
  71. *)
  72. IMPORT FIO, IO;
  73. VAR
  74. Ent : FIO.DirEntry;
  75. FOUND : BOOLEAN;
  76. BEGIN
  77. ...
  78. Found := FIO.ReadFirstEntry( "C:\COM\*.EXE",
  79. FIO.FileAttr{FIO.system,FIO.hidden},
  80. Ent);
  81. WHILE Found DO
  82. IO.WrStr(Ent.Name);
  83. IO.WrLn;
  84. Found := FIO.ReadNextEntry(Ent);
  85. END;
  86. ...
  87. Reference manual p 139:
  88. The drive values for the SetDrive procedure are
  89. 1 for Drive A, 2 for Drive B, etc.
  90. Reference manual p 155:
  91. The syntax for the FindNewPath and FindPath procedures should
  92. read as follows:
  93. PROCEDURE FindNewPath(
  94. name : ARRAY OF CHAR;
  95. VAR fullname : ARRAY OF CHAR) : BOOLEAN;
  96. PROCEDURE FindPath(
  97. name : ARRAY OF CHAR;
  98. VAR fullname : ARRAY OF CHAR) : BOOLEAN;
  99. The description of these procedures omits the following information:
  100. FindNewPath always returns TRUE.
  101. FindPath returns TRUE if the requested file was found.
  102. Reference manual p 157:
  103. The description of the Open procedure should read as follows:
  104. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  105. Open Open file for reading using redirection
  106. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  107. PROCEDURE Open( name : ARRAY OF CHAR ) : File;
  108. The Open procedure is used to open a file for reading. In
  109. this way it is identical to the OpenRead procedure in the
  110. FIO module. This version of Open, however, uses the
  111. redirection file to determine the full path string of the
  112. file. The FIO version of OpenRead only looks in the current
  113. directory.
  114. Reference manual p 157:
  115. The OpenRW procedure is not documented in the manual. The syntax
  116. and description are as follows:
  117. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  118. OpenRW Open file using redirection
  119. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  120. PROCEDURE OpenRW( name : ARRAY OF CHAR ) : File;
  121. The OpenRW procedure is used to open a file for processing.
  122. In this way it is identical to the Open procedure in the FIO
  123. module. This version of Open, however, uses the redirection
  124. file to determine the full path string of the file. The FIO
  125. version of Open only looks in the current directory.
  126. Reference manual p171:
  127. The third paragraph should read as follows:
  128. Thus to draw a rectangle in Red, on a CGA adapter:
  129. x:= Graph.SetVideoMode(MRES4COLOR);
  130. y:= Graph.SelectPalette(0);
  131. (* Palette 0 *)
  132. Graph.Rectangle(10,10,100,2,FALSE);
  133. (* The color is 2 (Red) *)
  134. Reference manual, page 173:
  135. The description of Arc should be replaced by the following:
  136. PROCEDURE Arc( x0, y0, a0, b0, x1, y1, x2, y2 : CARDINAL;
  137. Color : CARDINAL );
  138. Draws an arc in the color number specified by the Color
  139. parameter. The arc drawn is a fragment of an ellipse. The
  140. arc is specified using the parameters (x0,y0), a0, b0,
  141. (x1,y1) and (x2,y2) in the following manner:
  142. (x0,y0) Specifies the center of the ellipse that
  143. contains the arc.
  144. a0 Specifies the length of the semi-major axis
  145. of the ellipse that contains the arc.
  146. b0 Specifies the length of the semi-minor axis
  147. of the ellipse that contains the arc.
  148. (x1,y1) Specifies the co-ordinates for the starting
  149. point of the arc
  150. (x2,y2) Specifies the co-ordinates for the ending
  151. point of the arc
  152. The arc is drawn from (x1,y1) counterclockwise to (x2,y2).
  153. Reference manual, page 177:
  154. The description of Ellipse should be replaced by the following:
  155. PROCEDURE Ellipse( x0, y0 : CARDINAL; a0, b0 : CARDINAL;
  156. Color : CARDINAL; Fill : BOOLEAN );
  157. Draws an ellipse in the color number specified by the Color
  158. parameter. The ellipse is specified using the parameters
  159. (x0,y0), a0 and b0 in the following manner:
  160. (x0,y0) Specifies the center of the ellipse.
  161. a0 Specifies the length of the semi-major axis of
  162. the ellipse.
  163. b0 Specifies the length of the semi-minor axis.
  164. Color Specifies the color number used to draw the
  165. ellipse
  166. Fill If TRUE the ellipse is filled with the current
  167. fill mask (see Graph.SetFillMask).
  168. Reference manual, page 185:
  169. The description of Pie should be replaced by the following:
  170. PROCEDURE Pie( x0, y0, a0, b0, x1, y1, x2, y2 : CARDINAL;
  171. Color : CARDINAL; Fill : BOOLEAN );
  172. This procedure draws a pie slice. The parameters have the
  173. following meaning:
  174. Draws an arc in the color number specified by the Color
  175. parameter. The arc drawn is a fragment of an ellipse. The
  176. arc is specified using the parameters (x0,y0), a0, b0,
  177. (x1,y1) and (x2,y2) in the following manner:
  178. (x1,y1) Specifies the center of the ellipse that
  179. contains pie slice.
  180. a0 Specifies the length of the semi-major axis of
  181. the ellipse that contains the pie slice.
  182. b0 Specifies the length of the semi-minor axis of
  183. the ellipse that contains the pie slice.
  184. (x1,y1) Specifies the co-ordinates for the starting
  185. point of the pie slice (curved) edge.
  186. (x2,y2) Specifies the co-ordinates for the ending
  187. point of the pie slice (curved) edge.
  188. The pie slice arc is drawn from (x1,y1)
  189. counterclockwise to (x2,y2).
  190. Color Specifies the color number used to draw the
  191. slice.
  192. Fill If TRUE the pie slice is filled, otherwise
  193. only the outline is drawn.
  194. Reference manual p 199:
  195. The SetVideoMode procedure returns FALSE if the mode selected
  196. is not supported by the hardware.
  197. Reference manual p 220:
  198. The example should read as follows:
  199. For example:
  200. IMPORT Lib, IO;
  201. ...
  202. VAR
  203. CPU : Lib.CpuRec;
  204. ...
  205. Lib.CpuId(CPU);
  206. IF (CPU.cpu <> Lib.cpu_80386)
  207. OR (CPU.fpu <> Lib.fpu_80387) THEN
  208. IO.WrStr(
  209. "Won't run without a 80386 & 80387");
  210. HALT;
  211. END;
  212. ...
  213. Reference manual p 229:
  214. The declarations of the SetDate and SetTime Procedures should
  215. read as follows:
  216. PROCEDURE SetDate(
  217. VAR Year, Month,
  218. Day : CARDINAL) : BOOLEAN;
  219. PROCEDURE SetTime(
  220. Hrs, Mins,
  221. Secs, Hsecs : CARDINAL) : BOOLEAN;
  222. The return value indicates whether the date or time specified
  223. was valid.
  224. Reference manual, page 257:
  225. PROCEDURE ATan2 should read:
  226. ATan2 returns the arc tangent of ( Y / X ) and the result is
  227. in the range -ã to ã.
  228. Reference manual p 261 line 24:
  229. This line should read as follows:
  230. These are in graphics coordinates irrespective of the mouse
  231. state.
  232. Reference manual p 261 line 30:
  233. This line should read as follows:
  234. These are in graphics coordinates irrespective of the mouse
  235. state.
  236. Reference manual p 275 lines 11 and 15:
  237. The value in both cases should be 1 and not 0.
  238. Reference manual p 286:
  239. The spelling of the NearAllocate and FarAllocate procedures
  240. is incorrect and should read as spelt in this sentence.
  241. Reference manual p 288:
  242. The spelling of the NearDeallocate and FarDeallocate procedures
  243. is incorrect and should read as spelt in this sentence.
  244. Reference manual, page 312:
  245. Str.Match matches insensitive to the case of the characters.
  246. Thus the second example returns TRUE.
  247. 3. OBJECT-ORIENTED GRAPHICS INTERFACE
  248. ======================================
  249. Within the multi-language example programs is an object
  250. orientated interface to the M2 graphics module.
  251. 4. TOPSPEED EXTENSIONS
  252. =======================
  253. The following is a list of TopSpeed extensions to Modula-2 as
  254. described in Niklaus Wirth's Programming in Modula-2, 3rd
  255. edition.
  256. Address constructor A := [S:O PT]
  257. Based pointers SP : POINTER S TO T
  258. Structured constants SC = A(C1,C2)
  259. Concatenation of string constants S = 'ST'+'RING'+CHR(13)
  260. Type conversion of numeric types I := INTEGER(CARD)
  261. Standard types BYTE, SHORTINT, SHORTCARD, LONGCARD,
  262. LONGWORD, SHORTADDR
  263. Standard constant NULLPROC
  264. Object extensions, with CLASS, IS, VIRTUAL and SELF keywords.
  265. Alias notation A ::= P
  266. Compiler pragmas (*# ... *)
  267. Conditional compilation (*% ... *)
  268. Compiler directives (old style) (*$ ... *)
  269. SIZE and some other SYSTEM functions do not
  270. have to be imported from SYSTEM
  271. Function procedures may return any data type
  272. Shift operators >> and <<
  273. GOTO/LABEL GOTO fail
  274. SIZE may be applied to any expression or designated variable.
  275. Identifiers imported in a definition module do not have to
  276. be re-imported in the corresponding implementation module.
  277. A module may refer to its own objects using qualified
  278. reference.
  279. Keyword INLINE allows specification of a procedure body
  280. in a definition file.
  281. Binary procedures can be defined to be a constant agregate.
  282. VSIZE can find the size of a record (or object) type or
  283. variable upto and including the specified field.
  284. FieldOfs returns the offset of a field relative to the
  285. start of a record (or object) variable or type.
  286. A New function FieldOfs can be used to get the offsets of record
  287. fields of record and objects, it works on variables and types.
  288. Function procedure results may be dereferenced,
  289. indexed or fields selected.
  290. Procedures may be declared using a FORWARD declaration.
  291. Procedure may be declared externally in another module
  292. PROCEDURE P; IN file;
  293. Multiple-models mean that ADDRESSes and POINTERS can be 16 or
  294. 32 bits. FarADDRESS, NearADDRESS, FarADR and NearADR can
  295. be used to specify these explicitly.
  296. Procedure variables may be compared for equality.
  297. Pragmas may specify various calling conventions/parameter
  298. passing techniques.
  299. Record fields may be packed by using a pragma.
  300. 5. COMMON QUESTIONS AND ANSWERS
  301. ================================
  302. Q: How do I link to my own and other peoples C libraries?
  303. A: If you want to interface to third party libraries you will
  304. have to use pragmas within the definition module to set C
  305. calling and naming conventions, and if necessary, to turn
  306. off register parameter passing. Of course if you use TopSpeed
  307. C to build your C library you can continue to take advantage
  308. of register parameter passing.
  309. Q: How do I output to the printer using the library?
  310. A: You can use the standard handle PrinterDevice defined in
  311. FIO.DEF which is pre-opened when your program starts. Then
  312. you can use all the FIO routines available, passing the
  313. handle as the first parameter e.g:
  314. FIO.WrStr(FIO.PrinterDevice,'Hello'+CHR(13)+CHR(10)+CHR(12));
  315. An alternative is to use FIO.Open to open the printer device
  316. 'LPT1' and use the handle returned in the same way.
  317. Q: When using the C function printf from Modula-2, why does '\n'
  318. not get interpreted as a new line.
  319. A: The \n and other escape characters prefixed by '\' are not
  320. actually processed by printf but are in fact part of the C
  321. language when defining constant strings. In TopSpeed Modula-2
  322. you can use string constant concatenation: e.g.
  323. printf("hello world"+CHR(13)+CHR(10));
  324. Q: How can I use conditional compilation to include or exclude
  325. IMPORTs.
  326. A: You can do this by having a boolean constant in a definition
  327. which then can be imported before the conditional compilation
  328. is needed.
  329. E.g.
  330. DEFINITION MODULE OSVER;
  331. CONST MSDOS = TRUE; OS2 = NOT MSDOS;
  332. END OSVER.
  333. and in your implementation:
  334. FROM OSVER IMPORT MSDOS,OS2;
  335. ...
  336. (*%T MSDOS*)
  337. FROM SYSTEM IMPORT Seg,Ofs,Registers,CarryFlag,ZeroFlag;
  338. (*%E*)
  339. (*%T OS2*)
  340. IMPORT Dos,Kbd ;
  341. (*%E*)
  342. Q: How do I export a procedure from a local module that is
  343. defined in the definition module:
  344. A: As the definition of the procedure is already defined this
  345. procedure must be IMPORTed into the local module (not
  346. EXPORTed).
  347. E.g.
  348. DEFINITION MODULE test;
  349. PROCEDURE embedded;
  350. END test.
  351. IMPLEMENTATION MODULE test;
  352. MODULE local;
  353. IMPORT Embedded;
  354. PROCEDURE Embedded;
  355. BEGIN
  356. END Embedded;
  357. END local;
  358. END test.
  359. Note that using EXPORT instead of IMPORT is not supported.
  360.