home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,319 of 2,978   
   Wolf Behrenhoff to RadSurfer   
   Re: Real Help Now, seriously   
   05 Feb 05 23:15:22   
   
   From: NoSpamPleaseButThisIsValid2@gmx.net   
      
   RadSurfer wrote:   
   > Ok!   
   >   
   > Now it is time to see you present your point in a way that makes the   
   > most   
   > profound impact: Actual code.   
   >   
   > Please show me that some of you can actually code in Pascal that would   
   > accomplish my little Text Utility example:   
   >   
   > ALL of these tasks must be performed in a SINGLE operation;   
      
   In a single operation?! That does not work, in any language! Or how do   
   you define an operation?   
      
   > subroutines are permitted, but files must be opened only ONCE,   
   > and closed only when the program terminates....   
      
   You are thinking too "low-level". This task once again proves that you   
   look at the program implementation instead of an abstract problem.   
      
   > 1) Open (only once) for read, 3 different ascii text files   
   >    (* this would be 3 simultaneously opened files. *)   
      
   No problem with this.   
      
   > 2) Show me how I can get the File Length of each File   
      
   var f: file of byte; ... assign+reset; writeln(filesize(f)); ...   
      
    >    (* Yes! The very sensible need of knowing the FileLength of TEXT   
    > files! *)   
      
   No!   
      
   >   
   > 3) Please demonstrate how I might read, Char-by-Char directly from the   
   >    Opened file (say file #1)   
      
   var f: file of char; ch: Char; ... assign+reset; read(f, ch); close ...   
   But why in hell do you want to read a file char-by-char?   
      
   > 4) Illustrate how I might read, Line-by-Line, from say File #1   
   >    (* Hey! #3 and #4 are to be the SAME FILE? Yes sir, they are. *)   
      
   var t: text; s: String;   
   ... assign+reset; while not eof(t) do begin ReadLn(t,s); WriteLn(s); end   
      
   > All should be opened in a way that fully permits accessing them   
   > each in equal ways: Either line-by-line, or char-by-char,   
   > the FileLength MUST BE KNOWN in any event.   
      
   If you want to process line-by-line, declare it a text file. For   
   char-by-char a file of char. Declare a "file of your_type"! Everything   
   else is nonsense in Pascal.   
      
   > It is acceptable to open the file in "Binary" mode, provided   
   > char-by-char, and line-by-line TEXT reads can be accomodated.   
      
   Name a program which needs all your requirements! There doesn't exist   
   any. And if you do it the way you want us to do here, it would be bad code.   
      
   > Why on Earth would NOT knowing the length of a file not be worthwhile?   
      
   What's the need for a text file? You can't seek anyway. Seek would be a   
   O(n) operation (n=FileSize).   
      
   > Why is it necessary to be overly concerned about the internal content   
   > of   
   > the file?   
      
   Why in hell do you want to read a typed or text file if you don't know   
   what's in it?   
      
   > Lets say you simply wanted to copy files onto a floppy or zippy;   
   > calculating the FileSize would be crucial! and the files are of very   
   > mixed   
   > type!  Therefore, some means to SIMPLY know their SIZE is critical to   
   > the   
   > operation!   
      
   For copying, you don't need to know the content, that is why in this   
   case, you use _untyped_ files.   
      
   There is an example for a copy-program in the help file. It even prints   
   how many bytes are being copied. Please look up "BlockRead" and/or   
   "BlockWrite".   
      
   > Thats the whole point: getting a grip on HOW Pascal is different...   
      
   Simple: Pascal allows "file of type", where type can be any data   
   structure (like a record (struct in C)). You can then read/write the   
   whole record with a single Read/Write command.   
      
   > PLEASE? Someone willing to start posting GENUINE Pascal code to   
   > illustrate how we might *COMPROMISE* on the tasks described above?   
      
   No. Not as long as you insist in wanting to port C code line by line to   
   Pascal. If you continue this way, I won't answer to any further question.   
      
   Wolf   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca