Loading

Hash table viewer

  1. ;Hash Table viewing Dialog v2.01
  2. ;Creator - JoshR
  3. ;Reason for making - For people who are visual learners to assist them in hash tables
  4. ;                    and just to further my own experience.
  5. ;Usage - Pretty straight forward really. Just load it in to your remotes, right click, choose hash tables, and you're ready to go!
  6. ;        Single click in table list to display items/values for that table
  7. ;        Double click a table name to change it's name
  8. ;        Single click the add hash button or the add hash option in the 'option' menu to add a hash table
  9. ;        Double click an item/value or click the edit Item/value button to edit them
  10. ;            upon doing so will open the edit dialog allowing you to double click an item to change it or
  11. ;            the same for values.
  12. ;        Single click the add item/value to add an item with or without a value.
  13. ;        To use the search function be sure you choose a search type.
  14. ;        To delete tables or items, the option is located in the 'options' menu.
  15. ;Updates - Everything:
  16. ;               Completely redid everything on the dialog(s)
  17. ;Contact info - /query JoshR (on SwiftIRC && DALnet)
  18. ;                       PM me on the forums aswell (http://forum.swiftirc.net if you have an account there)
  19. ;               /query JoshR (on UnderNet)
  20. ;#############################################
  21. ;#Made by: JoshR                             #
  22. ;#Home Server(s): Swiftirc, Undernet, DALnet #
  23. ;#Home Channel: #mIRC #ikick(swiftirc)       #
  24. ;#############################################
  25. ;;MENU;;
  26. menu * {
  27.   -
  28.   Hash Tables:/hashview
  29. }
  30. ;;MAIN DIALOG
  31. dialog hashview {
  32.   title "[Hash:Viewer]"
  33.   option dbu
  34.   size -1 -1 208 130
  35.  
  36.   box "Tables" 1, 3 2 66 97
  37.   list 101, 5 10 62 97, vsbar hsbar
  38.   button "Add Hashtable" 102, 3 118 43 11
  39.  
  40.   box "Items" 2, 71 2 66 97
  41.   list 201, 73 10 62 97, vsbar hsbar
  42.   button "Add Item/Value" 202, 46 118 45 11
  43.  
  44.   box "Values" 3, 139 2 66 97
  45.   list 301, 141 10 62 97, vsbar hsbar
  46.  
  47.   edit "Enter search item here" 400, 3 105 147 11
  48.   button "Search" 401, 152 105 38 11
  49.   combo 402, 152 118 38 11, drop
  50.  
  51.   button "..." 501, 193 105 10 11
  52.   button "Edit Item/Values" 601, 91 118 48 11
  53.  
  54.   menu "&Options" 4,
  55.   item "&Add HashTable" 5, 4
  56.   item "&Delete Hash Table" 6, 4
  57.   item break, 7, 4
  58.   item "&Exit" 8, 4
  59. }
  60. on *:DIALOG:hashview:init:0:{
  61.   var %a 1
  62.   tokenize 46 exact.wildcard
  63.   did -a hashview 402 $*
  64.   while (%a <= $hget(0)) {
  65.     if ($hget(%a) != hashview) did -a hashview 101 $hget(%a)
  66.     inc %a
  67.   }
  68.   did -z hashview 101
  69. }
  70. on *:DIALOG:hashview:menu:*:{
  71.   if ($did == 5) {
  72.     if ($input(What would you like the table name to be?,en,[Hash:Add Table]) != $null) {
  73.       var %a $v1
  74.       if (!$hget($v1)) {
  75.         hmake %a 1000
  76.         did -a hashview 101 %a
  77.       }
  78.       else noop $input(Error: There is already a table named $+(',%a,'),o,[Hash:Add Table Alert])
  79.     }
  80.   }
  81.   if ($did == 6) delhash
  82.   if ($did == 8) dialog -x $dname
  83. }
  84. on *:DIALOG:hashview:sclick:601:{
  85.   edititem
  86. }
  87. on *:DIALOG:hashview:sclick:501:{
  88.   var %a 1
  89.   did -r hashview 101,201,301
  90.   while (%a <= $hget(0)) {
  91.     if ($hget(%a) != hashview) did -a hashview 101 $hget(%a)
  92.     inc %a
  93.   }
  94.   did -z hashview 101,201,301
  95. }
  96. on *:DIALOG:hashview:sclick:401:{
  97.   if (Enter search item here == $did(400) || $did(400) == $null) {
  98.     noop $input(Error: Missing input for search.,ok30,[Hash:Search] - Error)
  99.     return
  100.   }
  101.   if ($did(402) == $null) {
  102.     noop $input(Error: Please choose a type of search.,ok30,[Hash:Search] - Error)
  103.     return
  104.   }
  105.   did -r hashview 101,201,301
  106.   noop $dsearch($did(400),$did(402))
  107. }
  108. on *:DIALOG:hashview:sclick:101:{
  109.   if ($did(101).seltext) {
  110.     did -r hashview 201,301
  111.     var %a 1,%get $v1
  112.     while (%a <= $hget(%get,0).item) {
  113.       did -a hashview 201 $hget(%get,%a).item
  114.       did -a hashview 301 $hget(%get,%a).data
  115.       inc %a
  116.     }
  117.     did -z hashview 201,301
  118.   }
  119. }
  120. on *:DIALOG:hashview:dclick:101:{
  121.   if ($did(101).sel == 0) return
  122.   if ($input(Hashtable name change for $+(',$did(101).seltext,'),en,[Hash:Name Change])) {
  123.     if ($v1 != $null && $v1 != $did(101).seltext) {
  124.       hmake $v1 1000
  125.       var %a 1,%new $v1,%old $v2
  126.       while ($hget(%old,%a).item) {
  127.         hadd -m %new $v1 $hget(%old,%a).data
  128.         inc %a
  129.       }
  130.       hfree %old
  131.       did -o hashview 101 $did(101).sel %new
  132.     }
  133.   }
  134. }
  135. on *:DIALOG:hashview:sclick:102:{
  136.   if ($input(What would you like the table name to be?,en,[Hash:Add Table]) != $null) {
  137.     var %a $v1
  138.     if (!$hget($v1)) {
  139.       hmake %a 1000
  140.       did -a hashview 101 %a
  141.     }
  142.     else noop $input(Error: There is already a table named $+(',%a,'),o,[Hash:Add Table Alert])
  143.   }
  144. }
  145. on *:DIALOG:hashview:sclick:201,301:did -c hashview 201,301 $did($did).sel
  146. on *:DIALOG:hashview:sclick:202:{
  147.   additem
  148. }
  149. on *:DIALOG:hashview:dclick:201,301:{
  150.   edititem
  151. }
  152. ;;;;EDIT ITEM/VALUE;;;;
  153. dialog edititem {
  154.   title "[Hash:Item Editor]"
  155.   option dbu
  156.   size -1 -1 139 120
  157.  
  158.   combo 1, 3 3 70 11, drop
  159.  
  160.   box "Items" 2, 3 18 66 97
  161.   list 201, 5 26 62 97, vsbar hsbar
  162.  
  163.   box "Values" 3, 71 18 66 97
  164.   list 301, 73 26 62 97, vsbar hsbar
  165. }
  166. on *:DIALOG:edititem:init:0:{
  167.   didtok edititem 1 32 $regsubex($str(.,$hget(0)),/./g,$hget(\n) $chr(32))
  168.   if ($did(hashview,101).seltext) {
  169.     var %a $v1,%b 1
  170.     did -ck edititem 1 $did(hashview,101).sel
  171.     while ($hget(%a,%b).item) {
  172.       did -a edititem 201 $v1
  173.       did -a edititem 301 $hget(%a,$v1)
  174.       inc %b
  175.     }
  176.     set %edititem.table $did(hashview,101).seltext
  177.     did -z edititem 201,301
  178.   }
  179. }
  180. on *:DIALOG:edititem:sclick:1:{
  181.   did -r edititem 201,301
  182.   var %a 1
  183.   while ($hget($did(1),%a).item) {
  184.     did -a edititem 201 $v1
  185.     did -a edititem 301 $hget($did(1),$v1)
  186.     inc %a
  187.   }
  188.   set %edititem.table $did(1)
  189.   did -z edititem 201,301
  190. }
  191. on *:DIALOG:edititem:dclick:201:{
  192.   var %a = $didwm(hashview,201,$did(201).seltext)
  193.   if ($input(Change the name of the item selected item $+(',$did(201).seltext,'),en,[Edit:Item])) {
  194.     if ($v1 != $null && $v1 != $did(201).seltext) {
  195.       hadd -m %edititem.table $v1 $hget(%edititem.table,$did(201).seltext)
  196.       hdel %edititem.table $did(201).seltext
  197.       did -o edititem 201 $did(201).sel $v1
  198.       did -o hashview 201 %a $v1
  199.     }
  200.   }
  201. }
  202. on *:DIALOG:edititem:dclick:301:{
  203.   var %a = $didwm(hashview,301,$did(301).seltext),%b = $did(edititem,201,$did(301).sel)
  204.   if ($input(Change the value of the selected item,en,[Edit:Value])) {
  205.     if ($v1 != $null && $v1 != $did(301).seltext) {
  206.       hadd -m %edititem.table %b $v1
  207.       did -o edititem 301 $did(301).sel $v1
  208.       did -o hashview 301 %a $v1
  209.     }
  210.   }
  211. }
  212. on *:DIALOG:edititem:close:0:{
  213.   unset %edititem.*
  214. }
  215. ;;;;ADD ITEM/VALUES;;;;
  216. dialog additem {
  217.   title "[Hash:Add Item/Values]"
  218.   option dbu
  219.   size -1 -1 139 60
  220.  
  221.   combo 1, 3 3 70 11, drop
  222.  
  223.   box "Items" 2, 3 18 66 28
  224.   edit "" 201, 5 26 62 18, autohs
  225.  
  226.   box "Values" 3, 71 18 66 28
  227.   edit "" 301, 73 26 62 18, autohs
  228.  
  229.   button "Add Item/Value" 4, 3 47 66 11
  230.   button "Clear Fields" 5, 71 47 66 11
  231.  
  232.   menu "&Options" 6
  233.   item "&Add Item/Value" 7, 6
  234.   item "&Exit" 8, 6
  235. }
  236. on *:DIALOG:additem:menu:*:{
  237.   if ($did == 8) dialog -x additem
  238.   if ($did == 7) {  }
  239. }
  240. on *:DIALOG:additem:init:0:{
  241.   if ($did(hashview,101).sel) {
  242.     didtok additem 1 32 $regsubex($str(.,$hget(0)),/./g,$hget(\n) $chr(32))
  243.     did -ck additem 1 $v1
  244.   }
  245.   else didtok additem 1 32 $regsubex($str(.,$hget(0)),/./g,$hget(\n) $chr(32))
  246. }
  247. on *:DIALOG:additem:sclick:5:did -r additem 201,301
  248. on *:DIALOG:additem:sclick:4:{
  249.   if ($hget($did(1),$did(201))) {
  250.     if ($input(Adding this Item will overwrite the currently loaded item of the same name. Are you OK with this?,o,[Hash:Item Alert])) {
  251.       hadd -m $did(1) $did(201) $did(301)
  252.       if ($did(1) == $did(hashview,101).seltext) {
  253.         did -o hashview 301 $didwm(hashview,201,$did(201),1) $did(301)
  254.       }
  255.       did -r additem 201,301
  256.     }
  257.     else return
  258.   }
  259.   else {
  260.     hadd -m $did(1) $did(201) $did(301)
  261.     if ($did(1) == $did(hashview,101).seltext) {
  262.       did -a hashview 201 $did(201)
  263.       did -a hashview 301 $did(301)
  264.     }
  265.     did -r additem 201,301
  266.   }
  267.   dialog -x additem
  268. }
  269. ;;;;DELETE DIALOG;;;;
  270. dialog delhash {
  271.   title "[Hash:Item/Table Deleter]"
  272.   option dbu
  273.   size -1 -1 140 129
  274.  
  275.   combo 1, 3 3 70 11, drop
  276.  
  277.   box "Items" 2, 3 18 66 97
  278.   list 201, 5 26 62 97, vsbar hsbar
  279.  
  280.   box "Values" 3, 71 18 66 97
  281.   list 301, 73 26 62 97, vsbar hsbar
  282.  
  283.   button "Delete Table" 4, 3 116 40 11
  284.   button "Delete Item/Value" 5, 46 116 47 11
  285.   button "Delete Value" 6, 98 116 40 11
  286. }
  287. on *:DIALOG:delhash:init:0:{
  288.   didtok delhash 1 32 $regsubex($str(.,$hget(0)),/./g,$hget(\n) $chr(32))
  289.   if ($did(hashview,101).sel) {
  290.     did -ck delhash 1 $v1
  291.     var %a 1,%b $v1
  292.     while $hget(%b,%a).item {
  293.       did -a delhash 201 $v1
  294.       did -a delhash 301 $hget(%b,$v1)
  295.       inc %a
  296.     }
  297.     did -z delhash 201,301
  298.   }
  299. }
  300. on *:DIALOG:delhash:sclick:1:{
  301.   var %a 1,%b $did(1)
  302.   did -r delhash 201,301
  303.   while $hget(%b,%a).item {
  304.     did -a delhash 201 $v1
  305.     did -a delhash 301 $hget(%b,$v1)
  306.     inc %a
  307.   }
  308.   did -z delhash 201,301
  309. }
  310. on *:DIALOG:delhash:sclick:4:{
  311.   if ($did(1) != $null) {
  312.     if ($input(Clicking yes will delete the table $+(',$did(1),') $crlf Are you sure you want to do this?,y,[Hash:Delete Confirmation])) {
  313.       hfree -s $did(1)
  314.       did -r delhash 201,301
  315.       if ($did(1) == $did(hashview,101).seltext) {
  316.         did -r hashview 201,301
  317.         did -d hashview 101 $did(hashview,101).sel
  318.       }
  319.       did -r delhash 1
  320.       didtok delhash 1 32 $regsubex($str(.,$hget(0)),/./g,$hget(\n) $chr(32))
  321.     }
  322.   }
  323. }
  324. on *:DIALOG:delhash:sclick:5:{
  325.   hdel $did(1) $did(201).seltext
  326.   if ($did(1) == $did(hashview,101).seltext) {
  327.     did -d hashview 201,301 $did(201).sel
  328.   }
  329.   did -d delhash 201,301 $did(201).sel
  330. }
  331. on *:DIALOG:delhash:sclick:6:{
  332.   hadd -m $did(1) $did(201).seltext $null
  333.   if ($did(1) == $did(hashview,101).seltext) {
  334.     did -d hashview 301 $did(201).sel
  335.   }
  336.   did -d delhash 301 $did(201).sel
  337. }
  338. ;;;;ALIASES;;;;
  339. alias hashview { dialog -mv hashview hashview }
  340. alias -l edititem { dialog -mv edititem edititem }
  341. alias -l addhash { dialog -mv addhash addhash }
  342. alias -l additem { dialog -mv additem additem }
  343. alias -l delhash { dialog -mv delhash delhash }
  344. alias -l dsearch {
  345.   var %search $$1,%a 1
  346.   if ($$2 == exact) {
  347.     while ($hget(%a)) {
  348.       var %table $v1,%b 1
  349.       while ($hget(%table,%b).item) {
  350.         if ($v1 == %search || $hget(%table,$v1) == %search) {
  351.           if (!$didwm(hashview,101,%table)) { did -a hashview 101 %table }
  352.           else { did -a hashview 101 $chr(32) }
  353.           did -a hashview 201 $hget(%table,%b).item
  354.           did -a hashview 301 $hget(%table,%b).data
  355.         }
  356.         inc %b
  357.       }
  358.       inc %a
  359.     }
  360.   }
  361.   elseif ($$2 == wildcard) {
  362.     while ($hget(%a)) {
  363.       var %table $v1,%b 1
  364.       while ($hget(%table,%b).item) {
  365.         if (%search iswm $v1 || %search iswm $hget(%table,$v1)) {
  366.           if (!$didwm(hashview,101,%table)) { did -a hashview 101 %table }
  367.           else { did -a hashview 101 $chr(32) }
  368.           did -a hashview 201 $hget(%table,%b).item
  369.           did -a hashview 301 $hget(%table,%b).data
  370.         }
  371.         inc %b
  372.       }
  373.       inc %a
  374.     }
  375.   }
  376. }
  377. alias listvar {
  378.   var %i 1
  379.   aline -a @test Variable : Value
  380.   while (%i <= $var(%*,0)) {
  381.     aline -a @test $var(%*,%i) : $var(%*,%i).value
  382.     inc %i
  383.   }
  384. }

Comments