home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 July / VPR0207A.ISO / OLS / IRVINE0_4_1A / irvine0_4_1a.lzh / scripts / maindivitems.dms < prev    next >
Text File  |  2002-02-11  |  2KB  |  99 lines

  1. /*
  2. スクリプト初期化データ
  3. guid={DFAC9C28-7765-4927-8FDC-B21FA5DFA16B}
  4. caption=アイテムの振り分け
  5. version=1
  6. hint=カレントフォルダのアイテムを指定したアイテム数で下位フォルダに振り分けます
  7. event=OnMainMenuClick
  8. match=
  9. author=Wolfy
  10. */
  11.  
  12. function formatDigit(num,digit){
  13.   s = num.toString();
  14.   if(s.length < digit){
  15.     temp = '';
  16.     for(i = 0; i < digit - s.length;i++)
  17.       temp = temp + '0';
  18.       
  19.     s = temp + s;
  20.   }
  21.   return s;
  22. }
  23.  
  24. function includeBackslash(s){
  25.   if(s.charAt(s.length - 1) == '\')
  26.     return s;
  27.   else
  28.     return s + '\';
  29. }
  30.  
  31. function OnMainMenuClick(irvine,action){
  32. //メインメニューのクリックイベント
  33.   //終わり
  34.   if(irvine.ItemCount == 0)
  35.     return;
  36.   //アイテム数
  37.   divcount = prompt('振り分けるアイテムの数を入力してください。',1000);
  38.   if(!divcount || isNaN(divcount)){
  39.    return;
  40.   }
  41.   else{
  42.    //数字にする
  43.    divcount = parseInt(divcount);
  44.   }
  45.   //カレントフォルダ名
  46.   current = irvine.Current;
  47.   //Irvine.Folderを作成
  48.   folder = new ActiveXObject('Irvine.Folder');
  49.   flag = false;
  50.   index = 0;
  51.   
  52.   oldfilter = irvine.Filtering;
  53.   irvine.Filtering = false;
  54.   irvine.BeginProgressBar(current.ItemCount);
  55.   try{
  56.     i = 0;
  57.     //振り分けフォルダ
  58.     folder.Path = current.Path + '/' + formatDigit(index,2);
  59.     while(current.ItemCount > 0){
  60.       //フォルダを作成
  61.       if(!folder.Exists()){
  62.         if(folder.Make()){
  63.           //保存場所を設定
  64.           folder.Data['queue','folder'] = includeBackslash(current.Data['queue','folder']) + formatDigit(index,2);
  65.         }
  66.         else{ //作成失敗ならば終わり
  67.           return;
  68.         }
  69.       }
  70.       
  71.       //加える
  72.       folder.AddItem(current.Items[0]);
  73.       //削除する
  74.       current.ExtractItem(0);
  75.       flag = true;
  76.       ++i;
  77.       irvine.ProgressBarStepBy(1);
  78.       //カウントをチェックする
  79.       if(i >= divcount){
  80.         i = 0;
  81.         ++index;
  82.         folder.Path = current.Path + '/' + formatDigit(index,2);
  83.       }
  84.     }
  85.   }
  86.   
  87.   finally{
  88.     irvine.Filtering = oldfilter; 
  89.     irvine.EndProgressBar();
  90.     if(flag)
  91.       irvine.Invalidate();
  92.   }
  93. }
  94.  
  95. function OnMenuUpdate(irvine,action){
  96. //メニューの更新イベント
  97.   action.enabled = (irvine.ItemCount > 0);
  98. }
  99.