Hash+INI Manager — File Browser

HashINIManagerv2.0 / HashINIManagerv2.0 / mims2.mrc

mims2.mrc — 8.76 KB — Download this file

;...Hash+INI Manager v.2.0 by orkin...;
;...For ease of use, consult the readme...;


on *:load:{ set %inidir $mircdir | set %xpand off | echo -s Hash+INI Manager2.0 loaded.  Use /mims2 to begin }
on *:unload:{ unset %inidir %sel.cl %xpand | echo -s Thank you for using Hash+INI Manager2.0 by orkin }
alias mims2 { $iif($dialog(mims2),/dialog -x mims2,/dialog -m mims2 mims2) }
dialog mims2 {
  title "Hash+INI Manager"
  size -1 -1 178 376
  edit "", 8, 9 273 158 22, autohs
}
on *:dialog:mims2:init:*: {
  dcx Mark $dname mims2c
  xdialog -c $dname 1 treeview 9 9 158 257 haslines showsel tabstop hasbuttons
  mimsinit
}
on *:dialog:mims2:edit:8: { xdid -e $dname 4 | if (%xpand = on) { /xdid -r mims2 2 | /xdid -a mims2 2 $did(mims2,8).text } }
alias -l mimsinit {
  xdialog -c $dname 2 richedit 9 300 158 35 autohs hsbar tabstop
  xdialog -c $dname 5 button 116 342 50 24 ok tabstop
  xdid -t $dname 5 Okay
  xdialog -c $dname 4 button 10 342 50 24 disabled tabstop
  xdid -t $dname 4 Apply
  xdialog -c $dname 3 check 79 342 20 20 tabstop
  if (%xpand = on) xdid -c mims2 3
  elseif (%xpand = off) richlapse
  set %pr 0 
  window -pfhkdCiB +fL @prog -1 -1 120 40
  drawrect -fr @prog $rgb(face) 0 0 0 120 40
  drawrect  @prog 1 0 7 23 104 12
  drawtext -o @prog 1 Tahoma -8 36 4 Loading
  window -a @prog
  set %numb 0
  var %y = $findfile($shortfn(%inidir),*.ini,0,1,inc %numb)
  set %numb $calc(%numb + $hget(0))
  set %numb $calc(100 / %numb) 
  populate
}
alias populate {
  tokenize 32 $1-
  xdid -r mims2 1
  xdid -a mims2 1 $+(-1,$chr(9),+b 1 1 0 0 0 $rgb(0,0,0) INI)
  $iif($window(@prog),pgsbar 0.5 Loading INI Files)  
  var %x = $findfile($shortfn(%inidir),*.ini,0,1,listini $1-)
  xdid -a mims2 1 $+(2,$chr(9),+b 1 1 0 0 0 $rgb(0,0,0) Hash Tables) 
  $iif($window(@prog),pgsbar 0.5 Loading Hash Tables) 
  var %a = 1 
  while (%a <= $hget(0)) {
    xdid -a mims2 1 $+(2 -1,$chr(9),+ 1 1 0 0 0 $rgb(0,0,0) $hget(%a))
    var %b = 1
    while (%b <= $hget(%a, 0).item) {
      xdid -a mims2 1 $+(2 -1 -1,$chr(9),+ 1 1 0 0 0 $rgb(0,0,0) $hget(%a, %b).item)
      inc %b 
    }
    inc %a
    $iif($window(@prog),progress)
  }
  if ($window(@prog)) { drawrect -f @prog 1 0 9 25 $calc(100 - %pr) 8 | pgsbar 31 Complete | close -@ @prog | unset %pr | unset %numb }
  if ($1) { /xdid -c mims2 1 $1- } 
}
alias listini {
  xdid -a mims2 1 $+(1 -1,$chr(9),+ 1 1 0 0 0 $rgb(0,0,0) $nopath($1))
  var %x = 1
  while ($ini($1,0) <= $ini($1,%x)) { listitems $1 %x | inc %x }
  $iif($window(@prog),progress)
}
alias listitems {
  xdid -a mims2 1 $+(1 -1 -1,$chr(9),+ 1 1 0 0 0 $rgb(0,0,0) $ini($1,$2))
  var %x = 1
  while ($ini($1,$2,0) <= $ini($1,$2,%x)) { xdid -a mims2 1 $+(1 -1 -1 -1,$chr(9),+ 1 1 0 0 0 $rgb(0,0,0) $ini($1,$2,%x)) | inc %x }
}
alias richxpand {
  dialog -s mims2 -1 -1 178 376
  xdialog -c mims2 2 richedit 9 300 158 35 autohs tabstop
  xdid -p mims2 5 116 342 50 24
  xdid -p mims2 4 10 342 50 24 
  xdid -p mims2 3 79 342 20 20
  set %xpand on
  xdid -a mims2 2 $did(mims2,8).text
}
alias richlapse { 
  xdialog -d mims2 2
  dialog -s mims2 -1 -1 178 340
  xdid -p mims2 5 116 305 50 24
  xdid -p mims2 4 10 305 50 24 
  xdid -p mims2 3 79 305 20 20 
  set %xpand off
}
alias mims2c {
  tokenize 32 $1-
  if ($2 = sclick) {
    if ($3 = 5) { /mims2 }
    if ($3 = 3) { $iif(%xpand = off,/richxpand,/richlapse) }
    if ($3 = 4) {
      tokenize 32 %sel.cl
      xdid -b mims2 4
      if ($1 = 2) { if (!$2) { hmake $did(mims2, 8) 100 | populate $1- } | elseif ($2) {  hadd $hget($2) $hget($2, $3).item $did(mims2,8) | if (!$3) { /populate $1- | did -r mims2 8 ) } } }
      if ($1 = 1) { if ($2) { var %x = $shortfn($findfile(%inidir,*.ini,$2)) | if (!$3) { writeini %x $did(mims2, 8) x y | remini %x $did(mims2, 8) x | populate $1- | did -r mims2 8 } | elseif ($3 && !$4) {  writeini %x $ini(%x,$3) $did(mims2, 8) "" | populate $1- | did -r mims2 8 } | else { writeini %x $ini(%x,$3) $ini(%x,$3,$4) $did(mims2, 8) } } }
      if ($3 = 3) { $iif($xdid(mims2,3).state = 0,/richlapse,/richxpand) }
    }     
    if ($3 = 1) { 
      %sel.cl = $4-
      if ($4 = 2) { /did -i mims2 8 1 $hget($xdid(mims2, 1,$4 $5).text, $xdid(mims2, 1, $4-).text) | if (%xpand = on) { /xdid -r mims2 2 | /xdid -a mims2 2 $hget($xdid(mims2, 1,$4 $5).text, $xdid(mims2, 1, $4-).text) } }
      if ($4 = 1 && ($6)) { /did -i mims2 8 1 $readini(%inidir $+ $xdid(mims2,1,$4 $5).text, $xdid(mims2,1,$4 $5 $6).text, $xdid(mims2,1,$4 $5 $6 $7).text) | if (%xpand = on) { /xdid -r mims2 2 | /xdid -a mims2 2 $readini(%inidir $+ $xdid(mims2,1,$4 $5).text, $xdid(mims2,1,$4 $5 $6).text, $xdid(mims2,1,$4 $5 $6 $7).text) } }
    }
  }
  if ($2 = rclick) {
    if ($4 = 1) {
      if (!$5) { popup New top 1 1 | popup AddItem top end &Change Directory $cr inichgdir |pop top $mouse.dx $mouse.dy }
      elseif ($5 && !$6) {
        popup New inif 1 1
        popup AddItem inif end &Change Directory $cr inichgdir
        popup AddItem inif end &Rename $cr renini $5-
        popup AddItem inif end &Delete $cr delini $5-
        pop inif $mouse.dx $mouse.dy
      }
      elseif ($6 && !$7) {
        popup New inis 1 1
        popup AddItem inis end &New Topic $cr addsect $5-
        popup AddItem inis end &Delete $cr delsect $5-
        pop inis $mouse.dx $mouse.dy
      }
      else {
        popup New initem 1 1
        popup AddItem initem end &New Item $cr plusline $5-
        popup AddItem initem end &Delete Item $cr deline $5-
        pop initem $mouse.dx $mouse.dy
      }
    }
    if ($4 = 2) {
      if (!$5) {
        popup New tab 1 1 
        popup AddItem tab end &New Table $cr newtab $4
        pop tab $mouse.dx $mouse.dy
      }
      if ($5 && !$6) {
        popup New table 1 1
        popup AddItem table end &New Table $cr newtab $5-
        popup AddItem table end &Load Table $cr addhf $5-
        popup AddItem table end &Free Table $cr delht $5-
        popup AddItem table end &Save As... $cr stable 
        pop table $mouse.dx $mouse.dy    
      }
      if ($6) {
        popup New item 1 1 
        popup AddItem item end &New Item $cr new.item $4-
        popup AddItem item end &Delete $cr delhi $4-
        pop item $mouse.dx $mouse.dy
      }
    }
  }   
}
alias -l pgsbar { drawrect -rf @prog $rgb(face) 0 0 0 502 22 | drawtext -o @prog 1 Tahoma -8 $1 4 $2- | window -a @prog }
alias -l progress { $iif(%pr == 0,set %pr %numb,set %pr $calc(%pr + %numb)) | drawrect -f @prog 1 0 9 25 $round(%pr,2) 8 | window -a @prog }
alias -l deline { var %x = $shortfn($findfile(%inidir,*.ini,$1)) | remini %x $ini(%x,$2) $ini(%x,$2,$3) | /populate 1 $1 $2 1 }
alias -l plusline { var %x = $shortfn($findfile(%inidir,*.ini,$1)) | writeini %x $ini(%x,$2) $?="Item name?" "" | /populate 1 $1 $2 $ini(%x,$2,0) }
alias -l delsect { remini $shortfn($findfile(%inidir,*.ini,$1)) $ini($shortfn($findfile(%inidir,*.ini,$1)),$2) | echo -s $2 | /populate 1 $1 $iif($2 > 1,$calc($2 - 1),1) }
alias -l addsect { var %x = $shortfn($findfile(%inidir,*.ini,$1)) | var %y = $?="Name of new section" | writeini %x %y x y | remini %x %y x | /populate 1 $1 $ini(%x,0) }
alias -l delini { .remove -b $shortfn($findfile(%inidir,*.ini,$1)) | //echo -s  $+ $color(info) $+ $chr(42) Removed $nopath($shortfn($findfile(%inidir,*.ini,$1))) | /populate 1  }
alias -l renini { var %x = $?="New Name (include Extension)" | rename $+($chr(34),$findfile(%inidir,*.ini,$1),$chr(34)) $+($chr(34),%inidir,%x,$chr(34)) | /populate 1 $1 }
alias -l inichgdir { set %inidir $sdir(%inidir,Specify new directory) | /populate }
alias -l delhi { hdel $hget($2) $hget($2, $3).item | /populate $1 $2 $iif($3 > 1,$calc($3 - 1),1) }
alias -l new.item { hadd $hget($2) $?="Item name" | /populate $1 $2 $hget($2, 0).item  }
alias -l newtab { hmake $?="Name of table" | /populate 2 $1- }
alias -l delht { hfree $hget($1) | /populate 2 $iif($1 > 1,$calc($1 - 1),1) }
alias -l addhf { var %x = $?="Name of Hash Table" | hmake %x 100 | hload %x $shortfn($sfile($mircdir,Hash File to load,Load)) | /populate 2 $1- }
alias -l stable { var %x = $sfile($mircdir,Specify filename(including extension),Save) |  hsave -s $hget($1) " $+ %x $+ " }
alias -l popup { return $dll($shortfn($scriptdirpopups.dll),$1,$2-) }
alias -l pop { tokenize 32 $dll($shortfn($scriptdirpopups.dll),Popup,$1-) | if ($isid) return $1- | else $iif($4- != did not select a menu item,$4-) }

;########DCXtools provided by twigboy##########;
alias -l dcx {
  if ($isid) return $dll($scriptdirdcx.dll,$1,$2-)
  else dll " $+ $scriptdirdcx.dll" $1 $2-
}

alias -l udcx dll -u dcx.dll

alias -l xdid {
  if ( $isid ) {
    return $dcx( _xdid, $1 $2 $prop $3- )
  }
  else {
    dcx xdid $2 $3 $1 $4-
  }
}

alias -l xdialog {
  if ( $isid ) {
    return $dcx( _xdialog, $1 $prop $2- )
  }
  else {
    dcx xdialog $2 $1 $3-
  }
}