// // ProjFill.vdm Christian Ziemski 27.02.2003 // 28.02.2003 // // // Fill the currently open project with all files from a directory; // optionally with subdirectories. // (*.bak files are ignored) // // // Register usage: // // #94 flag for subdirectory inclusion // #95 temp // // $94 directory to be listed // $95 message text in DI1() // $96 message text in DI1() // $99 temp // // //============================================================================== // // To do: Some more error checking // ... // //============================================================================== Num_Push(94,95) // Save locally used numeric registers Reg_Push(94,99) // Save locally used text registers Reg_Set(97, PROJ_CURRENT) if (Reg_Size(97) == 0) { // If no project open Dialog_Input_1(94,"`ProjFill: Error`, `There is no project open! Please open a project before executing this macro.`, `[&OK]`", APP+CENTER,0,0) Goto EXIT } Buf_Switch(Buf_Free) Reg_Ins(97) Search("\", REVERSE+ADVANCE) Del_Line(0) Replace(".prj", "") Reg_Copy_Block(97, 0, File_Size) Buf_Quit(OK) // Create (VEDIT_TEMP) temp directory, if necessary. // if (File_Exist(VEDIT_TEMP)==0) { File_Mkdir(VEDIT_TEMP) } // // Prompt for directory. // #94=0 Reg_Set(94, CUR_DIR) Reg_Set(94, "\*.*", APPEND) Reg_Set(95,"Enter the pathname of the directory and optional wildcard: ") Reg_Empty(96) if (OS_TYPE==1) { repeat (ALL) { // LOOP until valid directory #95=Dialog_Input_1(94,"`Fill project '|@(97)' with files`, `|@(96)|@(95)`, `??`, `[] Include &subdirectories`, `[&OK]`,`[&Cancel]`", @94,APP+CENTER,0,0) if ((#95==0) || (#95==2)) { Goto Exit } Reg_Set(96,"Directory invalid or doesn't exist. Try again.\n\n") if (Reg_Size(94) < 2) { continue } if (File_Exist(@94,NOERR)) { Break } } } else { repeat (ALL) { // LOOP until valid directory Get_Input(94,@(95),@(94),NOCR) if (File_Exist(@94,NOERR)) { Break } Message("Directory not found. Try again.\n") } if ( Get_Key("subdirectories too? (y/n) ") == 'y') { #94 = 1 } } Buf_Switch(Buf_Free) File_Save_As("|(VEDIT_TEMP)/projfill.tmp", OK) // get the directory listing Out_Ins() if (#94) { Directory('"|@(94)" -s', SUPPRESS+COUNT ,1) } else { Directory("|@(94)", SUPPRESS+COUNT ,1) } Out_Ins(CLEAR) Replace("|<|N", "", BEGIN+ALL+NOERR) // Remove empty lines Replace("|<|*.bak|N", BEGIN+ALL+NOERR) // Remove .BAK files // build a list of complete file names inclusive path BoF Reg_Empty(99) while (! AT_EoF) { if (Match("|