&routine formgen &define i -11 &var &define j -12 &var &define resp -13 &var &define numit -14 &var &define wksp -18 &var &define temp -19 &var &value [resp] -1 &value [wksp] WKSP &rem **** load item names and definitions &openw [wksp]t$temp.lis ITEMS &closew &open [wksp]t$temp.lis error &sv [i] 501 &while &do &read [j] [break] &extract [temp] [j] 1 &if &nm "[temp]" &do &extract -2 [j] 2 &extract -3 [j] 3 &sv -3 %-3 (I3) &extract -4 [j] 4 &extract -5 [j] 5 &sv -5 %-5 (I2) &if &eq "x[resp]" "x" &or &cn "[resp]" " %-2," &do &sv %[i] 0 "(I1,T1,'%-2',T13,'%-3',T17,'%-4',T19,'%-5')" &inc [i] &end &end &end &close &cv [numit] [i] - 501 &rem **** generate dialog box file &openw [wksp]t$forms.dlg &write "BEGIN 100 4 0 17 60 v" &write "DROP -101 0 0 11.0 14 f" &write "PBUT -99 0 15 1.5 8 v OK" &write "PBUT -98 0 24 1.5 8 v Cancel" &sv [i] 1 &while &rn [i] 1 10 &do &cv -1 109 + ( [i] * 2 ) &cv -2 %-1 + 1 &cv -3 2 + ( ( [i] - 1 ) * 1.5 ) &write "LTEXT %-1 %-3 0 1.5 20 f" &write "EBOX %-2 %-3 20 1.5 40 f" &inc [i] &end &write "END" &rem **** populate list box with items &write "L 101" &sv [i] 1 &while &rn [i] 1 [numit] &do &cv [j] [i] + 500 &extract [temp] %[j] 1 &write "[temp]" &inc [i] &end &closew & DEL [wksp]t$temp.lis &return [numit] &rem **** I/O error trap &label error &type "I/O Error" &return&r formgen {item_list}
Note that the routine expects the item list to be formatted as follows:
" item_1, item_2, ... item_n,"The space before and comma after each item helps the routine to locate exact matches with a single statement (see the example at the end of this section for code to build the item list from individual item names supplied as arguments). The first part of the routine loads item names and definitions into SML variables starting at 501. If the argument variable is blank, all items are loaded; otherwise, only those items contained in the list are loaded. Once the items are loaded, the dialog file is built and the drop-down box populated with item names:
LTEXT and EBOX widgets have alternating ID values:
111 112 113 114 etc.At this point, the LTEXT and EBOX widget values are not yet set. The next routine provides the dialog box handling:
&routine formdo &define i -11 &var &define j -12 &var &define resp -13 &var &define pointer -14 &var &define ok -15 &var &define numit -16 &var &define title -17 &var &define wksp -18 &var &define temp -19 &var &define winrtn 1 &var &sv [pointer] 501 &value [wksp] WKSP &value [numit] -1 &value [title] -2 &rem **** load item values SHOW SELECT 1 -7 SHOW EDITFEATURE -8 &sv [i] 1 &while &rn [i] 1 [numit] &do &extract -2 %<[i] + 500> 1 &extract -4 %<[i] + 500> 3 SHOW %-8 %-7 ITEM %-2 [temp] &if &eq %-4 D &do &rem **** reformat date value &value -1 [temp] 3 4 &value -2 [temp] 5 6 &value -3 [temp] 7 8 &sv [temp] "%-2/%-3/%-1" &end &value %<[i] + 600> [temp] &inc [i] &end &rem **** put up dialog box and process resp WIN DB C [wksp]t$forms.dlg &sv [ok] .FALSE &while &ne [ok] .TRUE. &do &r forminit [pointer] [numit] "[title]" WIN DB R [wksp]t$forms.cmd &sv [resp] [winrtn] &rem WIN FOCUS T &if &eq [resp] -1 &or &eq [resp] 49 &do WIN DB D &return [ok] &end &if &eq [resp] 98 &do WIN DB D &return [ok] &end &rem **** store current values &sv [i] 1 &while &rn [i] 1 10 &do &cv [temp] 500 + [numit] &cv [j] [i] + [pointer] - 1 &if &rn [j] [pointer] [temp] &do &value %<[j] + 100> %<110 + ( [i] * 2 )> &end &inc [i] &end &if &eq [resp] 99 &or &eq [resp] 50 &do WIN DB D &sv [ok] .TRUE. &else &rem **** reposition pointer &sv [i] 1 &while &rn [i] 1 [numit] &do &extract [temp] %<[i] + 500> 1 &if &eq [temp] %101 &do &cv -1 [i] + 500 &end &inc [i] &end &value [pointer] -1 &end &end &rem **** calculate attributes &sv [i] 1 &while &rn [i] 1 [numit] &do &value -1 %<[i] + 500> &value -2 %<[i] + 600> &extract -3 -1 1 &extract -4 -1 3 &value -5 -2 &if &eq "%-4-" "D-" &or &eq "%-4-" "N-" &do CALC %-3 = %-5 &elseif &eq "%-4-" "C-" &do MOVEITEM '%-5' TO %-3 &end &inc [i] &end &return [ok]&r formdo [numit] {title}
The first step is to load the item values of the first feature in the selection set into SML variables starting at 601. Note the special handling of date values because the SHOW command returns dates in "yyyymmdd" format, the routine reformats the value to "mm/dd/yy".
Then the dialog box is put up, initialized, and responses processed. When either the OK button is clicked (or the <Enter> key pressed) or the drop-down box selection is changed, the current EBOX values are saved to the item value variables. When the drop-down box selection is changed, the item pointer is reset and the LTEXT and EBOX values reinitialized accordingly. When the OK button is clicked, the selection set attributes are recalculated according to the item value variables. Otherwise, the routine is cancelled. The following routine generates the command file to initialize the dialog box:
&routine forminit &define pointer -1 &var &define numit -2 &var &define title -3 &var &define i -11 &var &define j -12 &var &define wksp -18 &var &define temp -19 &var &value [wksp] WKSP &rem **** generate command file &openw [wksp]t$forms.cmd &write "S 100 [title]" &extract [temp] %[pointer] 1 &write "S 101 [temp]" &sv [i] 1 &while &rn [i] 1 10 &do &cv [temp] 500 + [numit] &cv [j] [i] + [pointer] - 1 &cv -5 109 + ( [i] * 2 ) &cv -6 %-5 + 1 &if &rn [j] [pointer] [temp] &do &value [temp] %[j] &extract -13 [temp] 1 &extract -14 [temp] 2 &extract -15 [temp] 3 &extract -16 [temp] 4 &write "S %-5 [temp]" &if &eq %-15 C &do &write "B %-6 %-14 2" &elseif &eq %-15 D &do &write "B %-6 %-14 1" &elseif &eq %-16 0 &do &if &rn %-14 1 10 &do &write "B %-6 %-14 3" &else &write "B %-6 10 3" &end &else &if &rn %-14 3 20 &do &write "B %-6 %-14 4" &else &write "B %-6 20 4" &end &end &value -18 %<[j] + 100> &write "S %-6 %-18" &write "E %-6" &else &write "S %-5" &write "S %-6" &write "G %-6" &end &inc [i] &end &write "F 112" &closew &return&r forminit [pointer] [numit] {title}
First, the title of the dialog box is set. Then, the drop-down box is set to the value of the item name indicated by the pointer variable. Beginning at the current pointer position, item definition definitions are examined. Because the contents of the item variable are preformatted by routine FORMGEN, the corresponding LTEXT widget may be set verbatim. The B dialog command for the EBOX widget is set according to the item definition, and the EBOX value is set to the contents of the item value variable. Finally, focus is sent to the first EBOX.
The above routines may be applied to edit a logically selected feature or to calculate multiple items for an entire selection set:
&routine gform &define i -11 &var &define resp -12 &var &define numit -13 &var &define temp -19 &var &rem **** read arguments &sv [i] -1 &while &rn [i] -10 -1 &do &extract [temp] %[i] 1 &if &ne "x[temp]" "x" &do &sv [resp] "[resp] [temp]," &end &dec [i] &end &rem **** generate dialog box file &r formgen "[resp]" &rv [numit] &r formdo [numit] "Global Edit" &return&r gform {item_1} ... {item_n}
The above routine formats a list of up to ten item names, generates the forms dialog box, and then invokes it. Item values for the first feature in the selection set are loaded into the dialog box:
Once any edits are made and the OK button clicked, the resulting values will be applied to all selected features.
In a future article I plan to show how the above routines may be modified to support the cursor-style forms used in Host ARC/INFO.
&value -1 ARC &value -2 WKSP &sv -3 %-1/UTOOL/QCHECK/ &openw %-2q_disp.dlg &write "BEGIN 0 5.00 1.00 2.00 24.00 v Display" &write "UBUT -201 0.00 0.00 2.00 4.00 b %-3qc~01.dis" &write "UBUT -202 0.00 4.00 2.00 4.00 b %-3qc~02.dis" &write "UBUT -203 0.00 8.00 2.00 4.00 b %-3qc~03.dis" &write "UBUT -204 0.00 12.00 2.00 4.00 b %-3qc~04.dis" &write "UBUT -205 0.00 16.00 2.00 4.00 b %-3qc~05.dis" &write "UBUT -206 0.00 20.00 2.00 4.00 b %-3qc~06.dis" &closew WIN DB C %-2q_disp.dlg
Note that the full path and filename of an image must be given. Otherwise, a plain gray button will appear. If no image is specified, the button will be invisible (I plan to discuss using COORD vs. UBUT to build clickable image maps in a future article).
The image file format is the same as that used by the WIN PLOT command. Thus a coverage could be used to create icons:
&rem set DISPLAY 4 before executing &rem **** set WIN PATH to current directory &r curdir &rv -1 WIN PATH %-1 &sv -11 1 &label do01 CLEAR CLEARSELECT SHADESET COLOR255.SHD LINESET PLOTTER.LIN RES ICONS POLY ICON = %-11 PAGESIZE 2 2 MAPE POLY ICONS SHOW MAPE -1 -2 -3 -4 &cv -5 ( %-3 - %-1 ) / 22 &cv -6 ( %-4 - %-2 ) / 22 MAPE %<%-1 + %-5> %<%-2 + %-6> %<%-3 - %-5> %<%-4 - %-6> WIN PLOT qc~0%-11.dis RES ICONS POLY SYMBOL <> 0 RES ICONS POLY SYMBOL <> 999 POLYGONSHADES ICONS SYMBOL ASEL ICONS POLY RES ICONS POLY SYMBOL = 999 POLYGONSHADES ICONS 0 RES ICONS LINE SYMBOL <> 999 ARCLINES ICONS SYMBOL NSEL ICONS LINE LINESET COLOR255.lin ARCLINES ICONS 9 WIN PLOT &cv -11 %-11 + 1 &goback do01 &if &rn %-11 1 6 &label end01Note that DRAWW may be used to view DIS files (also SCREENRESTORE in the Windows extensions).
The BMPDIS command may be used to create icons from Windows bitmap files (higher resolution bitmaps will result in smoother graphics):
BMPDIS icon.bmp icon.dis WBefore:
After:
There's more fun with widgets to come, but first I want to get into a topic that's long overdue.