Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!hplabs!hpcc05!hpyhde4!hpycla!hpcuhc!hpcupt3!defaria@hpcupt3.cup.hp.com From: defaria@hpcupt3.cup.hp.com (Andy DeFaria) Newsgroups: comp.lang.pascal Subject: Re: Text Files, I/O Redirection Message-ID: <45670018@hpcupt3.cup.hp.com> Date: 22 May 91 16:46:52 GMT References: <45670017@hpcupt3.cup.hp.com> Organization: Hewlett Packard, Cupertino Lines: 34 >/ hpcupt3:comp.lang.pascal / defaria@hpcupt3.cup.hp.com (Andy DeFaria) / 10:44 am May 21, 1991 / >I have been having three problems lately in TP: > > 1) How do you perform I/O redirection using Exec? I remember this > being discussed and had thought that my home-brewed shell did > this properly then found out it doesn't and the posting has > since timed out. I thought that I needed to Exec Command.Com > and specify the ">" or "|" options in the Options parameter but > this not working. > > 2) How do you get the name of an open text file from AFile : Text > variable? > > 3) The FileSize function doesn't work on Text files. How can I > easily and efficiently get the FileSize (in bytes) of a Text > file? I have solved #2 and #3. The solution for #2 is to cast the Text file to a TextRec and extract the Name field. Unfortunately this Name field is an ASCIIZ string (smells like a C string). So: FileName := ASCIIZToString (TextRec (TextFile).Name); Where ASCIIZToString is a function that converts the ASCIIZ string to a TP String. The solution to #3 is a little bit uglier but works. Basically, I take the Text file, get its name (see above), assign it to a File of Byte and call FileSize on that file (Oh and don't forget to Close the file). I would like to come up with a better method for this. I don't like opening and closing files if I can avoid it. Perhaps a FindFirst would give me the information but I'm not sure if FindFirst would incur more overhead than an Open/Filesize/Close. Does anybody know? Oh, and I'm still waiting for an answer to #1.