Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!bbn!uwmcsd1!ig!agate!ucbvax!UOGUELPH.BITNET!BOTCHAIR From: BOTCHAIR@UOGUELPH.BITNET (Alex Bewley) Newsgroups: comp.lang.modula2 Subject: Re: Recursion & Types Message-ID: Date: 11 Feb 88 22:50:03 GMT References: Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Info-Modula2 Distribution List Organization: The Internet Lines: 36 Pointers are extremely useful. They can be used for type conversion (but we, being good programmers :-), don't do this). They can also be used to 'fix' data structures to certain locations in memory. For example consider the video screen of a PC. It is composed of 4000 bytes. The colour screen memory is located at B800H:0000H, and the monochrome screen memory is located at B000H:0000H. A small procedure could determine which type of video card is being used and set an array to point to the appropriate memory location. Thus, every time you use a data structure (usually a two dimensional array, in this case) it will change the screen display. Some code is included below. For this screen exercise you could use the absolute variable declaration, but that would mean defining an array for each screen. Alex ----- TYPE ScreenType = POINTER TO ARRAY [0..25-1],[0..80-1] OF RECORD Char, Attr : CHAR; END; VAR Screen : ScreenType; BEGIN (* determine video card type *) ... IF ColourMonitor THEN Screen := 0B800H:0000H; ELSE Screen := 0B000H:0000H; END; ... Screen[0][0].Char := "A"; (* put an 'A' in the top left corner of the *) END; (* screen *)