String

The methods described below are used to handle strings in Knowledge browsers.

Extract()

This method returns the sub string starting at a given position with a specified length.

Syntax

string->Extract(StartIndex: Integer, Length: Integer) : String where StartIndex is the index (0 or 1) of the substring first character and Length the sub string length.

Example

Let Responsible = "Cilas Evans Evans"

Message ("#",Responsible.Extract(2,2))

/* "la" is displayed.

Length()

This method applies to a string type parameter. Returns the string length.

Syntax

string->Length(Integer)

Example

Let Responsible = "Cilas Evans Evans"

Let i=0

I = Responsible -> Length()

ToString()

You can convert an integer into a string.

Syntax

ToString(Real) : String

Example

Let s = ""

s = ToString(3.4)

Let s = ""

s = ToString(3.4)

ToReal()

Converts a string into a real.

Syntax

String->ToReal(Real): Real

Example

Let s = "2.3"

Let r=0.0

r = s -> ToReal()

ReplaceSubText()

You can replace a sub string with another substring within a character string.

Syntax

ReplaceSubText(InputString: String, SubStringToBeReplaced: String, ReplacingSubString: String): String

Note: Arguments 2 and 3 can be specified either with their parameters names or with the string itself between quotes.

ToUpper()

You can change all lower-case letters of a string to upper-case.

Syntax

ToUpper(StringTobeConverted: String): String where StringTobeConverted is name of the string type parameter.

ToLower()

You can change all upper-case letters of a string to lower-case.

Syntax

ToLower(StringTobeConverted: String): String where StringTobeConverted is name of the string type parameter.

BuildMessageNLS

You can 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.

Syntax

BuildMessageNLS(MessageCatalog:String, MessageKey: String, argument: Literal, ...):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 Knowledge Advisor 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

You can retrieve a date as a string.

Syntax

DateFormat (Format:String):String // Returns a string at the given format for the current date

DateFormat (Format:String , Dateargument: Date):String// Returns a string at the given format for the date passed in argument

Control Characters allowed:



Example

Message(DateFormat("Today is %d/%m/%Y and it is %H:%M"))

GetEnvVariableValue

You can read the content of an environment variable.

Syntax

GetEnvVariableValue(VarName: String):String where VarName is the name of the variable. It returns the name of the variable.