String Functions

This page discusses:

BuildDate

Signature

BuildDate() : Date

ReturnType

Date

BuildDeferredMessageNLS

Function used to build a NLS message (a message in a given language) by finding it in a CATXXX.CATNls file depending on the NLS client on a target machine. Its role is to store the information to build a message (could be error, warning or info) from catalog, key and inputs arguments.

Signature

BuildDeferredMessageNLS(MessageCatalog : String, MessageKey : String
 [, argument : Literal, ..]) : NLSMessage

Arguments

NameInput / OutputRequired?TypeComment
MessageCatalogInYesStringCATNls file name or .properties file name. File name without extension.
MessageKeyInYesStringKey name in the .CATNls or in the .properties file.
argumentInOptionalLiteralVariable arguments number.

The output is a structure composed of Catalog, Key and List of arguments, that will be affected to Parameters.

Note: The BuildMessageNLS on the client is replaced by a BuildDeferredMessageNLS on the server. .CATNls files are to be used on the client. The format must be as follows:
// Name of the catalog: Catalog1.CATNls
Message1.Request    = "";
Message1.Diagnostic = "No description for (/p1)";
Message1.Advice     = "You should add a description for (/p1)";
.properties files are to be used on the server. The format must be as follows:
# Name of the catalog: Catalog1.properties
Message1 = "No description for ({0})";

ReturnType

NLSMessage

Example

Parameters.NLSMessage = BuildDeferredMessageNLS("Catalog1", "Message1", "MyObject")

BuildMessageNLS

Enables you to send messages or ask questions through the Message and Question functions in the language of your choice. The BuildMessageNLS function can build a NLS message (a message in a given language) by finding it in a CATXXX.CATNls file.

Signature

BuildMessageNLS(MessageCatalog : String, MessageKey : String
 [, argument : Literal, ..]) : String

Arguments

NameInput / OutputRequired?TypeComment
MessageCatalogInYesString
MessageKeyInYesString
argumentInNoLiteral

ReturnType

String

Example

The KwrCATCatalog.CATNls file contains the following text:

Zero = "Zero";
One = "One /P1";
Two = "Two /P1 /P2";

Zero, One and Two are the messages. The first message has no arguments, the second has 1 argument, the third, 2 arguments. To display those messages in a Engineering Rules Capture rule for example, enter the following rule body:

  • Message (BuildMessageNLS("KwrCATCatalog","Zero"))
  • Message (BuildMessageNLS("KwrCATCatalog","One",x)) Where x is a parameter.
  • Message (BuildMessageNLS("KwrCATCatalog","Two",y,z)) Where y, and z are parameters.
Important:
  • If the function does not find the key or the .NLS catalog, it will return an empty string.
  • If there are too many parameters compared to the number of arguments of the message, the parameters will be ignored.
  • If there are too few parameters compared to the number of arguments of the message, the parameters will be replaced with a "???" string.
  • Note that the .NLS file is to be stored in the runtime view (in the msgcatalog directory)

DateFormat

Enables you to retrieve a date as a string.

Signature

DateFormat(format : String [, date : Date]) :
 String



Arguments

NameInput / OutputRequired?TypeComment
formatInYesString
dateInNoDate

ReturnType

String

GetEnvVariableValue

Enables you to read the content of an environment variable.

Signature

GetEnvVariableValue(VarName : String) : String

Arguments

NameInput / OutputRequired?TypeComment
VarNameInYesStringName of the variable. It returns the name of the variable.

ReturnType

String

GetPLMOwner

Enables you to retrieve the PLM Owner of any kind of object.

Signature

  • If the object is inside a representation, it retrieves the representation that contains it.
  • If the object is a PLMEntity, it returns itself.
  • If the object is not persistent, it will return a NULL value.
  • The result of the GetOwner can be put in any kind of variable. But if you do not use a variable of the right type, it will be equal to NULL.
There are several ways to use GetPLMOwner but the main goal is to propagate a value from an object in a representation, into an attribute of the representation.
Note: Note that no particular license is required in case you run this function.
GetPLMOwner(Object : ObjectType) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
ObjectInYesObjectType

ReturnType

UndefinedType

Example

let x(VPMRepReference)
x = GetPLMOwner (Point) /* Point is the point in the model */
x.V_Description = "Hello"

ReplaceAll

Lets you replace occurrences of a string by another one in a given string.

Signature

ReplaceAll(v1 : String, v2 : String, v2 : String) : String

Arguments

NameInput / OutputRequired?TypeComment
v1InYesString-
v2InYesString-
v2InYesString-

ReturnType

String

Example

  1. Create a knowledge action.
  2. Enter the following script:
    Let stringToModify(String)
    Let stringModified(String)
    Let replacingString(String)
    Let replacedString(Strnig)
    
    stringToModify = "test1234testest1234test" 		
    replacedString = "test"
    replacingString = "thisStringHasBeenModified"
    stringModified = ReplaceAll(stringToModify,replacedString,replacingString)
    Message(stringModified)	
    
  3. Execute the action and check that it displays: "thisStringHasBeenModified1234thisStringHasBeenModifiedest1234thisStringHasBeenModified".

ReplaceSubText

Enables you to replace the first occurrence of string with another string and returns the result.

Signature

ReplaceSubText(v1 : String, v2 : String, 
v2 : String) : String

Arguments

NameInput / OutputRequired?TypeComment
v1InYesString
v2InYesStringCan be specified either with their parameters names or with the string itself between quotes.
v2InYesStringCan be specified either with their parameters names or with the string itself between quotes.

ReturnType

String

ToLower

Enables you to change all upper-case letters of a string to lower-case.

Signature

ToLower(v1 : String) : String

Arguments

NameInput / OutputRequired?TypeComment
v1InYesStringName of the string type parameter.

ReturnType

String

ToString

Enables you to convert an integer into a string.

Signature

ToString(Real) : String

Arguments

NameInput / OutputRequired?TypeComment
InYesReal

ReturnType

String

Example

let s = ""
s = ToString(3.4)
let s = ""
s = ToString(3.4)

ToUpper

Enables you to change all lower-case letters of a string to upper-case.

Signature

ToUpper(v1 : String) : String

Arguments

NameInput / OutputRequired?TypeComment
v1InYesStringName of the string type.

ReturnType

String

String.Search()

Searches for the first occurrence of a sub string in a String type parameter. It returns the index (o or 1) of the start of the substring. It returns -1 if the substring specified is not found.

Signature

String.Search(a1: String [, String, index: Integer, Forward: Boolean]) : Integer

Arguments

NameInput / OutputRequired?TypeComment
a1InYesStringName of the SubString parameter
InNoString
indexInNoIntegerCorresponds to the index of the character to start the search. The index starts at 0. If you're not using this argument, the default value is 0.
ForwardInNoBooleanIndicates if we want to search the string from the beginning of the string (forward equal to true) or from the end (forward equal to false). Note that when we are searching backward, the index value corresponds to the rank of the character in backward order. If you're not using this argument, it will search in forward mode.

ReturnType

Integer

Example



String.Extract()

Returns the sub string starting at a given position with a specified length.

Signature

String.Extract(a1: String, Integer, Integer) : String

Arguments

NameInput / OutputRequired?TypeComment
a1InYesString
InYesInteger
InYesInteger

ReturnType

String

Example

let Responsible = "Cilas Evans Evans"
Message ("#",Responsible.Extract(2,2))
/* "la" appears. */

String.Length()

Applies to a string type parameter. Returns the string length.

Signature

String.Length(a1: String) : Integer

Arguments

NameInput / OutputRequired?TypeComment
a1InYesString

ReturnType

Integer

Example

let Responsible = "Cilas Evans Evans"
let i=0
i = Responsible ->  Length()

String.ToReal()

Converts a string into a real.

Signature

String.ToReal(a1: String) : Real

Arguments

NameInput / OutputRequired?TypeComment
a1InYesString

ReturnType

Real

Example

let s = "2.3"
let r=0.0
r = s -> ToReal()