Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!gumby!bezanson From: bezanson@gumby.WISC.EDU (Brian Bezanson) Newsgroups: net.micro.mac Subject: Re: TML Pascal ver 2.01 bug Message-ID: <440@gumby.WISC.EDU> Date: Sun, 2-Nov-86 00:44:47 EST Article-I.D.: gumby.440 Posted: Sun Nov 2 00:44:47 1986 Date-Received: Mon, 3-Nov-86 23:59:40 EST References: <12125@watnot.UUCP> Distribution: net Organization: Manta Software Corporation Lines: 38 Summary: TML and Programming Bug In article <12125@watnot.UUCP>, mjmartin@watnot.UUCP (Marie-Josee Martin) writes: > Using the "Plain Vanilla" mode, TML doesn't pass variable text parameters > correctly, at least for input and output. The following piece of code > compiles correctly but never runs correctly. Actually, the program hangs > (and sometimes crashes.) > procedure Sread (var f : text); > begin > writeln (SizeOf (f)); > get (f); > while f^ <> 'q' do > get (f) > end; > By defining the procedure as: > procedure Sread (f : text); > the program compiles correctly AND executes properly. (Try to figure > that out.) I tried a similiar procedure recently in a program running under Lightspeed Pascal. But when it tried to compile a procedure similiar to your second one, WITHOUT the VARiable parameter, Lightspeed gave me an error. What you have to do is change it to a VAR parameter, no mater if you plan on changing it or not. The reason why (correct me somebody because this may not be perfect) is that a file of type TEXT (or a file of char) is a pointer or start of a buffer in memory for this file. By passing it as a straight parameter, the computer would try and pass a copy of the buffer onto the stack. By using a VAR parameter you are passing a pointer to this buffer, thus giving no memory problems at all. Lightspeed is set up to watch for this possible error, either TML misses this, or Leonard lets you try it and when it gets pushed on the stack, the program either bombs or hangs. I made the fix in my procedures and used VAR parameters and everything worked fine, I would assume this should fix your problem with TML. -- Brian Bezanson {seismo,ihnp4,allegra,topaz,harvard}!uwvax!gumby!bezanson Manta Software Corp. bezanson@gumby.wisc.edu