Script to Pull Numeric Data from a String
Description
How do you pull all the numeric data from a field?
Follow these steps:
- Set up a scripting field, an input field and an output field.
- Modify the example below using the names of the fields on your label.
- Copy the modified script into the scripting field data source window.
Copy
Sample Script
<pre class="syntaxhighlighter-pre" xml:space="preserve">var result = "";
var input = String(label.fields.field.(@name == 'input').@data);
// for loop
for (i=0; i < input.length; i++)
// if statement using "or" logic - ||
{if (input.charAt(i) < '0' || input.charAt(i) >'9')
{
result = result;
}
else
{
result = result + input.charAt(i);
}
}
label.fields.field.(@name == 'output').@data = result;
</pre>
Article Number
2016011
Versions
Loftware Label
A label is a design area on the computer screen where a label format is created or edited. Manager / Loftware Print Server versions 9.5.2.0 - 11.1
Environment
All supported installation environments.