pmancini@lynx.northeastern.edu (02/26/89)
I would like to know what is (if possible) standard implementation in PASCAL to send text output simultaneously to the screen and to a LST device or file. I hate having to write lines twice, such as; writeln('abcdefg12345'); {goes to screen} writeln(lst,'abcdefg12345'); {goes to printer} Is there anyway I can send the output to both without writing the line twice? In programs which print a lot of text to the screen and the printer it gets very tedious typing everything over and over again.
Mannie@cup.portal.com (William Allison Guynes) (02/27/89)
[Answer to request for DUAL OUTPUT routine] The only way I know of to send output to two output devices at once is to create your own procedure. It's also the simplest way I'm sure. Procedure Dual_Writeln (str : string); Begin Writeln(str); Writeln(lst,str); End; I realize that this might have been obvious and that you were looking for another (possibly easier) way to do this. If there is, I don't know it, but someone else might. Mannie@cup.portal.com
mikej@pyr1.acs.udel.EDU (Michael Jacobs) (02/28/89)
In article <18461@adm.BRL.MIL> pmancini@lynx.northeastern.edu writes: > to the screen and to a LST device or file. I hate having to > write lines twice, such as; > > writeln('abcdefg12345'); {goes to screen} > writeln(lst,'abcdefg12345'); {goes to printer} > > Is there anyway I can send the output to both without > writing the line twice? How about making a procedure with a string as an input and does the two writeln's in it. Mike J, The Grey Sysop... | Ancient Spirits of Evil, transform this Temporal Hitchhiker | decayed form into Mumm-ra, the Ever Living! mikej@vax1.acs.udel.EDU |
damm@freja.diku.dk (Kristian Damm Jensen) (03/01/89)
pmancini@lynx.northeastern.edu writes: > I would like to know what is (if possible) standard > implementation in PASCAL to send text output simultaneously > to the screen and to a LST device or file. > writeln('abcdefg12345'); {goes to screen} > writeln(lst,'abcdefg12345'); {goes to printer} > Is there anyway I can send the output to both without > writing the line twice? In programs which print a lot of text > to the screen and the printer it gets very tedious typing everything > over and over again. An easy way to do this would be to make your own write-procedure, something like type string = packed array [1..N] of char; procedure writestring (ToBeWritten : string); begin writeln (ToBeWritten); writeln (lst, ToBeWritten); end; This, however, has the disadvantage that you have to write a procedure for every type you need to write from your program. Are there an easier way to do it (in standard pascal) ? Kristian
galvinp@lafcol.UUCP (Pablo) (03/02/89)
In article <2937@udccvax1.acs.udel.EDU>, mikej@pyr1.acs.udel.EDU (Michael Jacobs) writes: > In article <18461@adm.BRL.MIL> pmancini@lynx.northeastern.edu writes: > > to the screen and to a LST device or file. I hate having to > > write lines twice, such as; > > > > writeln('abcdefg12345'); {goes to screen} > > writeln(lst,'abcdefg12345'); {goes to printer} > > > How about making a procedure with a string as an input and does the > two writeln's in it. > I was once wrote a function that was passed a string of allowed input characters as well as a character that had been input. The function was not flagged with any errors or anything, but my professor stated that this was a bad idea, passing strings to functions/procedures. Was he right? I lost several points for the project and I was never given a very satisfactory answer concerning why it was a bad idea. (The program ran under Turbo Pascal). Paul J. Galvin (galvinp@lafcol).
pa1804@sdcc15.ucsd.edu (pa1804) (03/05/89)
In article <18461@adm.BRL.MIL>, pmancini@lynx.northeastern.edu writes: > > I would like to know what is (if possible) standard > implementation in PASCAL to send text output simultaneously > to the screen and to a LST device or file. I hate having to > write lines twice, such as; > > writeln('abcdefg12345'); {goes to screen} > writeln(lst,'abcdefg12345'); {goes to printer} > > Is there anyway I can send the output to both without > writing the line twice? In programs which print a lot of text > to the screen and the printer it gets very tedious typing everything > over and over again. You can write a procedure that will send the output to both the screen and the other output device: Procedure WriteAll { pass variables that are necessary } Begin { WriteAll } writeln(argument); { this goes to the screen } writeln(OutputDevice1, argument); { this goes to OutputDevice1 } writeln(OutputDevice2, argument); { this goes to OutputDevice2} end; { WriteAll } .. .. .. .. begin { main program } .. .. WriteAll; ( variables ) .. .. end. { main program } As you can see, by using the procedure WriteAll you can send output to as many destinations as you want. George Chen pa1804@sdcc15.UCSD.EDU PO BOX 4474 La Jolla, CA 92037
chan@galaxy.ee.rochester.edu (Daniel Chan) (03/05/89)
>From: pa1804@sdcc15.ucsd.edu (pa1804) Date: 4 Mar 89 23:41:57 GMT Organization: University of California, San Diego >In article <18461@adm.BRL.MIL>, pmancini@lynx.northeastern.edu writes: > > I would like to know what is (if possible) standard > implementation in PASCAL to send text output simultaneously > to the screen and to a LST device or file. I hate having to > write lines twice, such as; > > writeln('abcdefg12345'); {goes to screen} > writeln(lst,'abcdefg12345'); {goes to printer} > > Is there anyway I can send the output to both without > writing the line twice? In programs which print a lot of text > to the screen and the printer it gets very tedious typing everything > over and over again. ! You can write a procedure that will send the output to both ! the screen and the other output device: ! ! ! ! ! Procedure WriteAll { pass variables that are necessary } ! ! Begin { WriteAll } ! ! writeln(argument); { this goes to the screen } ! ! writeln(OutputDevice1, argument); ! { this goes to OutputDevice1 } ! ! writeln(OutputDevice2, argument); ! { this goes to OutputDevice2} ! ! end; { WriteAll } ! ! .. ! .. ! .. ! .. ! ! begin { main program } ! ! .. ! .. ! WriteAll; ( variables ) ! .. ! .. ! end. { main program } ! ! ! ! ! As you can see, by using the procedure WriteAll you can ! send output to as many destinations as you want. ! ! ! ! George Chen ! ! pa1804@sdcc15.UCSD.EDU PO BOX 4474 La Jolla, CA 92037 The problem is not that simple when you have something like: writeln ("abcdefg34"); writeln (345, "abcd"); writeln ("345", 1.2E-3); It's also very painful to create a procedure for each combination of arguments you want to write. You need a function (like sprintf in C) that takes arguments like write/writeln and returns a string of what the output looks like. You can then use that string as an argument to WriteAll. This method is slightly less painful than duplicating every write/writeln. It works even better if you want your output to go to more than two places. Also there was a posting couple of days ago about logging both input and output. Hope all these will help. -dan.
vg55611@ihuxy.ATT.COM (Gopal) (03/06/89)
>>In article <18461@adm.BRL.MIL>, pmancini@lynx.northeastern.edu writes: >> >> I would like to know what is (if possible) standard >> implementation in PASCAL to send text output simultaneously >> to the screen and to a LST device or file. I hate having to >> write lines twice, such as; >> >> writeln('abcdefg12345'); {goes to screen} >> writeln(lst,'abcdefg12345'); {goes to printer} Utility programs are available on many operating systems that will do a "TEE" operation - i.e. that will send the standard output to both the standard output (say screen) and an auxiliary file. I know something like this exists for UNIX and I have seen something similar for MS-DOS (unfortunately have neither one). On MS-DOS, you can also use the <ctrl>-prtsc functions to copy the standard output to the printer along with the display. MS-PASCAL allows you to create a string variable that is formatted with the output of the writeln; but I don't think there are many MS_PASCAL users in the DOS world. Venu P. Gopal UUCP: att!ihuxy!vg55611 Internet: vg55611@ihuxy.att.com BITNET: com%"vg55611@ihuxy.att.com" or com%"vg55611%ihuxy@research.att.com" Save 500 million keystrokes a day; silence those silent letters forever.