String Manipulation

This action defines how the values of selected variables should be formatted.

The most popular string manipulation actions are: delete leading and trailing spaces, search and replace characters, and delete opening and closing quotes.

This feature is often required is a trigger receives an unstructured data file or legacy data. in such cases, the data needs to be parsed using the Unstructured Data filter. String Manipulation action allows you to fine-tune the data value.

Note

If this action doesn't provide enough string manipulation power for a particular case, use Execute Script action instead to manipulate your data using Visual Basic Script or Python scripts.

UUID-e7689da1-7fbe-e698-af8e-884c627bf335.png

About group identifies the selected action.

  • Name: allows you to define a custom action name. This makes actions easily recognizable on the solution's list of actions. By default, the action name is taken from its type.
  • Description: custom information about the action. Enter a description to explain the purpose and role of action in a solution.
  • Action type: read-only information about the selected action type.

Variables group defines the variables whose values need to be formatted.

  • All variables: specifies all the defined variables in a data file to be formatted.

  • Selected variables: specifies a selection of variables to be formatted from the data file.

Format Text group defines string manipulation functions that apply to the selected variables or fields. Multiple functions can be used. The functions apply in the same order as seen in the editor – from top to bottom.

  • Delete spaces at the beginning: deletes all space characters (decimal ASCII code 32) from the beginning of the string.

  • Delete spaces at the end: deletes all space characters (decimal ASCII value 32) from the end of a string.

  • Delete opening closing characters: deletes the first occurrence of the selected opening and closing characters that is found in the string.

    Example 100. Example

    If using "{" as opening character and "}" as closing character, the input string {{selection}} is converted to {selection}.

  • Search and replace: executes standard search and replace function upon the provided values for find what and replace with. Regular expressions are supported.

Note

Several implementations of regular expressions are present. Loftware uses .NET Framework syntax for the regular expressions. For more information, see .NET Framework Syntax for Regular Expressions.

  • Replace non printable characters with space: replaces all control characters in the string with "space" character (decimal ASCII code 32). Non printable characters are characters with decimal ASCII values between 0–31 and 127–159.

  • Delete non printable characters: deletes all control characters in the string. Non printable characters are characters with decimal ASCII values between 0–31 and 127–159.

  • Decode special characters: decodes the characters (or control codes) that are not available on the keyboard, such as Carriage Return or Line Feed. Loftware uses a notation to encode such characters in human-readable form, such as <CR> for Carriage Return and <LF> for Line Feed. This option converts special characters from Loftware syntax into actual binary characters.

    Example 101. Example

    When you receive the data "<CR><LF>", Desktop Designer uses it as plain string of 8 characters. You will have to enable this option to interpret and use the received data as two binary characters CR (Carriage Return – ASCII code 13) and LF (Line Feed – ASCII code 10).

  • Search and delete everything before: finds the provided string and deletes all characters in front of the defined string. The string can also be deleted.

  • Search and delete everything after: finds the provided string and deletes all characters behind the defined string. The string can also be deleted.

Action Execution and Error Handling

Each action can be set as a conditional action. Conditional actions only run when the defined conditions allow them to be run. To define these conditions, click Show execution and error handling options.

Execution options are:

  • Enabled: specifies if the action is enabled or disabled. Only enabled actions will execute. This functionality may be used while testing a form.
  • Condition: defines one-line programming expression that must provide a Boolean value (true or false). When the result of the expression is true, the action will execute. Condition offers a way to avoid executing actions every time.

Error handling options are:

  • Ignore failure: specifies whether an error should be ignored. If enabled, the execution of actions continues even if the current action fails.

    Note

    Nested actions that depend on the current action do not execute in case of a failure. The execution of actions continues with the next action on the same level as the current action. The error is logged but does not break the execution of the action.

  • Example

    At the end of printing, you might want to send the status update to an external application using the HTTP Request action. If the printing action fails, action processing stops. In order to execute the reporting even after the failed print action, the Print Label action must have the option Ignore failure enabled.

  • Save error to variable: allows you to select or create a variable to save the error to. The same cause of the error is also saved to internal variables ActionLastErrorId and ActionLastErrorDesc.