Contents Previous Next Subchapters

A Complex Easy Dialog Example

Description
This example combines various controls in one dialog.

Program
# Initialize O-Matrix
clear
#
# the dialog caption
cap  = "Campus Commuter Form"
#
# one button in dialog
buttons = "Done"
#

msg  = " "
#
# layout for the Name field
name = "textfield, Name, 10, Jane Doe"
#
# popup menu for the Mail field
menu = "HN10, HW4, GH6"
#
# layout for the Mail field
mail = ["popupmenu, Mail, 10, HN10,", menu]
#
# layout for the Student, Faculty and Staff fields
position = { ...
     "checkbox, Student, 2, true", ...
     "checkbox, Faculty, 2, false", ...
     "checkbox, Staff,   2, false" ...
}
#
# layout for the Day fields
day = { ...
     "checkbox, Monday,    2, false", ...
     "checkbox, Tuesday,   2, false", ...
     "checkbox, Wednesday, 2, false", ...
     "checkbox, Thursday,  2, false", ...
     "checkbox, Friday,    2, false" ...
}
#
# layout for the Distance field
dis = "slider, Commute Distance, 20, 1, 1, 50"
#
# fields that are split left and right
layout = [ ...
     {name, mail, position}, ... fields on left side of dialog
     fill(";", 5, 1), ...        separator between fields
     day ...                     fields on right side of dialog
]
#
# Distance field is centered at the bottom
layout = {layout, dis}
#
# make Student, Faculty, Staff fields a set of radio buttons
connections = "radio, Student, Faculty, Staff"
#
# display the dialog
easydlg(cap, buttons, msg, layout, connections)
#
# call back function
function Campus_Commuter_Form(button) begin
     # list of field names
     Name = { ...
          "Name", ...
          "Mail", ...
          "Student", ...
          "Faculty", ...
          "Staff", ...
          "Monday", ...
          "Tuesday", ...
          "Wednesday", ...
          "Thursday", ...
          "Friday", ...
          "Commute Distance" ...
     }
     # get the value for each field
     for i = 1 to rowdim(Name) begin
          name = Name.row(i)
          print name, "=", easydlg(name)
     end
end

Example
If you paste the program above into the command line, the following dialog will be displayed:
The value of all the fields will be displayed in the Command window when you select the "Done" button.