10.5.4. Filtering Object Query Output

Gamma permits the user to control the level of detail reported, and the format used, when an object is queried. This is done by defining a function named _ivar_filter with two arguments. For example, each class instance has a number of instance variables that are reported during interactive mode in the format:

Gamma> stats = qnx_osinfo(0);
{Osinfo (bootsrc . 72) (cpu . 586) (cpu_speed . 18883) (fpu . 587) 
      (freememk . 16328) (machine . "PCI") (max_nodes . 7)
      (nodename . 2) (num_handlers . 64) (num_names . 100)
      (num_procs . 500) (num_sessions . 64) (num_timers . 125)
      (pidmask . 511) (release . 71) (reserve64k . 0)
      (sflags . 28675) (tick_size . 9999) (timesel . 177)
      (totmemk . 32384) (version . 423)}
	  

The following example provides a function named _ivar_filter that controls the output format. Note that each instance variable consists of a name and a value. If we define the following:

function _ivar_filter (!instance,!value)
{
    princ(format("\n%-20s %-20s",
          string(car(value)), string(cdr(value))));
    nil;
}
	  

then the output for Gamma in interactive mode now looks like:

Gamma> stats;
{Osinfo 
      bootsrc         72				  
      cpu             586				 
      cpu_speed       18883			   
      fpu             587				 
      freememk        15544			   
      machine         PCI				 
      max_nodes       7				   
      nodename        2				   
      num_handlers    64				  
      num_names       100		         
      num_procs       500                 
      num_sessions    64                  
      num_timers      125                 
      pidmask         511                 
      release         71                  
      reserve64k      0                   
      sflags          28675               
      tick_size       9999                
      timesel         177                 
      totmemk         32384               
      version         423
      }