Difference between revisions of "Env"
(→Mini Micro: + shell) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
| importPaths || [[list]] of directories searched for [[import]] modules | | importPaths || [[list]] of directories searched for [[import]] modules | ||
|- | |- | ||
− | | prompt || [[string]] | + | | prompt || [[string]] or [[function]] to use as the command-line prompt |
|- | |- | ||
− | | morePrompt || [[string]] | + | | morePrompt || [[string]] or [[function]] to use as the prompt when more input is needed |
+ | |- | ||
+ | | shell || path to the current [[Env.shell|shell]] program (<c>""</c> for the default Mini Micro shell) | ||
|} | |} | ||
Line 37: | Line 39: | ||
| MS_EXE_DIR || Launch directory ||Returns the directory ([[String]]) of which the miniscript.exe was launched from | | 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" || | + | | 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 | | HOMEPATH || User home || Returns the home Directory ([[String]]) of the user that had launched miniscript.exe | ||
|} | |} | ||
− | === Linux === | + | === Linux Version=== |
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 50: | Line 52: | ||
== Useful tips == | == Useful tips == | ||
− | === Adding more import paths (Windows) === | + | === 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|env]].MS_IMPORT_PATH like below: | 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|env]].MS_IMPORT_PATH like below: | ||
Latest revision as of 08:12, 18 February 2024
env
is a built-in map in both Mini Micro and command-line MiniScript. It has somewhat different meaning and usage in each environment.
Contents
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 or function to use as the command-line prompt |
morePrompt | string or function to use as the prompt when more input is needed |
shell | path to the current shell program ("" for the default Mini Micro shell)
|
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