home *** CD-ROM | disk | FTP | other *** search
- Macro_File 4Dos;
-
- /***************************************************************************
- *
- * ME file description support for 4Dos.
- *
- * -----------
- * 12/01/1991: -written by norm walsh (Small Planet
- * Software)
- *
- * You are free to do whatever you want to this code
- *
- * 12/07/1991: - disabled backup of DESCRIPT.ION in SetCurDesc [MRB]
- * 12/07/1991: - prohibited creating an entry for non-existent files [MRB]
- * 01/09/1992: - added FileMngr compatibility from code by Dick Botbyl
- * allow deletion of DESCRIPT.ION entries
- * 01/11/1992: - added DIck Botbyls's ShowDescriptions macro
- *
- * Usage:
- *
- * RM('4Dos^EditDescription') to edit the file description for the "current"
- * file. This macro handles non-existent DESCRIPT.ION files and new files
- * (files that aren't in the DESCRIPT.ION file yet) as well as old files.
- *
- * RM('4Dos^Running4DOS') sets Return_Int to the version number*100
- * (i.e. version 3.02 -> 302) of 4Dos or 0 if 4Dos is not running.
- *
- * RM('4Dos^ShowDescriptions') Shows current directory files with
- * 4Dos descriptions - Dick Botbyl 1992
- *
- **************************************************************************/
-
- Macro EditDescription
- {
- Str Fn[81],Fpath[65],Fname[12];
- /* enable this macro in the File Manager */
- If( mode == dos_shell ) {
- Fn = Caps(Dir_Entry);
- } Else {
- Fn = Caps(File_Name);
- /* Note: in File mode, this macro allows editing of a
- description for the parent directory entry ("..")
- which will not be directly accessible with 4DOS
- and will not appear in the parent directory itself.
- */
- };
- /* */
- Fpath = Get_Path(Fn);
- Fname = Copy(Fn,Svl(Fpath)+1,12);
-
- Int back_mode;
-
- If( File_Exists(Fexpand(Fn)) ) {
- RM('4Dos^GetCurDesc');
- Set_Global_Str('IPARM_1','/T=Enter Description for '+Fname+':/C=2/L=2/TP=10/ATTR='+Str(M_S_COLOR));
- Set_Global_Str('IPARM_2','/C=1/L=3/W=40/ML=40');
- Set_Global_Str('ISTR_2',Return_Str);
- RM('DATA_IN /S=2/#=2/Y=5/W=45/T= 4DOS File Description ');
- If (Return_Int) {
- RM('4Dos^SetCurDesc /D='+Global_Str('ISTR_2'));
- }
- } else {
- RM('MEERROR^MESSAGEBOX /T= 4DOS File Description /M= '+Fexpand(Fn)+' does not exist /B=1/NW=0');
- }
- };
-
- macro GetCurDesc;
- {
- Str Fn[81],Fpath[65],Fname[12];
- Int SaveRefresh,SaveRegExp,CurWinId,Place;
- Str Description[64];
-
- /* enable this macro in the File Manager */
- If( mode == Dos_Shell ) {
- Fn = Caps(Dir_Entry);
- } Else {
- Fn = Caps(File_Name);
- };
- /* */
- Fpath = Get_Path(Fn);
- Fname = Copy(Fn,Svl(Fpath)+1,12);
-
- Fn = Fpath + 'DESCRIPT.ION';
- CurWinId = Window_Id;
- SaveRefresh = Refresh;
- SaveRegExp = Reg_Exp_Stat;
- Refresh = False;
- Reg_Exp_Stat = True;
- Create_Window;
- Load_File(Fn);
- If( Error_Level == 0 ) {
- If( Search_Fwd('%'+Fname,0) ) {
- Description = Get_Line;
- Place = XPos(' ',Description,1);
- Description = Copy(Description,Place+1,40);
- } Else {
- Description = "";
- }
- }
- Delete_Window;
- Switch_Win_Id(CurWinId);
- Error_Level = 0;
-
- Refresh = SaveRefresh;
- Reg_Exp_Stat = SaveRegExp;
- Return_Str = Description;
- }
-
- Macro SetCurDesc;
- {
- Str Fn[81],Fpath[65],Fname[12];
- Int SaveRefresh,SaveRegExp,SaveIns,CurWinId,Place,IsNew,SaveBackups;
- Str Description[64],Line;
-
- Description = Copy(Parse_Str('/D=',MParm_Str),1,40);
-
- /* enable this macro in the File Manager */
- If( mode == dos_shell ) {
- Fn = Caps(Dir_Entry);
- } else {
- Fn = Caps(File_Name);
- };
- /* */
- Fpath = Get_Path(Fn);
- Fname = Copy(Fn,Svl(Fpath)+1,12);
-
- Fn = Fpath + 'DESCRIPT.ION';
-
- CurWinId = Window_Id;
- SaveRefresh = Refresh;
- SaveRegExp = Reg_Exp_Stat;
- SaveIns = Insert_Mode;
- Refresh = False;
- Reg_Exp_Stat = True;
- Insert_Mode = True;
- Create_Window;
- Load_File(Fn);
- If( Error_Level == 0 ) {
- IsNew = False;
- If (Search_Fwd('%'+Fname,0)) {
- Line = Get_Line;
- If( Description == '' ) {
- Del_Line;
- } else {
- Place = XPos(' ',Line,1);
- Line = Copy(Line,1,Place-1)+' '+Description;
- Put_Line(Line);
- };
- } else {
- If( Description != '' ) {
- Line = Fname + ' ' + Description;
- Text(Line); Cr;
- }
- }
- } else {
- If( Description != '' ) {
- IsNew = True;
- File_Name = Fn;
- Line = Fname + ' ' + Description;
- Text(Line); Cr;
- Error_Level = 0;
- }
- }
- /* temporarily disable backups and save DESCRIPT.ION */
- SaveBackups = Backups;
- Backups = 0;
- Save_File;
- If(Error_Level != 0 ) {
- RM('MEERROR');
- }
- If( Cur_File_Size == 0 ) {
- Del_File(File_Name);
- }
- If( Error_Level != 0 ) {
- RM('MEERROR');
- }
- Backups = SaveBackups;
- /* */
-
- Delete_Window;
- Switch_Win_Id(CurWinId);
-
- If( IsNew ) {
- Set_File_Attr(Fn,0x02);
- If( Error_Level != 0 ) {
- RM('MEERROR');
- }
- }
-
- Refresh = SaveRefresh;
- Reg_Exp_Stat = SaveRegExp;
- Insert_Mode = SaveIns;
- }
-
- Macro Running4DOS;
- {
- Return_Int = 0;
-
- R_AX = 0x352F;
- Intr(0x21); /* Call DOS: Get Interrupt Vector */
-
- If( (R_ES == 0) && (R_BX == 0) ) {
- Goto Exit;
- }
-
- R_AX = 0xD44D; /* use 0xE44D for NDOS */
- R_BX = 0x0000;
- Intr(0x2F);
-
- If( R_AX == 0x44DD ) { /* 4Dos is loaded */ /* 44EE for NDOS */
- Return_Int = 100*(R_BX & 0x00FF) + (R_BX >> 8);
- }
-
- Exit:
- }
-
- Macro ShowDescriptions
- /**********************************************************
- assign this macro to ME File Manager keymap
- shows current directory files with 4Dos descriptions
- links to 4DOS^EditDescription
-
- Dick Botbyl 01-11-92 03:13pm (see disclaimer below)
-
-
- The "NON-PROGRAMMER" disclaimer
-
- I know the code is very crude
- just chunks pieced and glued.
- Some may even call it sloppy
- and yes it looks a little choppy.
-
- This little gem has been run and rerun
- But now I think I have it done.
- When it is time to do the work,
- it runs with only an occasional quirk.
-
- Please give these lines a real try.
- Tell me where the errors lie.
- The outcome of your final critique
- may be that my skills are really weak.
-
- Since this is not my livelihood,
- It shouldn't be considered bad or good.
- Again and again, I will stammer
- "This is the work of a 'NON-PROGRAMMER'"
-
- Some will be heard to mutter
- "I can do it much, much better."
- What I did here was only to suggest
- and allow a rewrite by the best.
-
- Please remember that inspiration
- can count as much as perspiration!
- So tell them all to plagiarize
- We'll know where the credit lies.
-
- * REB 1992 *
-
- ***********************************************************/
-
- {
-
- Str Fn[81],Fpath[65],Fname[12];
- str Temp_Str[64],Description[64], Tstr[14];
- Int CurWinId,Place,Re_Int;
- Int S_R,Back_Mode, Dir_Done, Dline;
-
- /* Added 01-Jan-91 - MRB */
- If( Mode != Dos_Shell) {
- Beep;
- Make_Message('Sorry, this macro is only usable in the File Manager');
- Goto End_Macro;
- }
-
- ToTop: /* Go to the top of the DIR listing */
-
- Make_Message('Reading Descriptions ...');
- SAVE_BOX(1,1,Screen_Width, Screen_Length);
- S_R = Status_Row;
- Status_Row = 0;
- Re_Int = 0;
- Push_Labels;
- Refresh = False;
- CurWinId = Window_Id;
- Dir_Done = 0;
- Dline = 1;
- While( DIR_NUM > 1 ) {
- Dos_Left;
- Dline = Dline + 1;
- }
- Create_Window;
- While( Dir_Done < Dir_Total ) {
- Dir_Done = Dir_Done + 1;
- Fn = Lower(Dir_Entry);
- Fpath = Get_Path(Fn);
- Fname = Copy(Fn,Svl(Fpath)+1,12);
- Fn = Fpath + 'DESCRIPT.ION';
- Load_File(Fn);
- If( Error_Level == 0 ) {
- If( Search_Fwd('%'+Fname,0) ) {
- Description = Get_Line;
- Place = XPos(' ',Description,1);
- Description = Copy(Description,Place+1,40);
- } Else {
- Description = "";
- }
- }
- If( Dos_File_Attr == $10 ) {
- Temp_Str = Fname + Copy( ' ', 1, 12 - Svl(Fname)) + '<DIR>' + Description + ' ';
- } Else {
- Temp_Str = Fname + Copy( ' ', 1, 12 - Svl(Fname)) + ' ' + Description + ' ';
- }
- Set_Global_Str('4ISTR_' + Str(Dir_Done), Temp_Str );
- Dos_Right;
- }
- Delete_Window;
- Create_Window;
- Dir_Done = 1;
- While( Dir_Done < Dir_Total ) {
- Dir_Done = Dir_Done + 1;
- Put_Line(Global_Str('4ISTR_' + Str(Dir_Done)));
- Down;
- }
- Tof;
- Make_Message('');
- Set_Global_Str('B4IPARM_1', '/HT=' + Str(Screen_Length - 9) + '/TP=15/C=1/W=56/L=1/WIN=' + Str(Cur_Window) );
- RM('USERIN^DATA_IN /DBM=0/HT=' + Str(Screen_Length - 4) + '/#=1/X=2/y=2/NK=1/A=2/ABT=Edit/CBT=Done/T='+Caps(Fpath)+'/A=1/#=' + str(Dir_Done) + '/PRE=B4');
- Error_Level = 0;
- Re_int = Return_Int;
- Temp_Str = Copy(Get_Line, 1, 24);
- Place = XPos(' ',Temp_Str,1);
- Temp_Str = Copy(Temp_Str, 1, Place -1);
- Delete_Window;
- If (re_int) {
- While( Dir_Num > 1 ) Dos_Left;
- While( Dir_Num < Dir_Total ) {
- Fn = Lower(Dir_Entry);
- Fpath = Get_Path(Fn);
- Fname = Copy(Fn,Svl(Fpath)+1,12);
- If(Fname == Temp_Str) RM('4dos^EditDescription');
- Dos_Right;
- }
- If( Re_Int) {
- If( Fname == Temp_Str) {
- RM('4dos^EditDescription');
- }
- }
- }
- Dir_Done = 0;
- While( Dir_Num > 1 ) Dos_Left;
- While( Dir_Num < Dline ) Dos_Right;
- While( Dir_Done < Dir_Total ) {
- Dir_Done = Dir_Done + 1;
- Set_Global_Str('4istr_' + Str(Dir_Done), '' );
- }
- Set_Global_Str('4iparm_1', '' );
-
- Switch_Win_Id(CurWinId);
- Refresh = True;
- Restore_Box;
- Update_Dir;
- Pop_Labels;
- Status_Row = S_R;
- If( Re_Int ) Goto Totop;
-
- End_macro:
- }
-
-