# Smart Controls

Using Smart Controls Outside of NOMADS |

Smart controls are designed to work within the confines of NOMADS. It is possible, however, to invoke the auto-load logic for Smart List Box, Drop Box and Grid controls programmatically. To load the Smart control, make a CALL to the program *winlist as follows:

> CALL "*winlist", q_name$, q_library$, smartlist.ctl [,var_iol$, var_rec$]

Where:

| q_name$ | Name of the query object definition to be used.
| q_library$ | Name of the library in which the query object definition is located. If null, default is the currently open library.
| smartlist.ctl | CTL value of the list box to be loaded.
| var_iol$ | (Optional) Compiled IOList of variables to be passed to the Load logic.
| var_rec$ | (Optional) Values of variables in the IOList derived by REC(var_iol$ ).

#### Note:
If you want to use *winlist to auto-load a Formatted List Box using the format from the query object, it is necessary to define the List Box with a format of L1 so that it can be differentiated from a Standard List Box that has no format. (This is not necessary for Report View format whose format can be left blank.)

A native chart can also be auto-loaded by making a CALL to the program *TOOLS/CHARTIMAGE:

> CALL "*tools/chartimage", ERR=stmtref, query$, library$, chart$, control, [,controlSettings, var_iol$, var_rec$]

| query$ | Name of the query which owns the chart.
| library$ | Path of the library where the query definition resides.
| chart$ | Name given to the AutoChart definition associated with the query. (Must be a public definition)
| control | CTL value of the chart control to be loaded.
| controlSettings | Values are: 0 - Use chart format/titles from the Query+ AutoChart definition 1 - Use chart format/titles from the control definition
| var_iol$ | (Optional) Compiled IOList of variables to be passed to the Load logic. (added in PxPlus 2019 Update 1)
| var_rec$ | (Optional) Values of variables in the IOList derived by REC(var_iol$). (added in PxPlus 2019 Update 1)
| stmtref | Error transfer.

Plus charts may also be auto-loaded. To do this, instantiate the *OBJ/CHART object and load it using the CALL to *tools/chartimage. Once loaded, use the Draw( ) method to display the chart. When done, drop the chart object:

> oChart=new("*obj/chart")
> call "*tools/chartimage","Salesqry","query.en","Sales by Class",oChart,0
> oChart'Draw(0,5,5,40,15)
> drop object oChart

(The *tools/chartimage program was added in PxPlus 2019.)