Scenario: You have to output all the subsequent characters following the ‘-‘ character of a field value coming from a datastream however, the string length of the value can vary from 3 characters on-wards, i.e. the value is never fixed.
- Open the process.
- Add the variable version of the field you wish to format.
- Right-click on the variable and select Edit Script…
- Insert the following code:
$a = $lotnumber;
//searches string of $a for ‘-‘ and gets a position number
//adds 1 to the ‘-‘ position number to get next position
$c = num($b)+ 1;
//gets substring starting at ‘next’ position
$lotnumber = substr($lotnumber,$c);
- Click OK.
Export, deploy and test!
- If the field value is 1234-567 you will output 567
- IF the field value is -123 you will output 123
- If the field value is 34-4533345689 you will output 4533345689