// -*- Mode: Eagle -*- string FILENAME_SUBS; // // Values to substitute in file names. // string setup_subs_side_phase(int l_side, int l_phase) { string side; string file; string tmp; int i; side = (l_side == TOP) ? TOP_FILE_NAME : BOT_FILE_NAME; switch (l_phase) { case PH_TOP_OUT_GEN: case PH_TOP_OUT_WRITE: case PH_BOTTOM_OUT_GEN: case PH_BOTTOM_OUT_WRITE: file = ETCH_FILE_NAME; break; case PH_TOP_DRILL: case PH_BOTTOM_DRILL: file = DRILL_FILE_NAME; break; case PH_MILL: file = MILL_FILE_NAME; break; case PH_TEXT: file = TEXT_FILE_NAME; break; default: file = "invalid"; } // dlgMessageBox("file = " + ETCH_FILE_NAME); // file = PHASE_NAME[l_phase]; FILENAME_SUBS = ""; i = 0; while (path_epf[i] != "") { sprintf(tmp, "$PROJECT_PATH[%d]", i); FILENAME_SUBS += key_value_record(tmp, remove_last_slash(path_epf[i])); sprintf(tmp, "$ULP_PATH[%d]", i); FILENAME_SUBS += key_value_record(tmp, remove_last_slash(path_ulp[i])); sprintf(tmp, "$CAM_PATH[%d]", i); FILENAME_SUBS += key_value_record(tmp, remove_last_slash(path_cam[i])); i++; } FILENAME_SUBS += key_value_record("$PATH", remove_last_slash(g_path)) + key_value_record("$BOARD_PATH", remove_last_slash(filedir(BOARD_NAME))) + key_value_record("$BOARD_NAME", filesetext(filename(BOARD_NAME), "")) + key_value_record("$BOARD_FILE_PATH", filesetext(BOARD_NAME, "")) + key_value_record("$SIDE", side) + key_value_record("$FILE", file) + key_value_record("$EXT", DEFAULT_EXTENSION) ; return FILENAME_SUBS; } string filename_subs_help() { return "

Filename Variables

" "" "" "" "" "" "" "" "" "" "" "" "" "" "
$PROJECT_PATH[n]Project paths as set in the Control Panel. " "n begins at zero for the first entry.
$ULP_PATH[n]As above, but for User Language Program paths.
$CAM_PATH[n]As above, but for CAM Jobs paths.
$BOARD_PATHPath to the board file.
$BOARD_NAMEThe file name of the board with the extension (.brd) removed.
$BOARD_FILE_PATHPath and name of the board with the extension (.brd) removed.
$SIDESide of the board being generated. By default 'bot' or 'top'.
$FILEFile of the board being generated. By default 'etch', 'drill' and 'mill' or 'text'.
$EXTThe extension you set under the GCode Options tab.
" "Paths do not end with a /.
" "Example:
" "Assume the board we are working on is:
" "/home/john/eagle/my_stuff/enabtmr.brd
" "and we use these settings:
" "Filename Base: $BOARD_PATH/$BOARD_NAME
" "Top (Component) Side Files" "" "" "" "" "" "
Etching: .$SIDE.$FILE.$EXT
Drill: .$SIDE.$FILE.$EXT
Mill: /mill_jobs/$BOARD_NAME.$SIDE.$FILE.tap
Text: $SIDE.$FILE.tap
" "Would create the following filenames:
" "" "" "" "" "" "
Etching: /home/john/eagle/my_stuff/enabtmr.top.etch.nc
Drill: /home/john/eagle/my_stuff/enabtmr.top.drill.nc
Mill: /home/john/eagle/my_stuff/enabtmr/mill_jobs/enabtmr.top.mill.tap
Drill: /home/john/eagle/my_stuff/enabtmr.top.text.nc
" ; } string setup_subs() { return setup_subs_side_phase(g_side, g_phase); } string sub_side_phase(string s, int side, int phase) { if (phase == 0) dlgMessageBox("phase == 0"); setup_subs_side_phase(side, phase); return substitute(s, FILENAME_SUBS); } string get_filename() { string name; setup_subs(); if (g_side == TOP) { switch(g_phase) { case PH_TOP_OUT_GEN: case PH_TOP_OUT_WRITE: name = FILENAME_TOP_ETCH_FILE; break; case PH_TOP_DRILL: name = FILENAME_TOP_DRILL_FILE; break; case PH_MILL: name = FILENAME_TOP_MILL_FILE; break; case PH_TEXT: name = FILENAME_TOP_TEXT_FILE; break; } } else { switch(g_phase) { case PH_BOTTOM_OUT_GEN: case PH_BOTTOM_OUT_WRITE: name = FILENAME_BOT_ETCH_FILE; break; case PH_BOTTOM_DRILL: name = FILENAME_BOT_DRILL_FILE; break; case PH_MILL: name = FILENAME_BOT_MILL_FILE; break; case PH_TEXT: name = FILENAME_BOT_TEXT_FILE; break; } } return substitute(FILENAME_BASE + name, FILENAME_SUBS); } setup_subs(); string sub_path(string name) { return substitute(name, FILENAME_SUBS); }