Replaces %1, %2, %3... and #1, #2, #3... fields in a string with
the values you provide as optional parameters.
|
NewString := STRSUBSTNO(String [,Value1, …])
|
Parameters
- String
-
Type: Text constant or Code
A string containing '#' and/or '%' fields.
The % fields are replaced by the values with their full lengths,
and # fields are replaced by the values that are truncated to the
length of the # field.
If this parameter is an expression that evaluates to Text or
Code that is 512 or more characters, then a run-time error
occurs.
- Value1,
…
-
Type: Any
One or more values (expressions) that you want to insert into
String. You can specify up to 10
values.
Property Value/Return Value
Type: Text constant or Code
The resulting string, after the corresponding values have been
substituted into the '#' and '%' fields.
Remarks
Example
The following example shows how to use the STRSUBSTNO
function.
This example requires that you create the following
variables and text constants in the C/AL Globals window.
Variable name |
Data type |
Length |
Str
|
Text
|
1024
|
AccountNo
|
Integer
|
|
Balance
|
Decimal
|
|
Text constant |
ENU value |
Text000
|
The balance of account %1 is $ %2
|
Text001
|
The string before STRSUBSTNO has been called:\%1
|
Text002
|
The string after STRSUBSTNO has been called:\%1
|
|
Copy Code |
Str := Text000;
AccountNo := 3452;
Balance := 2345 + 5462;
MESSAGE(Text001, Str);
Str := STRSUBSTNO(Str, AccountNo, Balance);
MESSAGE(Text002, Str);
|
The first message window displays the following
text:
The string before STRSUBSTNO has been called:
The balance of account %1 is $ %2
The second message window displays the following
text:
The string after STRSUBSTNO has been called:
The balance of account 3452 is $ 7,807
Note |
This example is run on a computer with the regional format set
to English (United States).
|
See Also