Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FreeCOM environment-variable question

9 views
Skip to first unread message

commodorejohn

unread,
Jul 26, 2010, 4:50:51 PM7/26/10
to
I'm throwing together some .BAT files to simplify some common tasks on
my FreeDOS installation, and I'm having a little trouble. In the
modern Windows cmd.exe shell, you can use ~n with an environment
variable (i.e. a batch-file argument) to strip it of its extension:
referencing %~n1 in a batch file that was passed a name like
"example.txt" would simply reference "example", and it would be
possible to append a new extension. Is this possible in FreeCOM? For
example, I want to use this script:

ASM.BAT

@msa %1 -o%~n1.com

Which *should*, if passed EXAMPLE.ASM, work out to

@msa EXAMPLE.ASM -oEXAMPLE.COM

the proper command-line format for the MSA assembler. Unfortunately,
it doesn't recognize it as an environment variable at all, and comes
out like so:

@msa EXAMPLE.ASM -o~n1.COM

You can see the problem. Is there an alternative approach to stripping
the extension from a batch-file argument?

Esra Sdrawkcab

unread,
Jul 29, 2010, 3:12:57 AM7/29/10
to
On Mon, 26 Jul 2010 21:50:51 +0100, commodorejohn
<commod...@gmail.com> wrote:

> I'm throwing together some .BAT files to simplify some common tasks on
> my FreeDOS installation, and I'm having a little trouble. In the
> modern Windows cmd.exe shell, you can use ~n with an environment
> variable (i.e. a batch-file argument) to strip it of its extension:
> referencing %~n1 in a batch file that was passed a name like
> "example.txt" would simply reference "example", and it would be
> possible to append a new extension. Is this possible in FreeCOM? For
> example, I want to use this script:

environment variables (e.g. %name%) are different to batch arguments (e.g.
%1)


>
> ASM.BAT
>
> @msa %1 -o%~n1.com
>
> Which *should*, if passed EXAMPLE.ASM, work out to
>
> @msa EXAMPLE.ASM -oEXAMPLE.COM
>
> the proper command-line format for the MSA assembler. Unfortunately,
> it doesn't recognize it as an environment variable at all, and comes
> out like so:
>
> @msa EXAMPLE.ASM -o~n1.COM
>
> You can see the problem. Is there an alternative approach to stripping
> the extension from a batch-file argument?

Back in the day you'd probably require just the first part (name without
extension) so it'd be simply:

@msa %1.asm -o%1.com

use as "compile EXAMPLE"

but this won't work if passed a fullname from windows.

This code appears to be able to get the root name in W9x; it mighrt work
in Freedos.

http://www.ericphelps.com/batch/samples/rootname.bat.txt

--
"Nuns! NUNS! Reverse! Reverse!"

0 new messages