TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: DON SCHULLIAN
date: 1998-02-27 04:55:00
subject: Re: Reading and Writing t

From: d83@ath.forthnet.gr (Don Schullian)
Subject: Re: Reading and Writing to files
 
On 26 Feb 1998 21:16:46 GMT, "Peter.waller" 
wrote:
 
>
>>   What kind'a file? RANdomm access, SEQuential, BINary?
>RANdomm access
>>   Are the lines consecutive?
>yes
>>   Are the lines of equal length to the ones being replaced?
>Probably not!
 
Ok.. if the file is RANdom and not SEQ then the problem is easily solved..
 
eg: OPEN "R", #FileNo%, FileName$, 128
      PUT #FileNo, LineNo%, LineInfo$
 
However RANdom files implyes that each record(line) is of equal length or, at
least padded or truncated to conform.
 
If, however, the file is SEQ ( eg: OPEN "I", #1, FileName$ ) then you'd 
ither
have to load the whole file into an array, change the lines required, and
rewrite the whole thing again. Or, open the file in Binary mode, find the
start of the text to be changed then, if the new text is shorter than the old
text; write the new text, move the following data up the file and truncate 
he
file: or if the new text were longer; move the existing data down the file
before writing the text. (quite a process to be sure).
 
  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|
    Reply to: d83@ath.forthnet.gr
     www.basicguru.com/schullian
 
*** QwkNews (tm) v2.1
 * [TN71] Internet Newsgroup: alt.lang.powerbasic
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/561)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.