Skip to contentSkip to conversation

How to read and Delete a character from a text file?

DISCUSSION Vinoth Rajagopal 2 participants 2 messages Aug 22, 2008

lore
Share & tools
lore
#0 lore raw

Hi Friends,

I need to your help with resolving this issue.

Actually I need to open a text file (D:\a.txt) and I need to read that file character by character. When the Character count reaches 226 I need to delete that character. An then I need to start my count from next chracter.

Is it possible to perform in DOS....

Please help me to resolve this issue...

Thanks In Advance

Thanks,
Vinoth

Signature · 2 lines
View this message in context: http://www.nabble.com/How-to-read-and-Delete-a-character-from-a-text-file--tp19100322p19100322.html
Sent from the linux-msdos mailing list archive at Nabble.com.
#1 lore raw
Quoted 5 lines · On Thu, 21 Aug 2008 19:24:01 -0700 (PDT) Vinoth Rajagopal…

Actually I need to open a text file (D:\a.txt) and I need to read that file character by character. When the Character count reaches 226 I need to delete that character. An then I need to start my count from next chracter.

Is it possible to perform in DOS....

I'm not sure if you can perform that feat using just command.com and a batch file.

However, the "stock" dosemu comes with bwbasic, a basic interpreter that can certainly do what you're looking for.

Here is an untested bwbasic program:

10 open "R",1,"a.txt",1
20 field #1, 1 as a$
30 open "O",2,"b.txt"
40 for x = 1 to 225
50 if eof(1) then 110
60 get #1
70 print #2, a$;
80 next x
90 if not eof(1) then get #1
100 goto 40
110 close 1,2
120 kill "a.txt"
130 name "b.txt" as "a.txt"
140 end

You can run this from the command line by saving it as a dos-formatted text file, then using this command:

bwbasic program.bas

where program.bas is the name of the program text file.

Note that I haven't really tested this little program except to insure that it runs and doesn't hang in an infinite loop. It may not work at all for your purpose as presented here. Experiment with it and edit it to suit your needs.

Signature · 1 line
MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com