How Do I Delete Lines From a Text File in DOS 7.1?

Dell / DIMENSION 2400
February 5, 2012 at 17:59:29
Specs: MS-DOS 7.10, Pentium 4 / 1GB
I have a text file with three lines. I want to create a new file (or modify the first) that only contains the third line.

I also want to remove the first 5 characters from the third line. Please help!

See More: How Do I Delete Lines From a Text File in DOS 7.1?

Report •

February 11, 2012 at 16:17:25
I found a solution through my own research:

STRINGS READ File1.txt,3 > File2.txt
ALTER File2.txt "%1 " ""

"%1" is the first 4 chracters of the line.

It would be nice to know how to remove the first N (unknown) characters, but that is not needed for this project. It would also be nice to know if this can be done without resorting to third party utilities like STRINGS.COM and ALTER.EXE.

Report •

February 12, 2012 at 06:02:13
If the old program debug is still around, you could use that to write a STRINGS.COM and/or ALTER.COM. That's the closest you're going to get with first party tools. We used to have a few guys who would know enough assembler to do that, but I don't know if any of them are around anymore.

How To Ask Questions The Smart Way

Report •

March 24, 2012 at 01:46:21
As luck would have it, STRINGS comes packaged with its own assembler source code. STRINGS.COM has a rather disturbing limitation. All of the string processing functions become unpredictable or worse when used on strings greater than 110 characters in length, which has left me scratching my head why someone would bother to create it this way. I have found workarounds, but it has been a pain. I notice at the beginning of the source code there is this:

RES_STACK	equ	offset end_of_resident+512
TRANS_STACK	equ	offset end_of_code+512
VAR_SIZE        equ     128                     ;Max size of variables
DATABUFF_SIZE   equ     2048                    ;Size of file data buffer
MAX_PARAMS	equ	10			;Max number of parameters
DEF_PARSE_CHAR	equ	","			;Default parse character

Could the solution to this dilemma be as simple as changing VAR_SIZE to 256 or 512? Please opine.

Report •

Related Solutions

March 24, 2012 at 15:39:39
This will work, but assumes that every file you process with this contains only 3 lines.

@echo off
for /f "tokens=* delims=" %%i in ('type myfile.txt') do set line=%%i
set line=%line:~5%
echo %line% > myfile.tx

Edit: Didn't realize this was for DOS 7.1, which I'm not sure has the /f switch with FOR.

Report •

March 25, 2012 at 00:14:04
Thanks tonysathre for the bit of code. I'm just beginning to learn the NT command language and every bit helps. As you suspect, MS-DOS does not support FOR /F, and I needed to do this in MS-DOS.

STRINGS is a fantastic free program with some very wierd restrictions that I just can't wrap my head around. I can use STRINGS in MS-DOS batch files, but not from the command line. I can use STRINGS from the NT command line (except it won't assign variables) but not in NT batch files. Then there is the ridiculous 110 character restriction which is even more severe in NT.

I probably have a copy of MASM 2.0 for DOS sitting around here somewhere, but wondering if I can use Microsoft MASM 8.0 to assemble the MS-DOS binaries. Any opinions on what can be done to enhance STRINGS.COM are greatly appreciated.

Report •

March 25, 2012 at 07:42:23
Instead of MASM you could you use the built in DEBUG assembler.


Report •

Ask Question