Module CRADTEST.SRC
1//---------------------------------------------------------------------------
2// CRADTEST.VW
3//
4// Shows various ways to use checkboxes and radios with DDs.
5//
6//======================================================================
7
8Use ALLENTRC
9Use Confirm
10
11Set Class_Colors To U_TEXT_WINDOW 0 0
12
13//---------------------------------------------------------------------
14
15// Create the Customer DD class right here
16
17open ordsys // new system file
18open customer // customers
19open orderhea // new order header file
20
21// Load all required selection lists used by data-sets
22use Customer.sl // Customer selection-list support
23
24// This is used to test file validation tables (the non visual tables). This
25// will build a list of all records from the customer file using default fields
26// for code and description (Code=1=cust# and desc=2=name). Because the list is non
27// static it will rebuild each time it is needed. Normally you do not do this - if
28// you had a lot of records this would be very slow. This is used by customer_number
29
30Object Customer_Table is a FileValidationTable
31 Set Validate_State to False
32 Set Main_File to Customer.File_Number
33 Set Static_State to False//True
34End_Object
35
36// If the above table is used a default code popup list will be used. Here
37// we show how you can create a custom popup list. In this case, the list will
38// only show the description, sort the list and display a title. We will make this
39// our prompt list for customer_number.
40
41Object Customer_Validation_List is a ValidationList
42 Set Sort_State to True
43 Set Code_Display_Mode to CD_Code_Display_Description
44 Set Table_Title to "Customer Names"
45End_Object
46
47Class Customer_Test_DataDictionary is a DataDictionary
48
49 Procedure Define_Fields
50 Forward Send Define_Fields
51
52 Set Main_File to Customer.File_Number
53
54 Set Cascade_delete_State to FALSE // don't delete if children exist
55
56 // List all required child (client) and parent (server) files
57 Send Add_Client_file Orderhea.File_Number
58 Send Add_System_File OrdSys.File_Number DD_Lock_On_New_save
59
60 Define_Auto_Increment Ordsys.Cust_Number to Customer.Customer_Number
61
62 // Define Default Foreign Field options
63 Set Foreign_Field_Options DD_KEYFIELD to DD_FINDREQ
64 Set Foreign_Field_Options DD_INDEXFIELD to DD_AUTOCLEAR DD_NOPUT
65 Set Foreign_Field_Options DD_DEFAULT to DD_DISPLAYONLY
66
67 // Define Individual Fields
68
69 // Number
70 Set Key_Field_State field CUSTOMER.Customer_NUMBER to TRUE
71 Set Field_Options field CUSTOMER.Customer_NUMBER to DD_AUTOCLEAR DD_AUTOFIND DD_NOPUT
72 // This is oddball stuff for testing purposes. Normally this would just use
73 // Customer_sl as its prompt list. This tests file validation tables and popup code
74 // lists.
75 // This defines the popup prompt object to use to display options
76 Set Field_Prompt_Object field CUSTOMER.Customer_NUMBER to (Customer_Validation_List(self))
77 // This defines the code table to use for this field
78 Set Field_Value_Table field Customer.Customer_Number to (Customer_Table(self))
79
80 // Name
81 Set Field_Prompt_Object field CUSTOMER.Name to (Customer_SL(self))
82
83 // City - kind of silly but it lets us test checkboxes.
84 Set Field_Checkbox_Values field CUSTOMER.CITY to "Miami" "San Diego"
85
86 // State
87 Set Field_Options field CUSTOMER.STATE to DD_CAPSLOCK
88 Set Field_Value_Check field CUSTOMER.STATE to "CA|WA|FL|NV|OR|TX|IL|RI|AZ|GA|MD|CO"
89
90 Set Field_Options Field Customer.Purchases To DD_DISPLAYONLY
91 Set Field_Options Field Customer.Balance To DD_DISPLAYONLY
92 End_Procedure // Define_Fields
93
94 Procedure Field_defaults
95 Set Field_Changed_Value field customer.state to "CA"
96 Set Field_Changed_Value field Customer.Credit_Limit to 1000
97 Set Field_Changed_Value field Customer.City to "Miami"
98 End_Procedure
99
100End_Class
101
102//--------------------end of dd------------------------------------------
103
104/Cust_Form
105┌─ Customer Entry Form: ─────────────────────┐
106│ Customer Number: _____. │
107├────────────────────────────────────────────┤
108│ Name: ______________________________ │
109│ Adrs: ______________________________ │
110│--------------------------------------------│
111│ City: ______________ ______________ │
112│ │
113│--------------------------------------------│
114│ │
115│ │
116│ │
117│ │
118│ │
119├─Comments───────────────────────────────────┤
120│ │
121│ │
122│ │
123└────────────────────────────────────────────┘
124/State_Img
125State:__
126/City_Img
127_________ _____________
128/States_img
129┌States───┐
130│_______ │
131│_______ │
132│_______ │
133└─────────┘
134/State2_img
135┌──────────────┐
136 State: ______
137└──────────────┘
138/Zip_etc_img
139Zip: __________
140Credit Limit $______.__
141Purchases $______.__
142Balance $______.__
143/*
144
145
146Activate_View Activate_Customer FOR Cust_entry
147
148Object Cust_Entry is an Entry_View_Client No_Image ;
149// Action_Bar (Main_Menu(self))
150
151 Object Customer_dd is a Customer_Test_DataDictionary
152 set cascade_delete_state to true // test- should generate an error because
153 // invalid DDO structure for cascade deletes
154 End_Object
155
156 Set main_dd to (Customer_dd(self))
157 Set Server to (Customer_dd(self))
158
159 Set Verify_Save_MSG to GET_Save_Confirmation
160 Set Verify_Delete_MSG to GET_Delete_Confirmation
161 Set Verify_Data_Loss_MSG to GET_Data_loss_Confirmation
162 Set Verify_Exit_MSG to GET_Exit_loss_Confirmation
163
164
165 Object Cust_Form is an Entry_Form Cust_Form
166
167 Set Location To 2 10 Relative
168 Set Allow_Move_State to TRUE
169
170 Item_List
171 Entry_Item CUSTOMER.CUSTOMER_NUMBER
172 Entry_Item CUSTOMER.NAME
173 Entry_Item CUSTOMER.ADDRESS
174 Entry_Item CUSTOMER.CITY
175
176 // checkbox
177 // In forms checkboxes are turned on with the Set Checkbox_Label
178 // message. This must follow the entry_item to be made a checkbox passing
179 // the label for the checkbox.
180 // In tables checkboxes are enabled with Set Column_Checkbox_state (we
181 // assume that tables will not have checkbox labels
182 Entry_Item CUSTOMER.CITY
183 Set Checkbox_Label to "Miami"
184 End_Item_List
185
186 // sample of how to create a radio list. Note that changes
187 // if the radio is reflected in other DEOs using the same file
188 // field (and visa versa)
189 Object City is a Radio_Entry_Form city_img for customer.city
190 Set location to 7 8 relative
191 End_Object
192
193 // show three ways to display a list of choices (code lists or
194 // check lists.
195 // 1. Use a standard form and select the items with a popup code list
196 // 2. Create a scrolling radio list
197 // 3. Create a single item spin form
198 Object Cust_Form2 is an Entry_Form State_Img
199
200 Set Location To 10 2 Relative
201
202 Item_List
203 Entry_Item CUSTOMER.STATE
204 End_Item_List
205 End_Object
206
207 Object States is a Radio_Entry_Form states_img for customer.state
208 Set location to 9 14 relative
209 set sort_state to true
210 End_Object
211
212 // creat "spin style" deo
213 Object State2 is a Radio_Entry_Form state2_img for customer.state
214 Set location to 9 25 relative
215 Set Select_mode to no_select
216 Set Radio_State to False
217 Set Search_Mode to First_Character
218
219 // customize the radio output
220 Function Code_Description_Value string DescVal string DataVal ;
221 returns string
222 integer Cnt
223 Get Item_Count to Cnt // this is the # to get added
224 // Fun with string expressions - think about it!
225 Function_Return ( (Character(Ascii("A")+Cnt)+"." * ;
226 lowercase(DescVal)))
227 End_Function // Code_Description_Value
228
229 End_Object
230
231 Object Comments_Editor is a Text_Window For CUSTOMER.COMMENTS
232 Set Location To 15 2 Relative
233 Set Size To 3 42
234 End_Object // Comments_Editor
235
236 End_Object // Cust_Form
237
238End_Object // Cust_Entry
239
240send activate to cust_entry
241start_UI
242