User fields

Top  Previous  Next

The 'fields' property


The 'fields' property is an array of objects, each one having the following structure describing each field element:


Property name



A string constant that identifies the field element.


The row's field location, using the host screen row/column coordinates.


The column's field location, using the host screen row/column coordinates.


The length of the field, expressed as the number of characters.


An optional getter function to retrieve and transform field content.


An array of fields that defines the field property as an array.


Please note that fields explicitly declared in this property, are added to the field collection automatically created by HostSurfer from the current screen.

The following code snippet shows how field objects are declared within a rule:



fields : [

   { name : 'screenTitle', row : 1, col : 35, len : 30, get : function (value) { return value.trim() } },

   { name : 'option', row : 18, col : 63, len : 2 }



It is also possible to declare a field being an array of inner fields, for array grouping purposes:



   name : 'label', fromRow : 16, toRow : 19, items : [


           name : 'caption', col : 25, len : 20, get : function (value) {

              return value.toLowerCase().replace(/\b\w/g, function (l) { return l.toUpperCase() })




       skip : function (obj) {

          return false;


       break : function (obj) {

          return false;




The field declaration in the above code snippet, illustrates how a field named 'label' is composed as a result of iterating from row 16 to row 19, thus creating an array of property fields with 'caption' key, located at column 25 with a length of 20 characters, and a value resulting from the specified getter function. Such structure has optional  'skip' and 'break' property keys, which values are condition evaluating functions. The 'skip' property defines a condition upon which a row included within the bounds 'fromRow' and 'toRow', is skipped on the iteration. The 'break' property determines the condition upon which the iteration is halted.


As an example of use of this property:


 var caption1 =[0].caption;

 var caption2 =[1].caption;

 var caption3 =[2].caption;


As shown in the example below, it is possible to include a regular expression as a 'match' condition to select the fields on the iteration between the specified starting and ending rows.



   name : 'pfkeys', fromRow : 22, toRow : 24, match : '(F[0-9]{1,2})\\s*:\\s([^:]+)(?:(?=F[0-9]{1,2})|$)', items : [

       { name : 'pf', index : 1 },

       { name : 'desc', index : 2 }

   ], skip : function (obj) {

      return (obj.desc == '');

   }, break : function (obj) {

      return false;




Example code: {

 document.write('<br><b>''</b> - '+pfkey.desc+'</br>');