User Tools

Site Tools


visual3d:documentation:pipeline:general_information:string_data

String Data

String data is fundamentally different from time-varying signals and metrics so we have created a collection of string-specific functions within Evaluate_Expression to allow common string manipulations to be accomplished within your pipeline scripts.

Syntax

The expression parser reads through the provided expression as one large string and parses out the specific variables, data and operators. Because Visual3D has no way to recognize the difference between a literal string and a variable name, it is necessary to use quotes around string data, e.g., subject_name=“John Smith”. String parameters in the pipeline are not quoted.

Literal String Data

Strings can be explicitly created within a pipeline script without having to be stored as a pipeline variable. To accomplish this, all that needs to be done is to use quotes.

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST_STRING
/EXPRESSION="A123456789"
/AS_INTEGER=FALSE
;

The result of this command is

::TEST_STRING = A123456789

Concatenation

Literal string data must be explicitly concatenated with values from parameters. For example, there is a problem with the following Evaluate_Expression syntax:

Evaluate_Expression
/EXPRESSION=(::HandChoice="LEFT")
/RESULT_NAME=TEST_4
! /RESULT_TYPE=DERIVED
! /RESULT_FOLDER=PROCESSED
;

This uses a pipeline parameter in the middle of a string parameter (the EXPRESSION). Global parameters cannot be evaluated in the middle of a string, so to recognize that a pipeline parameter, you need to concatenate it into the expression as follows:

Evaluate_Expression
/EXPRESSION=(&::HandChoice&="LEFT")
/RESULT_NAME=TEST_4
! /RESULT_TYPE=DERIVED
! /RESULT_FOLDER=PROCESSED
;

Negation

Operators are only parsed as a single character, so the “/=” notation for “not equals” cannot be used. It is also not possible to use the “!=” notation for “not equals” either because the “!” character is dedicated to indicating when comments begin within pipeline scripts.

In order to negate an expression you can use the syntax “NOT(item1=item2)”.

String Functions

Evaluate_Expression includes specific functions to enable the manipulation of string data:

Example: Extracting text

Given the following Text_Data loaded from a file,

Random Stuff <Subject>Scott</Subject> More Random Stuff

this example demonstrates how to store the desired string “<Subject>Scott</Subject>” into the data tree at TEXT_DATA::SCOTT:TEST.

!Extract the name of the subject.
Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=F1
/EXPRESSION=9+STRING_FIND(TEXT_DATA::SCOTT::TEST, "<Subject>", 0)
/AS_INTEGER=TRUE
;

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=F2
/EXPRESSION=STRING_FIND(TEXT_DATA::SCOTT::TEST, "</Subject>", 0)-&::F1
/AS_INTEGER=TRUE
;

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=SUBJECT
/EXPRESSION=String_Mid(TEXT_DATA::SCOTT::TEST,&::F1&,&::F2&)
/AS_INTEGER=FALSE
;
visual3d/documentation/pipeline/general_information/string_data.txt · Last modified: by wikisysop