Search code examples
scriptingmirc

Set variable in dialog boxes


/set %something sadf

hmm, can I use combo dialog boxes to set a value to variable?

If yes, how?


Solution

  • If you want to set the value of a variable to be equal to whatever is in a combo box, you just need to add an on dialog event. Here's an example of how to do that

    dialog combo {
    
      size -1 -1 100 20
      title "Combo"
      option dbu
    
      combo 1, 5 5 50 10
      button "Set variable", 2, 60 5 35 10
    
    }
    
    on 1:dialog:combo:sclick:2 { 
    
      if ($did(combo, 1) != $null) set %something $did(combo, 1)
    
    }
    
    alias combo dialog -m combo combo
    

    Run /combo, type something in the combo box and press Set variable. The %something variable will be set with what you typed in.