Smart Controls 

Creating a Smart File

 

Just like Smart controls, Smart-enabled files can use query definitions to define source files, columns and selection criteria. In your program, create and open the file that is to receive the data. When using a keyed file, key size should be derived from the length of the data in the first column. Record length should be based on the size of the fields selected in the query definition. Make sure that the channel used to open the file does not have the same number as a control. (If you are using NOMADS, this means keeping it under 9000.)

To load data into the Smart file, make a call to the program *winlist as follows:

call "*winlist", q_name$, q_library$, chan[,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.

 

chan

Channel of the file to write to.

 

var_iol$

(Optional) Compiled IOList of variables to be passed to load logic.

 

var_rec$

(Optional) Values of variables in the IOList derived by REC(var_iol$).

Example:

! Smartfil.prg - Write smart data to a keyed *memory* file
! Uses:
! Smartqry - Query List Object with selected fields from the 'Customer'
! ! file and a linked field from the 'Salesman' file, and
! ! selection criteria to set the Range from FROM$ to TO$
! Smartfile - Interface panel to accept FROM$ and TO$ values and
! ! launch Smartfil.prg
!
     from$=str(from:"000000");
     to$=str(to:"000000") ! Values used by the Query selection criteria
     var_iol$=cpl("IOLIST from$,to$") ! IOLIST of values to be passed
     var_rec$=rec(var_iol$) ! Values to be passed in REC format
     open (hfn)"*memory*";
     channel=lfo ! Open the file to be loaded
! Load the file:
     call "*winlist","Smartqry","nomv51.en",channel,var_iol$,var_rec$
     gosub PROCESS_SMARTFILE ! Process the data file as required
     close (channel)
     end
!
! Dump memory file contents into *viewer* to illustrate
! the raw data generated by the Smart File Interface
PROCESS_SMARTFILE:
     l=0
     open (hfn)"*Viewer*";
     vu=lfo
     print (vu)pad("Data from Smartqry",80)+'LF'
     read (channel,key="",dom=*next)
     while 1
          read record (channel,end=*break)r$
          l++;
          if l>40 \
               then l=0;
                       print (vu)'FF',
          write record (vu)r$
     wend
     close (vu)
     return