Due to very old hardware I'm forced to run Windows 3.1 that controls the plotter. The software I'm using creates a .bat file with this line in it:
SPLOT.EXE/fmyfile.uc c:\myfile.plt
the /f - is a switch that follows by filename for the converted output file.
The problem comes when filename starts with number 1 or 2, then the splot.exe tries to output on COM1 or COM2 ports instead of creating a .uc file.
Since I have no control on how this .bat file created my only solution is to create my own splot.exe file as a "loader", which will execute original splot.exe (I renamed it to splotOrg.exe) with temporary filename, then rename that temp file into proper filename.
So I come up with the following .bat file which later I converted into .exe with Advanced BAT to EXE Converter:
@echo off
set str=%1
splotOrg.exe/ftempfile %2
ren tempfile %str:~2%
This worked great from Windows 7 CMD window, but when I executed it from true MSDOS 4.0 it failed. Turned out that %str:~2% that supposed to trim out first 2 characters from %str% variable works only with windows 98+ extensions, or something in that nature.
Unfortunately I don't know any low-level programming languages, therefore I'm limited to simple scripting languages.
Can someone suggest how can I create an .exe file for MSDOS 4.0 which will do the following:
- accept two command line arguments, separated by a space, lets
call them $arg1 and $arg2 - execute:
splotOrg.exe/ftempfile $arg2
- trim out /f from $arg1, so /fmyfile.uc become myfile.uc
- rename tempfile into new $arg1 name
Answer
You mention using Advanced BAT to EXE Converter. According to that website, the executables "Executables compiled with Advanced BAT to EXE Converter will run on all Windows versions from Windows98 to Win8.1 64bit." It doesn't say MS-DOS 4.0
A solution is available by using JP Software's 4DOS. Just about any version will likely do, but you may as well grab the latest, "Free 4DOS" from 4DOS site.
You can probably get away with:ren *.* tempfile
Otherwise, if that doesn't work for some reason, you ought to be able to do things the long way, which is to trim away the undesirable characters using %@instr[] (See: JP Software for @Instr. e.g., %@instr[2,%@len[%2],%2]
) (or, for older 4DOS versions, %@substr[].) You ought to do fine as long as you don't have commas in the filenames (which are not commonly used/supported in filenames in MS-DOS anyway).
If your converted-to-exe batch files don't accept 4DOS extensions, then just have them run: 4DOS.Com/C mybatch.btm %1 %2
No comments:
Post a Comment