Datamine Macro Language — VS Code Extension
Full language support for Datamine Studio macro files (.mac).
Features
Syntax Highlighting
- ✅ Control commands (
!START, !END, !IF, !ELSE, !GOTO, !LET, etc.)
- ✅ File parameters (
&in(), &out(), &in1())
- ✅ Field parameters (
*field())
- ✅ Numeric/option parameters (
@param=value)
- ✅ Substitution variables (
$varname#)
- ✅ Jump labels (
MYLABEL:)
- ✅ Comments (
# and !REM)
- ✅ Process names (
!SELCOP, !ESTIMA, etc.)
Snippets — Control Commands
All macro control commands with proper syntax:
| Prefix |
Command |
Description |
!START |
!START / !END |
Macro block |
!IF |
!IF one-line |
Conditional branch |
!IFb |
!IF/!ELSEIF/!ELSE/!ENDIF |
Block IF |
!LET |
!LET $var# = value |
Variable assignment |
!LETa |
!LET with arithmetic |
Variable arithmetic |
!GOTO |
!GOTO LABEL |
Unconditional jump |
!GOSUB |
!GOSUB / !RETURN |
Subroutine call |
!ONERR |
!ONERR LABEL |
Error handler |
!ECHO |
!ECHO 'msg' |
Display message |
!RUNPROG |
!RUNPROG 'exe' |
Run external program |
!XRUN |
!XRUN 'macro.mac' |
Run another macro |
!FILE |
!FILE &in() |
Check file exists |
!FIELD |
!FIELD &in() *field() |
Check field exists |
!VARSAVE / !VARLOAD |
Variable persistence |
Save/load variables |
!SCROFF / !SCRON |
Output redirection |
Capture output to file |
macrotemplate |
Full template |
Complete macro with header, checks, error handler |
loopcount |
Loop template |
Counter-based loop pattern |
Snippets — Processes (267 processes)
All major Datamine Studio processes: !SELCOP, !ESTIMA, !DESURV, !EXTRA, !PICREC, !MGSORT, and many more.
Installation
From VSIX (manual)
code --install-extension datamine-macro-1.0.0.vsix
Development
git clone https://github.com/YOUR_USERNAME/vscode-datamine-macro
cd vscode-datamine-macro
# Press F5 in VS Code to launch Extension Development Host
Syntax Reference
Variables
!LET $counter# = 0
!LET $result# = $counter# + 1
File/Field/Option parameters
!SELCOP &in(drillholes),&out(output),
*f1(BHID),*f2(FROM),*f3(TO),
@keepall=0
Labels and branching
!IF $count# GE 10 !GOTO LOOP_END
LOOP_START:
...
!GOTO LOOP_START
LOOP_END:
Error handling
!ONERR ERR_LABEL
!FILE &in(myfile) !GOTO FILE_OK
!ECHO 'File not found'
!GOTO FINISH
FILE_OK:
# ... process ...
FINISH:
ERR_LABEL:
!ECHO 'Fatal error occurred'
Based on
Original work by opengeostat/vscode-dm-macro (MIT License).
Extended with full control command support, improved grammar, and additional snippets.
License
MIT