Legacy Plugin Collection

envvars

Inserts environment variables into source files.

Remarks

Brass 1 would perform a replacement of everything inside [%tags%] with the corresponding environment variable. Brass 3's parser doesn't support environment variable substitution, so this plugin tries to help port over old source code.

This plugin registers macros before assembling that will replace environment variables matching "[%key%]" with the corresponding values.

The macro preprocessor deals with individual tokens, and so can't perform substitution on environment variables not declared as a string.

If you need to pass a numeric value to your source code via an environment variable, use the eval() function.

Warning

You can only insert environment variables into strings. Use eval() to evaluate a passed string into a numeric value.

Example

Porting Brass 1 code to Brass 3

/* The following definitions are required */

None     = 0 ; No shell - All
Ion      = 1 ; Ion      - 83, 83+
MirageOS = 2 ; MirageOS - 83+
Venus    = 3 ; Venus    - 83

TI8X     = 1 ; TI-83 Plus
TI83     = 2 ; TI-83

/*
The build script passes in a value for 
SHELL and PLATFORM. We need these to be
numeric values. The Brass 1 source code
was as follows:

Shell    = [%SHELL%]
Platform = [%PLATFORM%]

This will not work in Brass 3!
The following code demonstrates a way to
work around Brass 3's stricter parser.
*/

Shell    = eval("[%SHELL%]")
Platform = eval("[%PLATFORM%]")

/*
The following used a string anyway, so
no code needed to be changed.
There is no functional difference between
[%var%] and [%$var$%].
*/

.if Shell != None
    .db "[%$PROJECT_NAME$%]", 0
.endif

See Also