Re: [BLACKBOX] Simple ASCII text editor example

From: [at]} <Josef>
Date: Fri, 6 Aug 2010 10:27:03 +0200


I would not use anything from the Texts subsystem for this task.
It is much more efficient to use the module 'Files' directly.
You can read and write the same file using a Files.Reader and a Files.Writer
connected to one and the same file. They are kept in sync.
 
There is 'only' one problem with this approach.
As far as I see from the interface of 'Files' there is no way to
truncate an existing file, ie. to set a new file size smaller
than the original one.
 
You would have to call WinApi.SetEndOfFile,
which is a nasty low level operation that should be part
of the Files interface.
 
- Josef
 
 
 

----- Original Message -----
From: Stephen <mailto:stroy{([at]})nowhere.xy
To: BLACKBOX{([at]})nowhere.xy
Sent: Friday, August 06, 2010 4:29 AM
Subject: [BLACKBOX] Simple ASCII text editor example


Hello List,
I am working with a database program which exports the data as an ASCII text file. I have been writing programs to generate additional reports from this ASCII data file. I want to add a function to filter out certain unnecessary lines in the ASCII data, so I want to read the ASCII file line by line, and (a) if the read lines are not the ones to filter out, write them back to the file; or (b) if they are the ones to filter out, NOT write them back; i.e. I want to read and write in the same ASCII text file. The Blackbox documentation indicates I can have a reader rider (scanner) and a writer rider (formatter) connected to the same file; however the documentation for the ASCII text file example (ObxAscii Docu) states "Mixed reading and writing on the same text is not very common and is therefore not supported in this simple model." I have tried a simple program with both a TextMappers.Scanner and a TextMappers.Formatter. This works as expected with only the Scanner, but as soon as I add the Formatter, the
Scanner becomes unstable, jumps backward and repeats characters already read. Does anybody have an example of a simple ASCII text editor, which reads and writes to the same file, that they would be willing to share? Thanks for any suggestions.
Stephen Troy



---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy

---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Fri Aug 06 2010 - 10:27:03 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:30 UTC