Util to allow arithmetic operations in MS-DOS scripts?

Getting old software/games running on older hardware.

Util to allow arithmetic operations in MS-DOS scripts?

Postby Rekrul » 2019-10-12 @ 01:29

In Windows batch scripts, you can perform arithmetic operations with SET /A x=x+1, but that dosn't work in MS-DOS.

Is there any third-party utility that can be used to perform basic arithmetic operations in an MS-DOS script?

So far all the programs I've found haven't worked with variables. I did find one, eval100.zip;

https://www.sac.sk/files.php?d=16&p=28

That claims it can modify variables, but naturally it gives absolutely no examples of its usage and I'll be damned if I can figure out how to make it work.

I tried Googling, but that's greatly complicated by the fact that the entire world seems to think that the command prompt in Windows is MS-DOS. :angry:

I could accomplish the same thing with a ton of IF statements, but I was hoping to find something more elegant.
Rekrul
Member
 
Posts: 344
Joined: 2005-2-10 @ 23:14

Re: Util to allow arithmetic operations in MS-DOS scripts?

Postby Errius » 2019-10-12 @ 02:10

What exactly are you trying to do? How are you planning to use variables in your script?
"EA simply loved Syndicate so much they did it IRL."
User avatar
Errius
Oldbie
 
Posts: 1484
Joined: 2015-12-16 @ 19:16
Location: Lave Station


Re: Util to allow arithmetic operations in MS-DOS scripts?

Postby BinaryDemon » 2019-10-12 @ 05:33

From what I read 'xset' would work, but I've never tried it. I've also used a ton of IF statements on occasion but it usually gets the the point where you ask yourself, why am I doing this in BATCH when I could be using QBASIC or an even more complex language.
Check out DOSBox Distro:

https://sites.google.com/site/dosboxdistro/ [*]

a lightweight Linux distro (tinycore) which boots off a usb flash drive and goes straight to DOSBox.

Make your dos retrogaming experience portable!
BinaryDemon
Member
 
Posts: 377
Joined: 2018-1-17 @ 00:35

Re: Util to allow arithmetic operations in MS-DOS scripts?

Postby derSammler » 2019-10-12 @ 07:21

Just use QBASIC, which is included with DOS.
derSammler
l33t
 
Posts: 2353
Joined: 2017-4-14 @ 11:30
Location: Germany

Re: Util to allow arithmetic operations in MS-DOS scripts?

Postby Rekrul » 2019-10-12 @ 11:09

Errius wrote:What exactly are you trying to do? How are you planning to use variables in your script?

At the moment I'm only planning to use one variable and it's going to be in the autoexec portion of the DOSBox configuration files.

I like to make up custom config files for each game that have a menu allowing you to boot the game, run the game's setup and change various options. For example, my menu for the Redneck Rampage games allows you to boot any of the three games (the original, Rides Again and Route 66), run the setup (settings are then copied to all three games), enable/disable the CD music and enable/disable the Cusspack.

Something I've wanted to do for a while now is add an option to adjust the volume of the CD music, since the in-game volume options don't work. Recent testing shows that the DOSBox Mixer command will accept a variable, so I just needed a way to increase or decrease the value of that variable. If xset works the way it says, I can just add a small routine to increase or decrease the variable when the proper menu key is pressed (with a min/max check so that it rolls over at each extreme). This way I don't need to edit the config file if I want to change the volume setting.

BinaryDemon wrote:From what I read 'xset' would work, but I've never tried it.

Thanks, from reading the docs, xset looks like exactly what I was looking for!

BinaryDemon wrote:I've also used a ton of IF statements on occasion but it usually gets the the point where you ask yourself, why am I doing this in BATCH when I could be using QBASIC or an even more complex language.

As above I need to put it in the DOSBox config file. It runs all other DOS commands and external programs, so I'm hoping that it will also work with a program like xset. If it doesn't, then nothing will and I'll have to do it the long way.

Thanks again. :)
Rekrul
Member
 
Posts: 344
Joined: 2005-2-10 @ 23:14

Re: Util to allow arithmetic operations in MS-DOS scripts?

Postby Rekrul » 2019-10-13 @ 23:15

I'm happy to report that xset works perfectly and does exactly what I wanted. It even allows setting the contents of a variable from a file (xset variable < file.txt), so I can have my configuration store the volume setting to a file and have it persist between sessions.

Thanks again! :)
Rekrul
Member
 
Posts: 344
Joined: 2005-2-10 @ 23:14


Return to Software

Who is online

Users browsing this forum: derSammler and 0 guests