home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 April / VPR0204A.ISO / OLS / GREP109 / grep109.lzh / searchEx / grepAndDlg.mac < prev    next >
Text File  |  2001-09-28  |  6KB  |  179 lines

  1. //絞り込み grep の dialog
  2. disablebreak;
  3. $ini = macrodir + "\\searchEx\\searchEx.ini";
  4. $search = getinistr($ini,"SEARCH","string");
  5. #otherOption = getininum($ini,"SEARCH","otherOption");
  6. #joint = getininum($ini,"SEARCH","joint");
  7. call Dialog;
  8. goto End;
  9.  
  10. End:
  11.     writeinistr $ini,"SEARCH","tmp","\"" + $search + "\"";
  12.     writeininum $ini,"SEARCH","SearchOption",0;
  13.     execmacro macrodir + "\\searchEx\\history.mac";
  14.     freedll;
  15.     endmacro;
  16.  
  17. Dialog://設定 dialog
  18.     loaddll hidemarudir + "\\DengakuDLL.dll";
  19.  
  20.     //option 部の作成
  21.     if(!(dllfunc("NEWDLGPAGE","OPTION",23) &&
  22.     dllfunc("NEWCONTROL","check","UpLower","大文字/小文字の区別(&C)")))goto DllError;
  23.     if(searchoption&2)if(!dllfunc("SETCTRLSTATE","","1"))goto DllError;
  24.     if(!dllfunc("NEWCONTROL","check","word","単語の検索(&W)"))goto DllError;
  25.     if(searchoption&1)if(!dllfunc("SETCTRLSTATE","","1"))goto DllError;
  26.     if(!dllfunc("NEWCONTROL","check","regular","正規表現(&R)"))goto DllError;
  27.     if(searchoption&16)call RegON;
  28.     if(!(dllfunc("SETCTRLNOTIFY","","1016") &&
  29.     dllfunc("NEWCONTROL","check","fuzzy","あいまい検索(&F)")))goto DllError;
  30.     if(searchoption&32)if(!dllfunc("SETCTRLSTATE","","1"))goto DllError;
  31.     if(!(dllfunc("SETCTRLNOTIFY","","1032") &&
  32.     dllfunc("NEWCONTROL","check","joint","指定文字列の無視(&J)") &&
  33.     dllfunc("SETCTRLNOTIFY","","4")))goto DllError;
  34.     call JointList;
  35.     if(#otherOption&4){
  36.         if(!dllfunc("SETCTRLSTATE","joint","1"))goto DllError;
  37.         call RegON;
  38.     }
  39.     else if(!dllfunc("ENABLECTRL",0,"jointList"))goto DllError;
  40.  
  41.     //本体
  42.     if(!(dllfunc("NEWDIALOG","絞り込み grep の実行",45) &&
  43.     dllfunc("NEWCONTROL","text","","検索文字列(&S)") &&
  44.     dllfunc("SETCTRLWIDTH","",11) &&
  45.     dllfunc("NEWCONTROL","combo","search",$search)))goto DllError;
  46.     writeinistr $ini,"SEARCH","tmp","SEARCHHISTORY";
  47.     execmacro macrodir + "\\searchEx\\combo.mac";
  48.     if(!(dllfunc("NEWCONTROL","text","","")&&
  49.     dllfunc("SETCTRLWIDTH","",3)&&
  50.     dllfunc("NEWCONTROL","frame","","") &&
  51.     dllfunc("SETCTRLITEM","","OPTION") &&
  52.     dllfunc("NEWCOLUMN",19) &&
  53.     dllfunc("NEWCONTROL","defbutton","","OK") &&
  54.     dllfunc("SETCTRLNOTIFY","","1") &&
  55.     dllfunc("NEWCONTROL","button","","キャンセル") &&
  56.     dllfunc("SETCTRLNOTIFY","","0") &&
  57.     dllfunc("NEWCONTROL","button","","無視する文字の設定(&1)") &&
  58.     dllfunc("SETCTRLNOTIFY","","2")))goto DllError;
  59.     if(#extension)if(!dllfunc("ENABLECTRL",0,"fileOnly"))goto DllError;
  60.     if(!dllfunc("SHOWDIALOG",hidemaruhandle(0),0))goto DllError;
  61.     while(1){
  62.         $$data = "";
  63.         while(strlen($$data) == 0)$$data = dllfuncstr("WAITCTRLNOTIFY",1);
  64.         ##notify = val($$data);
  65.         if(##notify < 4)break;
  66.         else if(##notify == 4)call JointOn;
  67.         else if(##notify == 5){
  68.             $$data = dllfuncstr("GETCTRLSTRING","file");
  69.             call GetFileName $$data;
  70.             $$data = dllfuncstr("GETCTRLSTRING","dir") + "\\" + $$return;
  71.             if(!dllfunc("SETCTRLSTRING","file",$$data))goto DllError;
  72.         }
  73.         else if(##notify == 1016)call SetRegular;
  74.         else if(##notify == 1032){
  75.             $$data = dllfuncstr("GETCTRLSTATE","fuzzy");
  76.             if($$data == "1")if(!dllfunc("SETCTRLSTATE","regular","1"))goto DllError;
  77.             call SetRegular;
  78.         }
  79.     }
  80.     if(!dllfunc("ENDDIALOG"))goto DllError;
  81.     if(##notify == 0)goto EndAll;
  82.     $search = dllfuncstr("GETCTRLSTRING","search");
  83.     $$data = dllfuncstr("GETCTRLSTRING","file");
  84.     call GetFileName $$data;
  85.     if($$return == $$data){
  86.         $directory = directory2;
  87.         $file = $$data;
  88.     }
  89.     else{
  90.         $file = $$return;
  91.         $directory = leftstr($$data,strlen($$data) - strlen($file) - 1);
  92.     }
  93.     if(dllfuncstr("GETCTRLSTATE","fuzzy") == "1")#option = 48;
  94.     else if(dllfuncstr("GETCTRLSTATE","regular") == "1")#option = 16;
  95.     else{
  96.         if(dllfuncstr("GETCTRLSTATE","word") == "1")#option = 1;
  97.         if(dllfuncstr("GETCTRLSTATE","UpLower") == "1")#option = #option|2;
  98.     }
  99.     if(dllfuncstr("GETCTRLSTATE","fileOnly") == "1")#option = #option|64;
  100.     #otherOption = val(dllfuncstr("GETCTRLSTATE","subdir"));
  101.     if(dllfuncstr("GETCTRLSTATE","fullpath") == "1")#otherOption = #otherOption|2;
  102.     if(dllfuncstr("GETCTRLSTATE","joint") == "1"){
  103.         #otherOption = #otherOption|4;
  104.         writeinistr $ini,"SEARCH","joint",dllfuncstr("GETCTRLSTATE","jointList");
  105.     }
  106.     writeininum $ini,"SEARCH","option",#option;
  107.     writeininum $ini,"SEARCH","otherOption",#otherOption;
  108.     writeinistr $ini,"SEARCH","string","\"" + $search + "\"";
  109.     if(##notify == 1)return;
  110.     else if(##notify == 2)execmacro macrodir + "\\searchEx\\stringDlg.mac";
  111.     goto Dialog;
  112.  
  113. GetFileName://file name だけ取得
  114.     while(1){
  115.         ##extension=strstr($$1,";");
  116.         if(##extension==-1)break;
  117.         ##extension=strlen($$1)-##extension-1;
  118.         $$1=rightstr($$1,##extension);
  119.     }
  120.     while(1){
  121.         ##extension=strstr($$1,"\\");
  122.         if(##extension==-1)break;
  123.         ##extension=strlen($$1)-##extension-1;
  124.         $$1=rightstr($$1,##extension);
  125.     }
  126.     return $$1;
  127.  
  128. SetRegular://正規表現の ON/OFF
  129.     $$state = dllfuncstr("GETCTRLSTATE","regular");
  130.     if($$state == "1"){
  131.         if(!(dllfunc("ENABLECTRL",0,"word") &&
  132.         dllfunc("ENABLECTRL",0,"UpLower")))goto DllError;
  133.     }
  134.     else if($$state == "0"){
  135.         if(!(dllfunc("ENABLECTRL",1,"word") &&
  136.         dllfunc("ENABLECTRL",1,"UpLower") &&
  137.         dllfunc("SETCTRLSTATE","fuzzy","0") &&
  138.         dllfunc("SETCTRLSTATE","joint","0") &&
  139.         dllfunc("ENABLECTRL",0,"jointList")))goto DllError;
  140.     }
  141.     return;
  142.  
  143. JointOn://文字列無視の ON/OFF
  144.     if(!val(dllfuncstr("GETCTRLSTATE","joint"))){
  145.         if(!dllfunc("ENABLECTRL",0,"jointList"))goto DllError;
  146.     }
  147.     else{
  148.         if(!dllfunc("ENABLECTRL",1,"jointList"))goto DllError;
  149.         if(!val(dllfuncstr("GETCTRLSTATE","regular")))call RegON;
  150.     }
  151.     return;
  152.  
  153. RegON://正規表現 ON
  154.     if(!(dllfunc("SETCTRLSTATE","regular","1") &&
  155.     dllfunc("ENABLECTRL",0,"word") &&
  156.     dllfunc("ENABLECTRL",0,"UpLower")))goto DllError;
  157.     return;
  158.  
  159. DllError://DLL error の処理
  160.     message "DLL機能の利用が出来ませんでした。\nマクロを終了します。";
  161. EndAll:
  162.     freedll;
  163.     endmacroall;
  164.  
  165. JointList://文字列無視の list 作成
  166.     if(!(dllfunc("NEWCONTROL","text",""," 種類(&2)") &&
  167.     dllfunc("SETCTRLWIDTH","",9) &&
  168.     dllfunc("NEWCONTROL","list","jointList","") &&
  169.     dllfunc("SETCTRLHEIGHT","",1)))goto DllError;
  170.     ##i = 0;
  171.     while(##i < 10){
  172.         $$tmp = getinistr($ini,"STRING",str(##i));
  173.         if($$tmp == "")break;
  174.         if(!dllfunc("SETCTRLITEM","",$$tmp,"-1"))goto DllError;
  175.         ##i = ##i + 1;
  176.     }
  177.     if(!dllfunc("SETCTRLSTATE","",str(#joint)))goto DllError;
  178.     return;
  179.