home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 199 / ME4DOS.ZIP / 4DOS.S
Encoding:
Text File  |  1992-01-12  |  9.5 KB  |  370 lines

  1. Macro_File 4Dos;
  2.  
  3. /***************************************************************************
  4.  *
  5.  *  ME file description support for 4Dos.
  6.  *
  7.  *  -----------
  8.  *  12/01/1991: -written by norm walsh (Small Planet
  9.  *               Software)
  10.  *
  11.  *  You are free to do whatever you want to this code
  12.  *
  13.  *  12/07/1991: - disabled backup of DESCRIPT.ION in SetCurDesc [MRB]
  14.  *  12/07/1991: - prohibited creating an entry for non-existent files [MRB]
  15.  *  01/09/1992: - added FileMngr compatibility from code by Dick Botbyl
  16.  *                allow deletion of DESCRIPT.ION entries
  17.  *  01/11/1992: - added DIck Botbyls's ShowDescriptions macro
  18.  *
  19.  *  Usage:
  20.  *
  21.  *  RM('4Dos^EditDescription') to edit the file description for the "current"
  22.  *  file.  This macro handles non-existent DESCRIPT.ION files and new files
  23.  *  (files that aren't in the DESCRIPT.ION file yet) as well as old files.
  24.  *
  25.  *  RM('4Dos^Running4DOS') sets Return_Int to the version number*100
  26.  *  (i.e. version 3.02 -> 302) of 4Dos or 0 if 4Dos is not running.
  27.  *
  28.  *  RM('4Dos^ShowDescriptions') Shows current directory files with
  29.  *  4Dos descriptions - Dick Botbyl 1992
  30.  *
  31.  **************************************************************************/
  32.  
  33. Macro EditDescription
  34. {
  35.   Str Fn[81],Fpath[65],Fname[12];
  36.    /* enable this macro in the File Manager */
  37.    If( mode == dos_shell ) {
  38.      Fn = Caps(Dir_Entry);
  39.    } Else {
  40.      Fn = Caps(File_Name);
  41.      /* Note: in File mode, this macro allows editing of a
  42.             description for the parent directory entry ("..") 
  43.           which will not be directly accessible with 4DOS
  44.             and will not appear in the parent directory itself.
  45.      */
  46.      };
  47.   /* */
  48.     Fpath = Get_Path(Fn);
  49.   Fname = Copy(Fn,Svl(Fpath)+1,12);
  50.  
  51.     Int back_mode;
  52.  
  53.     If( File_Exists(Fexpand(Fn)) ) {
  54.         RM('4Dos^GetCurDesc');
  55.     Set_Global_Str('IPARM_1','/T=Enter Description for '+Fname+':/C=2/L=2/TP=10/ATTR='+Str(M_S_COLOR));
  56.     Set_Global_Str('IPARM_2','/C=1/L=3/W=40/ML=40');
  57.     Set_Global_Str('ISTR_2',Return_Str);
  58.     RM('DATA_IN /S=2/#=2/Y=5/W=45/T= 4DOS File Description ');
  59.     If (Return_Int) {
  60.       RM('4Dos^SetCurDesc /D='+Global_Str('ISTR_2'));
  61.         }
  62.     } else {
  63.             RM('MEERROR^MESSAGEBOX /T= 4DOS File Description /M= '+Fexpand(Fn)+' does not exist /B=1/NW=0');
  64.     }
  65. };
  66.  
  67. macro GetCurDesc;
  68. {
  69.   Str Fn[81],Fpath[65],Fname[12];
  70.   Int SaveRefresh,SaveRegExp,CurWinId,Place;
  71.   Str Description[64];
  72.  
  73.    /* enable this macro in the File Manager */
  74.    If( mode == Dos_Shell ) {
  75.      Fn = Caps(Dir_Entry);
  76.    } Else {
  77.      Fn = Caps(File_Name);
  78.    };
  79.    /* */
  80.   Fpath = Get_Path(Fn);
  81.   Fname = Copy(Fn,Svl(Fpath)+1,12);
  82.  
  83.   Fn = Fpath + 'DESCRIPT.ION';
  84.   CurWinId = Window_Id;
  85.   SaveRefresh = Refresh;
  86.   SaveRegExp = Reg_Exp_Stat;
  87.   Refresh = False;
  88.   Reg_Exp_Stat = True;
  89.   Create_Window;
  90.   Load_File(Fn);
  91.   If( Error_Level == 0 ) {
  92.     If( Search_Fwd('%'+Fname,0) ) {
  93.       Description = Get_Line;
  94.       Place = XPos(' ',Description,1);
  95.       Description = Copy(Description,Place+1,40);
  96.     } Else {
  97.       Description = "";
  98.     }
  99.   }
  100.   Delete_Window;
  101.   Switch_Win_Id(CurWinId);
  102.   Error_Level = 0;
  103.  
  104.   Refresh = SaveRefresh;
  105.   Reg_Exp_Stat = SaveRegExp;
  106.   Return_Str = Description;
  107. }
  108.  
  109. Macro SetCurDesc;
  110. {
  111.   Str Fn[81],Fpath[65],Fname[12];
  112.   Int SaveRefresh,SaveRegExp,SaveIns,CurWinId,Place,IsNew,SaveBackups;
  113.   Str Description[64],Line;
  114.  
  115.   Description = Copy(Parse_Str('/D=',MParm_Str),1,40);
  116.  
  117.   /* enable this macro in the File Manager */
  118.    If( mode == dos_shell ) {
  119.      Fn = Caps(Dir_Entry);
  120.    } else {
  121.      Fn = Caps(File_Name);
  122.    };
  123.   /* */
  124.     Fpath = Get_Path(Fn);
  125.   Fname = Copy(Fn,Svl(Fpath)+1,12);
  126.  
  127.   Fn = Fpath + 'DESCRIPT.ION';
  128.  
  129.   CurWinId = Window_Id;
  130.   SaveRefresh = Refresh;
  131.   SaveRegExp = Reg_Exp_Stat;
  132.   SaveIns = Insert_Mode;
  133.   Refresh = False;
  134.   Reg_Exp_Stat = True;
  135.   Insert_Mode = True;
  136.   Create_Window;
  137.   Load_File(Fn);
  138.   If( Error_Level == 0 ) {
  139.     IsNew = False;
  140.     If (Search_Fwd('%'+Fname,0)) {
  141.       Line = Get_Line;
  142.              If( Description == '' ) {
  143.               Del_Line;
  144.             } else {
  145.           Place = XPos(' ',Line,1);
  146.         Line = Copy(Line,1,Place-1)+' '+Description;
  147.         Put_Line(Line);
  148.             };
  149.     } else {
  150.       If( Description != '' ) {
  151.               Line = Fname + ' ' + Description;
  152.         Text(Line); Cr;
  153.             }
  154.     }
  155.   } else {
  156.         If( Description != '' ) {
  157.       IsNew = True;
  158.       File_Name = Fn;
  159.       Line = Fname + ' ' + Description;
  160.       Text(Line); Cr;
  161.       Error_Level = 0;
  162.         }
  163.   }
  164.     /* temporarily disable backups and save DESCRIPT.ION */
  165.     SaveBackups = Backups;
  166.     Backups = 0;
  167.     Save_File;
  168.     If(Error_Level != 0 ) {
  169.     RM('MEERROR');
  170.   }
  171.     If( Cur_File_Size == 0 ) {
  172.         Del_File(File_Name);
  173.     }
  174.     If( Error_Level != 0 ) {
  175.     RM('MEERROR');
  176.   }
  177.     Backups = SaveBackups;
  178.     /* */
  179.  
  180.   Delete_Window;
  181.   Switch_Win_Id(CurWinId);
  182.  
  183.   If( IsNew ) {
  184.     Set_File_Attr(Fn,0x02);
  185.     If( Error_Level != 0 ) {
  186.       RM('MEERROR');
  187.     }
  188.   }
  189.  
  190.   Refresh = SaveRefresh;
  191.   Reg_Exp_Stat = SaveRegExp;
  192.   Insert_Mode = SaveIns;
  193. }
  194.  
  195. Macro Running4DOS;
  196. {
  197.   Return_Int = 0;
  198.  
  199.   R_AX = 0x352F;
  200.   Intr(0x21);     /* Call DOS: Get Interrupt Vector */
  201.  
  202.   If( (R_ES == 0) && (R_BX == 0) ) {
  203.     Goto Exit;
  204.   }
  205.  
  206.   R_AX = 0xD44D;   /* use 0xE44D for NDOS */
  207.   R_BX = 0x0000;
  208.   Intr(0x2F);
  209.  
  210.   If( R_AX == 0x44DD ) { /* 4Dos is loaded */ /* 44EE for NDOS */
  211.     Return_Int = 100*(R_BX & 0x00FF) + (R_BX >> 8);
  212.   }
  213.  
  214.   Exit:
  215. }
  216.  
  217. Macro ShowDescriptions
  218. /**********************************************************
  219.    assign this macro to ME File Manager keymap
  220.    shows current directory files with 4Dos descriptions
  221.    links to 4DOS^EditDescription
  222.  
  223.    Dick Botbyl 01-11-92 03:13pm (see disclaimer below)
  224.  
  225.  
  226.     The "NON-PROGRAMMER" disclaimer
  227.  
  228.     I know the code is very crude
  229.     just chunks pieced and glued.
  230.     Some may even call it sloppy
  231.     and yes it looks a little choppy.
  232.  
  233.     This little gem has been run and rerun
  234.     But now I think I have it done.
  235.     When it is time to do the work,
  236.     it runs with only an occasional quirk.
  237.  
  238.     Please give these lines a real try.
  239.     Tell me where the errors lie.
  240.     The outcome of your final critique
  241.     may be that my skills are really weak.
  242.  
  243.     Since this is not my livelihood,
  244.     It shouldn't be considered bad or good.
  245.     Again and again, I will stammer
  246.     "This is the work of a 'NON-PROGRAMMER'"
  247.  
  248.     Some will be heard to mutter
  249.     "I can do it much, much better."
  250.     What I did here was only to suggest
  251.     and allow a rewrite by the best.
  252.  
  253.     Please remember that inspiration
  254.     can count as much as perspiration!
  255.     So tell them all to plagiarize
  256.     We'll know where the credit lies.
  257.  
  258.     * REB 1992 *
  259.  
  260. ***********************************************************/
  261.  
  262. {
  263.  
  264.   Str Fn[81],Fpath[65],Fname[12];
  265.   str Temp_Str[64],Description[64], Tstr[14];
  266.   Int CurWinId,Place,Re_Int;
  267.      Int S_R,Back_Mode, Dir_Done, Dline;
  268.  
  269. /* Added 01-Jan-91 - MRB */
  270.     If( Mode != Dos_Shell) {
  271.         Beep;
  272.         Make_Message('Sorry, this macro is only usable in the File Manager');
  273.         Goto End_Macro;
  274.     }
  275.  
  276. ToTop:                                /*  Go to the top of the DIR listing  */
  277.  
  278.   Make_Message('Reading Descriptions ...');
  279.   SAVE_BOX(1,1,Screen_Width, Screen_Length);
  280.   S_R = Status_Row;
  281.   Status_Row = 0;
  282.   Re_Int = 0;
  283.   Push_Labels;
  284.   Refresh = False;
  285.   CurWinId = Window_Id;
  286.   Dir_Done =  0;
  287.   Dline = 1;
  288.   While(  DIR_NUM > 1  ) {
  289.     Dos_Left;
  290.     Dline = Dline + 1;
  291.   }
  292.   Create_Window;
  293.   While(  Dir_Done < Dir_Total  ) {
  294.     Dir_Done = Dir_Done + 1;
  295.     Fn    = Lower(Dir_Entry);
  296.     Fpath = Get_Path(Fn);
  297.     Fname = Copy(Fn,Svl(Fpath)+1,12);
  298.     Fn = Fpath + 'DESCRIPT.ION';
  299.     Load_File(Fn);
  300.     If( Error_Level == 0 ) {
  301.       If( Search_Fwd('%'+Fname,0) ) {
  302.         Description = Get_Line;
  303.         Place = XPos(' ',Description,1);
  304.         Description = Copy(Description,Place+1,40);
  305.       } Else {
  306.         Description = "";
  307.       }
  308.     }
  309.     If( Dos_File_Attr == $10 ) {
  310.     Temp_Str = Fname + Copy( '              ', 1, 12 - Svl(Fname)) + '<DIR>' + Description + '  ';
  311.     } Else {
  312.     Temp_Str = Fname + Copy( '              ', 1, 12 - Svl(Fname)) + '   ' + Description + '  ';
  313.     }
  314.     Set_Global_Str('4ISTR_' + Str(Dir_Done), Temp_Str );
  315.     Dos_Right;
  316.   }
  317.   Delete_Window;
  318.   Create_Window;
  319.   Dir_Done = 1;
  320.   While(  Dir_Done < Dir_Total  ) {
  321.     Dir_Done = Dir_Done + 1;
  322.     Put_Line(Global_Str('4ISTR_' + Str(Dir_Done)));
  323.           Down;
  324.   }
  325.      Tof;
  326.     Make_Message('');
  327.     Set_Global_Str('B4IPARM_1', '/HT=' + Str(Screen_Length - 9) + '/TP=15/C=1/W=56/L=1/WIN=' + Str(Cur_Window) );
  328.   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');
  329.   Error_Level = 0;
  330.   Re_int = Return_Int;
  331.   Temp_Str = Copy(Get_Line, 1, 24);
  332.   Place = XPos(' ',Temp_Str,1);
  333.   Temp_Str = Copy(Temp_Str, 1, Place -1);
  334.   Delete_Window;
  335.   If (re_int) {
  336.     While( Dir_Num > 1  ) Dos_Left;
  337.     While( Dir_Num < Dir_Total ) {
  338.       Fn    = Lower(Dir_Entry);
  339.       Fpath = Get_Path(Fn);
  340.       Fname = Copy(Fn,Svl(Fpath)+1,12);
  341.       If(Fname == Temp_Str) RM('4dos^EditDescription');
  342.       Dos_Right;
  343.     }
  344.     If( Re_Int) {
  345.       If( Fname == Temp_Str) {
  346.         RM('4dos^EditDescription');
  347.       }
  348.     }
  349.   }
  350.   Dir_Done = 0;
  351.   While(  Dir_Num > 1  )  Dos_Left;
  352.   While(  Dir_Num < Dline ) Dos_Right;
  353.   While(  Dir_Done < Dir_Total  ) {
  354.     Dir_Done = Dir_Done + 1;
  355.     Set_Global_Str('4istr_' + Str(Dir_Done), '' );
  356.   }
  357.   Set_Global_Str('4iparm_1', '' );
  358.  
  359.   Switch_Win_Id(CurWinId);
  360.   Refresh = True;
  361.   Restore_Box;
  362.   Update_Dir;
  363.   Pop_Labels;
  364.   Status_Row = S_R;
  365.   If( Re_Int ) Goto Totop;
  366.  
  367. End_macro:
  368. }
  369.  
  370.