Skip to end of metadata
Go to start of metadata

Description

This article outlines a few functions that are extremely useful when using the Field Level Scripting in Loftware.

Most of the Loftware commands involving fields on the label require the use of a long string.

Here is a prime example:

Getting Data
var x = String(label.fields.field.(@name=='inputField').@data);

 It is easy to see how someone could easily mistype this lengthy string.

Functions can be cut and pasted into the script to reduce the required typing.

getData Function
function getData(fieldName)
  {
  return String(label.fields.field.(@name==fieldName).@data);
  }

As a result, the code to assign the data to a variable is as follows:

Using getData Function
var x = getData('inputField');

Functions are best used when a particular command is going to be used multiple times in the script.

How to Implement the Solution

Here are a list of commands and the suggested function.

Examples
//Getting Data
//common command
var x = String(label.fields.field.(@name=='inputField').@data);
 
//function command
varx = getData('inputField');
 
//function
function getData(fieldname)
  {
  return String(label.fields.field.(@name==fieldName).@data);
  }   
 
 
//Putting Data back on the label
//common command
label.fields.field.(@name=='outputField') = x;
 
//function command
putData('outputField',x);
 
//function
function putData (fieldName,output)
  {
  label.fields.field.(@name==fieldName).@data=output;
  }
 
 

 

Article Number

 2014007

Versions

Loftware version 9.5.3 and above

Environment

All supported installation environments.