Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done Just a Help addition - Alias name can use variables

Oct
364
17
No change to the code, but point out the following in the Help for Alias:

The Alias name can be contained in a variable:
Set AliasName=MyAlias
Alias %AliasName=Echo Hello

:: Will output: Echo Hello
Alias MyAlias​


Example use:

UNALIAS C_*​

:: bw and `%bw` avoid an irrelevant parameter-passing issue, where
:: if a GOSUB parameter contains spaces, even if it is in quotes or
:: back-apostrophes, TCC will treat text after the space as separate
:: parameter unless the variable-in-back-apostrophes approach is
:: used.

set bw=Bright white

GOSUB DCC C_MAIN Blue `%bw`
GOSUB DCC C_ERR Red `%bw`
GOSUB DCC C_EMPH Green `%bw`​
unset bw

C_MAIN
Echo This is the main color.

C_ERR
Echo Oops! -- Error!

C_EMPH
Echo Let me emphasize that!

C_MAIN
Echo Done!

QUIT

::******************************************************
:: DEFINE COLOR COMBINATIONS
:DCC [AliasName foreground background]
::
::******************************************************
Alias %AliasName=color %foreground on %background

RETURN
:: End of DCC [AliasName foreground background]
 
When I was writing the post I noticed that the thread title can be a bit misleading -- the Alias name cannot include a variable, but it can be stored in a variable.
 

Similar threads

Back
Top