Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

gpss_manual

.pdf
Скачиваний:
49
Добавлен:
05.06.2015
Размер:
1.88 Mб
Скачать

ABS( Expression ) - Absolute value.

ANOVA( ResultMatrixName ) - Analysis of Variance. ATN( Expression ) - Arctangent in radians.

COS( Expression ) - Cosine. Expression must be in radians.

EXP( Expression ) - e raised to the power given by

Expression.

INT( Expression ) - Truncation toward zero. LOG( Expression ) - Natural logarithm.

SIN( Expression ) - Sine. Expression must be in radians. SQR( Expression ) - Square Root.

TAN( Expression ) - Tangent. Expression must be in radians.

8.3.3. Query Procedures

Transaction Query Procedures are available which return information based on any Transaction in the simulation. Except for QueryXNExist(), if you attempt to query a nonexistent Transaction, an Error Stop will occur. If there is any question, you should test for existence first.

All arguments are coerced to integers in order to look up either a Transaction or one of its parameters. The Transaction state query Procedures now include:

QueryXNExist( TransactionNumber ) - Return integer 1 if the Transaction exists in the simulation, integer 0 , if not.

QueryXNParameter( TransactionNumber, Parameter ) -

Return the value of a Transaction Parameter. Error Stop occurs if the Parameter does not exist.

QueryXNAssemblySet( TransactionNumber ) - Return the integer Assembly Set of a Transaction.

QueryXNPriority( TransactionNumber ) - Return the integer Transaction Priority of a Transaction.

QueryXNM1( TransactionNumber ) - Return the numeric Mark Time of a Transaction.

8.3.4. String Procedures

he GPSS World Procedure Library contains a number of String Procedures which make it easy to manipulate string data types. As with all built-in Procedures, the String Procedures coerce arguments into proper form before processing them.

Strings are sequences of ASCII characters. The individual characters can be addressed by an index called an "Offset". String Procedures that must find a specific character use the Offset as a 1-relative index into an array of characters. The first character in the string is associated with an index of 1, the second with 2, and so on.

A null string is a string of length 0. It contains no characters, and is denoted " ". Null strings are still considered to be valid strings.

A word is a consecutive sequence of printable characters, not including blanks or tabs.

Words may be separated by one or more blank and/or tab characters.

The remainder of this section describes the String Procedure Library. For each Procedure, the syntax of Procedure invocation is given in a syntax line. Any Procedure may be invoked in an Expression, without the assignment of the result, as well as in a PLUS Assignment Statement.

Align( InsertString, SourceString, Offset ) - Return a copy of one string placed in another, right justified.

Catenate( String1, String2 ) - Return a copy of two strings combined into one.

Copies( SourceString, Count ) - Create a string from many copies of a string.

Datatype( Datum ) - Return a string denoting the data type of the argument.

Find( TestString, SourceString ) - Return the Offset of one string in another.

Left( SourceString, MaxCount ) - Return a copy of a substring starting on the left.

Length( SourceString ) - Return the count of characters in a string.

Lowercase( SourceString ) - Return the lowercase representation of a string.

Place( InsertString, SourceString, Offset ) - Place one string in another. Left justify.

Polycatenate( String1, String2, String3, String4 ) - Return a copy of four strings combined into one.

Right( SourceString, MaxCount ) - Return a copy of a substring starting on the right.

String( Datum ) - Convert a data item to its string equivalent.

StringCompare( String1, String2 ) - Return an integer result if string comparison.

Substring( SourceString, Offset, MaxCount ) - Return a copy of a substring of the string argument.

Trim( SourceString ) - Remove leading and trailing white space.

Uppercase( SourceString ) - Return the uppercase equivalent of a string.

Value( Datum ) - Return the numeric equivalent of a string.

Word( SourceString, WordNumber ) - Return a copy of one of the words in a string.

1. Align - Right-justify a string.

Syntax

ReturnString=Align(InsertString,SourceString,Offset )

Arguments

InsertString - The string to be copied. Required. Coerced to string. The argument must be Expression.

SourceString - The string to be overwritten. Required. Coerced to string. The argument must be Expression.

Offset - The 1-relative offset in SourceString to receive the rightmost character of InsertString. Required. Coerced to integer. The argument must be Expression.

Return Value

ReturnString - The string created as a result of inserting InsertString into

SourceString at offset Offset.

Example

SHOW Align("ABC","123456789",6) "123ABC789"

This example uses a SHOW Command to demonstrate how the align() string Procedure right justifies the insert string at position 6 of the target string, and displays the result.

Action

Align( ) coerces the first and second arguments to strings, and the third to an integer. It then creates a string of blanks large enough to contain the result, and copies the target string into the result string. Finally, it copies the insert string, or the part of it that fits, into the result string.

If the Offset is larger than the target string, the resulting string will be larger, as well. Any characters not specified by the argument strings will be blanks.

If the Offset is less than the length of the insert string, only the characters that fit will be inserted, starting from the rightmost character of the insert string.

If the Offset is not strictly positive, no characters will be inserted.

2. Carenate - Combine two strings.

Syntax

ReturnString = CATENATE( String1,

String2 )

Arguments

String1 - The string to be first in the concatenated result string. Required. Coerced to string. The argument must be Expression.

String2 - The string to be second in the concatenated result string. Required. Coerced to string. The argument must be Expression.

Return Value

ReturnString - The string created as a result of placing String2 immediately after

String1.

Example

SHOW Catenate("ABC","123") "ABC123"

This example uses a SHOW Command to demonstrate how the Catenate() string Procedure combines two strings.

Action

Catenate( ) first coerces both arguments to strings. It then creates a string large enough to contain the result, and copies the first string and the second string into the result string.

3. Copies - Build a string from multiple copies.

Syntax

ReturnString = COPIES( SourceString,

Count )

Arguments

SourceString - The string to be duplicated. Required. Coerced to string. The argument must be Expression.

Count - The number of copies to make. Required. Coerced to integer. The argument must be Expression.

Return Value

ReturnString - The string created as a result of concatenating Count copies of SourceString.

Example

SHOW Copies("ABC ",3)

"ABC ABC ABC "

This example uses a SHOW Command to demonstrate how the copies( ) string Procedure creates a string out of 3 copies of an existing string.

Action

Copies( ) coerces the first argument to a string and the second to an integer. It then creates a string large enough to contain the result, and copies the source string to the result string once for each count in the second argument.

If the count is not strictly positive, a null string results.

4. DataType - Determine the type of a data item.

Syntax

ReturnString = DATATYPE( Datum )

Arguments

Datum - The data item to be examined. Required. The argument must be Expression.

Return Value

ReturnString - The string identifying the data type. One of: "INTEGER" - Datum is a 32 bit integer,

"REAL" - Datum is a double precision floating point number, "STRING" - Datum is a character string, or "UNIDENTIFIED" - The Data Type cannot be determined.

Example

SHOW DataType("ABC") "STRING"

This example uses a SHOW Command to demonstrate how the DataType() string Procedure identifies the data type of a string constant.

Action

DataType( ) does not coerce its argument. It determines the data type of the argument and returns the string constant associated with that type.

5. Find - Find one string in another.

Syntax

ReturnInteger = FIND( TestString, SourceString )

Arguments

TestString - The string to be found. Required. Coerced to string. The argument must be

Expression.

SourceString - The string to be tested for occurrence of TestString. The argument must be Expression.

Return Value

ReturnInteger - The 1-relative offset of the first occurrence of TestString in SourceString. A real value. Zero if not found.

Example

SHOW Find("ABC","123ABC789") 4

This example uses a SHOW Command to demonstrate how the find() string Procedure finds the occurrence of "ABC" starting at position 4 of string "123ABC789".

Action

Find( ) coerces the first and second arguments to strings, and tests the second argument for the existing of a substring equal to the first argument. If it cannot be found, find( ) returns 0. Otherwise, find( ) returns the 1-relative offset in the second string of the first occurrence of the first string.

6. Left - Return an initial substring.

Syntax

ReturnString = LEFT( SourceString, MaxCount )

Arguments

SourceString - The source string to be used to create the substring. Required. Coerced to string. The argument must be Expression.

MaxCount - The maximum number of characters to be used in the substring. Required. Coerced to integer. The argument must be Expression.

Return Value

ReturnString - The string created as the left MaxCount characters of SourceString.

Example

SHOW Left("123456789",6) "123456"

This example uses a SHOW Command to demonstrate how the left( ) string Procedure extracts the first 6 characters of the string "123456789".

Action

Left( ) coerces the first argument to a string, and the second to an integer. If MaxCount

is less than 0, it is made equal to 0. Left( ) then creates a string of length equal to the smaller of MaxCount and the length of SourceString. The result string is then filled with

characters from SourceString, starting with the first.

7. Length - Count string characters.

Syntax

ReturnInteger = LENGTH(

SourceString )

Arguments

SourceString - The string to be examined. Required. Coerced to string. The argument must be Expression.

Return Value

ReturnInteger - The number of characters in the string. A Real value.

Example

SHOW Length("ABC") 3

This example uses a SHOW Command to demonstrate how the length() string Procedure returns the character count of the string "ABC".

Action

Length( ) coerces the argument to a string, counts its characters, and returns the count as an integer. Null strings have a count of 0.

8. Lowercase - Convert string to lower case.

Syntax

ReturnString = LOWERCASE(

SourceString )

Arguments

SourceString - The string to be converted. Required. Coerced to string. The argument must be Expression.

Return Value

ReturnString - The string created as a result of converting SourceString to lower case.

Example

SHOW Lowercase("123 AbC")

"123 abc"

This example uses a SHOW Command to demonstrate how the lowercase( ) string Procedure copies a string and converts the upper case letters to lower case.

Action

Lowercase( ) coerces the argument to a string, and creates a copy of the string. It then converts the upper case letters in the copy to lower case and returns it as the result string.

9. Place = Left-justify a string.

Syntax

ReturnString =PLACE(InsertString,SourceString,Offset

)

Arguments

InsertString - The string to be inserted. Required. Coerced to string. The argument must be Expression.

SourceString - The string to receive the insertion. Required. Coerced to string. The argument must be Expression.

Offset - The 1-relative offset in SourceString to receive the leftmost character of InsertString. Required. Coerced to integer. The argument must be Expression.

Return Value

ReturnString - The string created as a result of inserting InsertString into

SourceString at offset Offset.

Example

SHOW Place("ABC","/123456789",3) "123ABC789"

This example uses a SHOW Command to demonstrate how the place() string Procedure left justifies the insert string at position 3 of the target string, and displays the result.

Action

Place( ) coerces the first and second arguments to strings, and the third to an integer. It then creates a string of blanks large enough to contain the result, and copies the target string into the result string. Finally, it copies the insert string into the result string.

If the end of the inserted string extends past the end of the original target string, the resulting string will be larger, as well. Any characters not specified by the argument strings will be blanks.

If the offset is less than 1, the leftmost characters of the insert string are truncated, and the remaining characters, if any, are inserted at position 1 of the target string.

10. Polycatenate - Combine four strings.

Syntax

ReturnString = POLYCATENATE(String1, String2, String3, String4

)

Arguments

String1 - The string to be first in the concatenated result string. Required. Coerced to string. The argument must be Expression.

String2 - The string to be second in the concatenated result string. Required. Coerced to string. The argument must be Expression.

String3 - The string to be third in the concatenated result string. Required. Coerced to string. The argument must be Expression.

String4 - The string to be fourth in the concatenated result string. Required. Coerced to string. The argument must be Expression.

Return Value

ReturnString - The string created as a result of placing copies of the four strings one after the other.

Examples

SHOW Polycatenate("The ","time ","is ",AC1) "The time is 0"

This example uses a SHOW Command to demonstrate how the Polycatenate( ) string Procedure combines four strings. The SNA AC1 is automatically coerced to a string.

SHOW Polycatenate("Yours"," ","truly,","") "Yours truly,"

This example uses a SHOW Command to demonstrate how the Polycatenate() string Procedure combines three string constants. A null string is used as the fourth argument.

Action

Polycatenate( ) first coerces all four arguments to strings. It then creates a string large enough to contain the result, and copies the first, second, third, and fourth strings into the result string. Any of the arguments can be a null string.

11. Right - Return terminal substring.

Syntax

ReturnString = RIGHT(SourceString, MaxCount)

Arguments

SourceString - The source string to be used to create the substring. Required. Coerced to string. The argument must be Expression.

MaxCount - The maximum number of characters to be used in the substring. Required. Coerced to integer. The argument must be Expression.

Return Value

ReturnString - The string created as the right MaxCount characters of SourceString.

Example

SHOW Right("123456789",6) "456789"

This example uses a SHOW Command to demonstrate how the right() string Procedure extracts the last 6 characters of the string "123456789".

Action

Right( ) coerces the first argument to a string, and the second to an integer. If MaxCount

is less than 0, it is made equal to 0. Right( ) then creates a string of length equal to the smaller of MaxCount and the length of SourceString. The result string is then filled with

the last MaxCount characters from SourceString.

12. String - Create string equivalent.

Syntax

ReturnString = STRING( Datum )

Arguments

Datum - The data item to be converted. Required. Coerced to string. The argument must be Expression.

Return Value

ReturnString - The string created as a result of converting Datum to its string equivalent.

Example

SHOW String(12345) "12345"

This example uses a SHOW Command to demonstrate how the string() string Procedure converts the integer constant 12345 to the string constant "12345".

Action

String( ) coerces the arguments a string, and returns a copy as the result. If the argument is already a string, it is not modified.

13. StringCompare - Compare two strings.

Syntax

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]