Variable Text on a Button


The text on a button can be derived from a variable. Where width is the width of the button in characters, height is the height of the button in lines, event_name is the name of the event ( a_dlg_button will be set to this value when the button is clicked) and ?condition is an optional logical condition that determines whether the button is enabled or disabled.

The following script displays a dialog with a button labeled "Save File". After the button is clicked, the button changes to "Open File".

button_text = "Save File"
ui_dlg_box("Button Text from a Variable",<<%dlg%
<15,2=button_text!button1> <10,2Close>
if a_dlg_button = "button1" then
    a_dlg_button = ""
    if button_text = "Save File" then
        button_text = "Open File"
        button_text = "Save File"
    end if
end if

This script produces the following dialog and displays variable text on the button:


After you click on the Save File button, the dialog looks like this:



Desktop applications only

See Also