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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 21 Aug 2008 19:24:01 -0700 (PDT)
Vinoth Rajagopal <vinoth124@xxxxxxxxx> wrote:


> 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.

-- 
MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com
--
To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Console]     [Linux Audio]     [Linux for Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Camping]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Samba]     [Linux Media]     [Fedora Users]

  Powered by Linux