You're welcome. grin

I'll add some comments, just to show you how we did it and that we're on the same wave length.. smile

Code:
menu channel {
  $iif($dialog(rand),$style(7)) Msg/Describe: { dialog -dm rand rand }
}

On *:Text:*match text*:#: {
  rand $r(a,b)
}

on 1:Start: {  
  [color:green];We make our tables with 1000 slots, this is where we store all our random messages.[/color]
  hmake message 1000 
  hmake describe 1000
  [color:green];Here we check if our data files exist, and if they do, we load in our data to our database (table) which we just created with hmake
  [/color]
  if ($isfile(msg.hsh)) {   
    hload -o message msg.hsh 
  }
  if ($isfile(desc.hsh)) {   
    hload -o describe desc.hsh 
  }
}
[color:green]
;This is our dialog, this is where you type in your random words.
[/color]
dialog rand {
  title "Random Msg / Describe"
  size -1 -1 154 163
  option dbu
  combo 1, 4 14 70 98, size
  combo 2, 77 14 70 98, size
  text "                   /msg                                      /describe", 3, 3 3 149 8
  button "Add", 4, 16 113 22 12
  button "Del", 5, 39 113 22 12
  button "Del", 6, 113 113 22 12
  button "Add", 7, 90 113 22 12
  button "Close", 8, 61 142 37 12
}
[color:green]
;The two aliases below is ewhat makes everything possible. Here we perform a while loop which will loop through all our items in the table and then display our random words in the dialog for you to add/delete.
[/color]
alias getmsg {
  [color:green]
  ;Here we simply check if our hash table exists and there's atleast 1 item in our hash table.
  [/color]
  if (($hget(message) && $hget(message,0).item) > 0) { 
    [color:green]
    ;We've established there's more than one item so now we're looping through all our entries.
    [/color]    var %msg = $hget(message,0).item
    while (%msg) {
      if ($dialog(rand)) {
        [color:green]
        ;We've now finished our looping, our items have now been retrieved.  We're ready to display our data in our dialog.
        [/color]
        did -a rand 1 $hget(message,%msg).data
        dec %msg
      }
    }
  }
  [color:green]
  ;This means that if there's no items to display, we halt the operation.
  [/color]
  elseif (($hget(message) && !$hget(message,0).item)) {  return 
  }
}

[color:green]
;Same as the above alias, only this is for describe, not msg.
[/color]
alias getdesc {
  if (($hget(describe) && $hget(describe,0).item) > 0) { 
    var %desc = $hget(describe,0).item
    while (%desc) {
      if ($dialog(rand)) {
        did -a rand 2 $hget(describe,%desc).data
        dec %desc
      }
    }
  }
  elseif (($hget(describe) && !$hget(describe,0).item)) {  return 
  }
}

on 1:dialog:rand:init:0: {
  [color:green]
  ;The 2 -b switches disable the "Del" button until an item in the combo box has been selected.
  [/color]
  did -b rand 5
  did -b rand 6
  [color:green]
  ;We are getting our database entries.
  [/color] 
  getmsg
  getdesc
}

[color:green]
;When we close our dialog, the databases are saved.
[/color]
on 1:dialog:rand:close:0: {
  hsave -o message msg.hsh
  hsave -o describe desc.hsh
}

[color:green]
;When a data entry has been selected in the combo box, the delete button is then enabled.
[/color]
on 1:dialog:rand:sclick:1: {
  if ($did(rand,1).sel) { 
    did -e rand 5
  }
}

[color:green]
;Same as above, only this time with combo box 2.
[/color]
on 1:dialog:rand:sclick:2: {
  if ($did(rand,2).sel) { 
    did -e rand 7
  }
}

on 1:dialog:rand:sclick:4: {
  [color:green]
  ;Again, this checks if the table exists.
  [/color]
  if ($hget(message)) {
    [color:green]
    ;It does exist, now we check if we have type in a data entry in the combo box.
    [/color]
    if ($did($dname,1).text) {
      [color:green]
      ;We did type an entry, we now add that entry to the dialog, and its written into the database.
      [/color]
      did -a rand 1 $did($dname,1).text
      hadd message $didwm(rand, 1,$did(rand,1).text) $did($dname,1).text
    }
  }
}

on 1:dialog:rand:sclick:5: {
  [color:green]
  ;This checks if we've clicked an item in the combo.
  [/color]
  if ($did($dname,1).sel) {
    [color:green]
    ;Again, this checks if the table exists.
    [/color]
    if ($hget(message)) {
      [color:green]
      ;It does exist, we're now deleting the entry from the database, and removing it from the dialog.
      [/color]
      hdel message $didwm(rand, 1,$did(rand,1).seltext)
      did -d rand 1 $didwm(rand, 1,$did(rand,1).seltext)
      [color:green]
      ;This disables our "Del" button again.
      [/color]
      did -b rand 5 
    }
  }
}

[color:green]
;Ass above only this checks for adding and deleting on the combo 2.
[/color]

on 1:dialog:rand:sclick:6: {
  if ($did($dname,2).sel) {
    if ($hget(describe)) {
      hdel describe $didwm(rand, 2,$did(rand,2).seltext)
      did -d rand 2 $didwm(rand, 2,$did(rand,2).seltext)
      did -b rand 6
    }
  }
}

on 1:dialog:rand:sclick:7: {
  if ($hget(describe)) {
    if ($did($dname,2).text) {
      did -a rand 2 $did($dname,2).text
      hadd describe $didwm(rand, 2,$did(rand,2).text) $did($dname,2).text
    }
  }
}
[color:green]
;For some stupid reason I added the close dialog event twice, it's either because I am tired, or it only took just over an hour so I kind of rush things.  So you can either remove this one or the above one.  My apologies.
[/color]
on 1:dialog:rand:close:0: {
  hsave -o describe desc.hsh
  hsave -o message msg.hsh
}

[color:green]
;Our alias for messaging, typing /rand a sends a msg to the target window with a random msg.  And /rand b sends an action to the target window with a random action
[/color]

alias rand {
  if ($1 == a) { msg $target $hget(message,$r($hget(message,0).item,1)) }
  if ($1 == b) { describe $target $hget(describe,$r($hget(describe,0).item,1)) }
}

Last edited by SladeKraven; 22/01/05 03:28 AM.