Aveva. PML BASICS. Strings

Some techniques for working with string variables.

Initial string variable:

!stringVar = ‘Wedge gate valve with rising stem # 30c41nzh / 30nzh41nzh

Example 1: Separation of part to a certain character or expression

!resultVar = !stringVar.Before(‘#’)

As a result, the variable !resultVar written to ‘Wedge gate valve with rising stem’, that is something that is up to the value specified as a parameter to the method.

Used method .Before(‘DELIMITER’)
NB: spaces are also considered

Example 2: Separation of part after a certain character or expression

!resultVar = !stringVar.After(‘#’)

As a result, the variable! resultVar written to ’30c41nzh / 30nzh41nzh’, that is what comes after the value specified as a parameter to the method.
Used .After ( ‘DELIMITER’) method
NB: spaces are also considered

Example 3. Separation of the substring, starting at a particular place (for the serial number in a row) and the specified length

!resultVar = !stringVar.Substring(1,5)

As a result, variable !resultVar written to ‘Wedge ‘ – that is, starting with the first character and length of 5.
Used method .Substring (real1, real2) NB: If you do not specify the length (that is, will be specified only one parameter), then all the rest of the line is taken from the specified locations

Example 4. Split string into an array of string values to the specified delimiter
NB: simultaneous use several methods to a single object. In object-oriented language, what it is PML 2, methods primenyatyutsya sequentially. In the first case, we applied two methods: first pruning of the rows at the specified string value, and then .Trim () method immediately allows to remove the gaps in the line edges. In the second case, too, used two methods sequentially: first get that follows the specified string value, and then, knowing the separator, obtain an array breaking znachenie.V resultArray result variable is an array of strings obtained by breaking the original line to the specified delimiter!. In this example, it will be an array of two cells with values ‘Wedge gate valve with rising stem’ and ’30c41nzh / 30nzh41nzh’ respectively.

!resultArray = !stringVar.Split(‘#’)

Used Split method (‘DELIMITER’)

NB: If you do not specify a separator character, that is, write just .Split (), then the system will attempt to break the starting line for a space

This post was taken from blog http://pmlinpdms.blogspot.com/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s