Env

From MiniScript Wiki
Jump to navigation Jump to search

env is a built-in map in both Mini Micro and command-line MiniScript. It has somewhat different meaning and usage in each environment.

Mini Micro

In Mini Micro, env refers to a map of special values that affect the Mini Micro environment. It contains at least the following keys:

Key Meaning
bootOpts a complete copy of the data in the bootOpts.grfon file
curdir current working directory (same as pwd)
cmdLine command line command that was used to launch Mini Micro (where applicable)
cmdLineArgs command line arguments (as a list) used when Mini Micro was launched (where applicable)
importPaths list of directories searched for import modules
prompt string printed as the command-line prompt
morePrompt string printed as the prompt when more input is needed

Command-Line MiniScript

In command-line MiniScript, env is a copy of the shell environment variables. Assignments to entries of env add or update environment variables. (Deleting environment variables is not possible; you may delete from the env map, but this does not actually affect the environment.)

The exact meaning of environment variables varies with the platform. They have many uses, such as in CGI scripts.

Windows Version

Key Default Meaning
MS_EXE_DIR Launch directory Returns the directory (String) of which the miniscript.exe was launched from
MS_IMPORT_PATH "$MS_SCRIPT_DIR/lib:$MS_EXE_DIR/lib" directory listings (String) of where MiniScript files are located allowing Import to search in those for file import.
HOMEPATH User home Returns the home Directory (String) of the user that had launched miniscript.exe

Linux Version

Key Default Meaning

Useful tips

Adding more import paths (Windows Command Line)

To add more folders to Import from, alter or add the path with a dollar sign ($) to the beginning of $MS_SCRIPT_DIR or $MS_EXE_DIR String text with a forward slash (/) before the folder name like so: $MS_SCRIPT_DIR/sprites. To add multiple paths for import simply add a colon (:) between the designated paths to indicate multiple directories to import from. Apply the string to the env.MS_IMPORT_PATH like below:

 env.MS_IMPORT_PATH = "$MS_SCRIPT_DIR/sprites" // replaces the default with one folder named sprites
 env.MS_IMPORT_PATH = "$MS_SCRIPT_DIR/lib:$MS_EXE_DIR/lib:$MS_SCRIPT_DIR/sprites" // default plus new folder sprites