String Data

From Software Product Documentation
Jump to navigation Jump to search

Syntax

Quotes are to be used around string data in an expression to differentiate it from variable names. ie; subject_name="John Smith". Parameters in the pipeline that are strings, are not quoted (i.e.; EXPRESSION is a string, but you don't need quotes around it). Within EXPRESSION, our expression parser parses the variables, data and operators out of the expression. Data can be doubles or strings. If it is a string, Visual3D has no way to recognize the difference between a string and a variable name reference, except to quote the string data.

For example, there is a problem with the following evaluate_expression:

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
;

Currently, the operators are only parsed as a single character, so the use of "/=" (not equals) cannot be used yet. You can do NOT(item1=item2) in order to process a not equals currently, but this will change shortly to allow "/=", "!=" cannot be used because the "!" is our start comment character for the pipeline commands.

Modify

Parsing

Given a pipeline parameter that is a string. For internal reasons, the string cannot be a number, or it will be interpreted as a number.

There are 3 commands that extract a portion of a string.

STRING_LEFT(string,index)
STRING_RIGHT(string,index)
STRING_MID(string,index1,index2)
STRING_LENGTH(string)
STRING_FIND(string, substring, start)

NOTE: When referencing strings, the string should be surrounded by quotes. This identifies to Visual3D that you are referencing a string, and not a file name etc.


Parsing String Data (more...)

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

The result is

::TEST_STRING = A123456789

String_Left

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST_LEFT
/EXPRESSION=STRING_LEFT("&::TEST_STRING&",3)
/AS_INTEGER=FALSE
;

The result is

::TEST_LEFT = A12

String_Right

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST_RIGHT
/EXPRESSION=STRING_RIGHT("&::TEST_STRING&",3)
/AS_INTEGER=FALSE
;

The result is

::TEST_RIGHT = 789

String_Mid

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST_MID
/EXPRESSION=STRING_MID("&::TEST_STRING&",3,3)
/AS_INTEGER=FALSE
;

The result is

::TEST_MID = 345

Note: For STRING_MID the number values are zero based

String_Length

Set_Pipeline_Parameter_From_Expression

/PARAMETER_NAME=TEST_LENGTH
/EXPRESSION=STRING_LENGTH("&::TEST_STRING&")
/AS_INTEGER=TRUE
;

The result is

::TEST_LENGTH = 10

Set_Pipeline_Parameter_From_Expression

/PARAMETER_NAME=TEST_INDEX
/EXPRESSION=STRING_FIND("&::TEST_STRING&",234,0)
/AS_INTEGER=TRUE
;

The result is

::TEST_INDEX = 2


String_Find

Set_Pipeline_Parameter_From_Expression

/PARAMETER_NAME=TEST_INDEX
/EXPRESSION=STRING_FIND("&::TEST_STRING&",234,5)
/AS_INTEGER=TRUE
;

The result is

::TEST_INDEX = -1

String_Reverse_Find

String_To_Lower

!Converting To_Upper and To_Lower String Data (more...)

Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST
/EXPRESSION=STRING_TO_LOWER("XXXXXX")
/AS_INTEGER=FALSE
;
Set_Pipeline_Parameter_From_Expression
/PARAMETER_NAME=TEST
/EXPRESSION=STRING_TO_UPPER("yyyyyyy")
/AS_INTEGER=FALSE
;
Select_Active_File
/FILE_NAME=GLOBAL
! /QUERY=
;
Create_Text_Data
/SIGNAL_FOLDER=SCOTT
/SIGNAL_NAMES=NAME
/TEXT_DATA=Hello World
! /TEXT_FILE_NAME=
! /PROMPT_ON_EMPTY=TRUE
;
Evaluate_Expression
/EXPRESSION=STRING_TO_UPPER(TEXT_DATA::SCOTT::NAME)
! /SIGNAL_TYPES=
! /SIGNAL_FOLDER=ORIGINAL
! /SIGNAL_NAMES=
/RESULT_TYPES=TEXT_DATA
/RESULT_FOLDERS=SCOTT
/RESULT_NAME=SCOTT_UPPER
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
;
Evaluate_Expression
/EXPRESSION=STRING_TO_LOWER(TEXT_DATA::SCOTT::NAME)
! /SIGNAL_TYPES=
! /SIGNAL_FOLDER=ORIGINAL
/SIGNAL_NAMES=
/RESULT_TYPES=TEXT_DATA
/RESULT_FOLDERS=SCOTT
/RESULT_NAME=SCOTT_LOWER
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
;

String_To_Upper

To_String

Example: Extract text (more...)

Given the following Text_Data loaded from a file store in a signal TEXT_DATA::SCOTT:TEST

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

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
;
The resulting pipeline parameter contains "Scott"
Retrieved from ""