Underlining in the listing refers to the
language concepts: It shows which parts of the code are taken from models and thus
what can vary between the applications.
Lines 1 and 17 are simply the structure for a generator and line 2 is a comment for
the generator module. Line 3 creates the function de?¬?nition signature and line 4 is a
comment for the Python code. Function naming in line 3 calls another generator
module that creates a unique function name if the developer has not given a name for
the pop-up menu in the application design model.
Listing 8.1 Code generator for pop-up menu.
01 Report '_Popup_menu'
02 /* Produces popup menu-style dialog code */
03 'def ' subreport '_Internal name' run '():' newline
04 '# Popup menu ' :Label newline
05 if :Return variable (optional); then
06 ' global ' subreport '_Return variable name' run newline
07 endif
08 ' choices' oid ' = ['
09 dowhile :List { 'u"' id '", ' }
10 '"]' newline
11 ' index = appuifw.popup_menu(choices' oid ', u"' :Label '")'
newline
12 ' if index <> None:' newline
13 ' ' subreport '_Return variable name' run '= choices' oid
'[index]' newline
14 ' if index == None:' newline
15 subreport '_Back' run
16 subreport '_next choiced element' run
17 endreport
Lines 5??“7 declare the return variable, if this pop-up has one. Lines 8??“10 create a
temporary variable that includes the choices given for the list in a Unicode string.
Pages:
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333