Program: Superbase Version: 2.0 Topic: Modifications to the .SBP generated by the Dialog Editor Date: January 19, 1993 Summary: After you create a dialog with the Dialog Editor, there are certain steps you need to take to be able to call the dialog from within a program. If your dialog contains list boxes, combo boxes, or nested dialogs, you must make additional changes. Create a dialog using the Dialog Editor 1. Select Dialog Editor from the Program menu. 2. Create and save a dialog. Superbase supplies the .SBP extension automatically and writes code to a procedure that bears the same name as the dialog filename. (For information on how to create dialogs, please refer Chapter 8 in the "Developing Applications" manual.) Add a main() subroutine that displays the dialog 1. Select Program/Edit. 2. Open the .SBP file that contains your dialog. 3. At the beginning of your program, add this section: SUB main() CALL PROGNAME() 'calls routine to define & display the dialog REMOVE DIALOG "Dialogname"' removes dialog from memory END SUB END Note that the dialog procedure name is case-sensitive. 4. Add the following line after the last ADD DIALOG command, but before the END SUB command in your dialog subroutine: DIALOG "Dialogname",n%%' displays dialog and holds button return value in n%% 5. Run the program. If you don't have any list boxes, combo boxes, or nested dialogs, this should display your dialog properly. Make changes for a dialog that contains combo boxes (Type 8) An example of a dialog editor generated ADD DIALOG statement for a combo box is: ADD DIALOG "MyDialog",8,101,77,58,33,2,2,ComboSel$,Combo$ In the above example, the ComboSel$ variable holds the initial value in the combo box, as well as the value that the user selects. The Combo$ array holds the items listed in the combo box. If you have a type 8 dialog object, you need to dimension and populate the array variable for the last parameter in its ADD DIALOG statement. 1. Dimension the array prior to calling the dialog subroutine by using a DIM or GLOBAL statement for the array: DIM Combo$(3) or GLOBAL Combo$(3) These statements can be added to your main routine, or in a separate data declaration subroutine. 2. Put data into the array. An example would be the following FOR...NEXT loop: FOR x%% = 0 to 3 Combo$(x%%) = "Type"+STR$(x%%,"0") NEXT x%% ComboSel$ = Combo$(3)' ComboSel$ is the default value in the combo box These statements can be added to your main routine, or in a separate data initialization subroutine. Make changes for a dialog that contains list boxes (Type 7) An example of a dialog editor generated ADD DIALOG statement for a list box is: ADD DIALOG "MyDialog",7,100,33,58,33,0,0,Listbox$,Selection$,Prompt$ In the above example the Listbox$ array contains the items listed. The Selection$ array contains the item(s) that the user chooses. The Prompt$ variable contains the default value selected in the list. If you have a type 7 dialog object, you need to dimension and populate array variables Listbox$, Selection$ (for the listarray and selectarray parameters) in its ADD DIALOG statement. 1. Dimension the arrays prior to calling the dialog subroutine by using a DIM or GLOBAL statement for the arrays: DIM Listbox$(3),Selection$(0) or GLOBAL Listbox$(3),Selection$(0) These statements can be added to your main routine, or in a separate data declaration subroutine. 2. Put data into the array. An example would be the following FOR...NEXT loop: FOR x%% = 0 to 3 Listbox$(x%%) = "List"+STR$(x%%,"0") NEXT x%% Prompt$ = Listbox$(3)' Prompt$ is the default value for the list box These statements can be added to your main routine, or in a separate data initialization subroutine. Make changes for a dialog that contains a nested dialog You can declare a command button that calls another dialog when pressed. An example of an ADD DIALOG statement with a nested dialog is: ADD DIALOG "MyDialog",1,102,97,40,18,0,"Part2",5,2,"parttwo" In the above case, the dialog that is displayed when this button is clicked is called "parttwo". 1. Create a dialog called "parttwo". You may use the dialog editor. 2. Move the CREATE DIALOG and ADD DIALOG statements for "parttwo" into the same subroutine as "MyDialog". You need to define the nested dialog before the calling dialog. 3. If "parttwo" has any listboxes or comboboxes, make the same changes as listed above. 4. Add the line REMOVE DIALOG "parttwo" to the main subroutine, so it is removed from memory before exiting the program. Sample Code: This code demonstrates a "converted" dialog editor program, which contains list boxes, combo boxes, and nested dialogs. SUB main() REM declare the global variables for dialog values GLOBAL Combo$(3),ListBox$(3),Selection$(0) GLOBAL ComboSel$,Prompt$ REM populate the list box and combo box arrays FOR x%% = 0 TO 3 Combo$(x%%) = "Type" + STR$ (x%%,"0") Listbox$(x%%) = "List" + STR$ (x%%,"0") NEXT x%% ComboSel$ = Combo$(3) 'Default for the combo box Prompt$ = Listbox$(3) 'Default for the list box CALL DIALOGS() 'display the dialogs REM Remove the dialogs from memory REMOVE DIALOG "MyDialog" REMOVE DIALOG "parttwo" END SUB END SUB DIALOGS() CREATE DIALOG "parttwo",4,11,165,90,"Part II","System",10 REM Text item -- type 5 ADD DIALOG "parttwo",5,2,5,156,12,0,"Welcome to Part Two! Please type in this box:" ADD DIALOG "parttwo",6,14,22,118,15,0,0,Editbox$,35' Edit box item -- type 6 ADD DIALOG "parttwo",1,49,58,59,23,0,"Done",1,1' Command Button -- type 1 CREATE DIALOG "MyDialog",4,11,200,150,"Check Out This Dialog","System",10 ADD DIALOG "MyDialog",9,163,9,20,19,3' Icon Button -- type 9 ADD DIALOG "MyDialog",5,8,10,134,13,1,"Here's My Dialog!!"' More text REM The following statement is for a Listbox Item -- type 7 ADD DIALOG "MyDialog",7,100,33,58,33,0,0,Listbox$,Selection$,Prompt$ ADD DIALOG "MyDialog",4,9,43,79,66,0,"Answer"' Group Box -- type 4 ADD DIALOG "MyDialog",3,21,60,52,10,0,"Yes","Option1",Option$' Option Buttons ADD DIALOG "MyDialog",3,21,76,49,9,0,"No","Option2",Option$' Type 3 ADD DIALOG "MyDialog",3,21,91,54,11,0,"Maybe","Option3",Option$ ADD DIALOG "MyDialog",8,101,77,58,33,2,2,ComboSel$,Combo$' Type 8 -- Combo Box ADD DIALOG "MyDialog",1,102,97,40,18,0,"Part2",5,2,"parttwo"' Calls nested dialog ADD DIALOG "MyDialog",1,101,122,42,20,1,"OK",1,1' Command Button OK ADD DIALOG "MyDialog",1,152,122,42,20,0,"Cancel",0,0' Command button - Cancel REM Check Box -- type 2 ADD DIALOG "MyDialog",2,14,124,40,15,0,"Member","Checktrue","Checkfalse",Check$ DIALOG "MyDialog"' Display the dialog END SUB