Please enable JavaScript to view this site.

A-Shell Consolidated Reference

Navigation: Command Files

Concatenate Parameters

Scroll Prev Top Next More

The DO file processor supports a mechanism for concatenating parameters on the command line before they are bound to the $0 thru $9 formal parameters. The syntax consists of prepending $+ to the start of a parameter that you want to combine with the prior parameter. For example, consider a generic dothis.do file consisting of the following command:

HOST $0 $1 $2 $3 $4 $5 $6 $7 $8 $9

If you executed it with:

.DOTHIS play ina $+gada $+davida real loud

The resulting host command would be:

play inagadadavida real loud

Note that "real" and "loud", which started out in positions $4 and $5, got shifted by the concatenation down to $2 and $3.

You can also use the $+ operator in the middle of an argument to avoid the argument renumbering problem just described, i.e.:

.DOTHIS play ina$+gada$+davida real loud

In this case, it is more clear that there are only 4 arguments ($0 thru $3) being passed to DOTHIS. This technique is mainly of interest in conjunction with $KBDn variables and the UCS/LCS functions where you may want to concatenate some folded keyboard input with a hardcoded value, and doing do so directly would interfere with the interpretation of the $KBDn and LCS() / UCS() syntax. For example:

:R

:<Enter command: >

:K0

:<Enter ini file: >

:K1

DOTHIS /vm/miame/bin/ $+LCS($KBD0) -i /vm/miame/ $+LCS($KBD1)

 

Assuming the user input "ASHELL" to the first prompt and "MIAME.INI" to the second, then the dothis.do file would execute:

HOST /vm/miame/bin/ashell -i /vm/miame/miame.ini

Without the concatenation, the user would have had to enter the entire paths or do without the LCS() function.

History

January 2005, A-Shell 4.9.910:  Function added to A-Shell.