Description
Substitutes values into a message string that is being constructed where the substitution tags have been specified in the message.
Parameters
| icSubstitutionText1 | input | character | Text to substitute for sustitution tag 1. |
| icSubstitutionText2 | input | character | Text to substitute for sustitution tag 2. |
| icSubstitutionText3 | input | character | Text to substitute for sustitution tag 3. |
| icSubstitutionText4 | input | character | Text to substitute for sustitution tag 4. |
| icSubstitutionText5 | input | character | Text to substitute for sustitution tag 5. |
| bcMessageText | input-output | character | Message Text the substitutions will be processed against. |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bmfgmessage.p)
/*
* Copy the substitution text parameters into an array so that we can loop
* through the array and write generic code that does not have to specifically
* reference each individual parameter.
*
* Initially set the vcSubMessage to the value of the bcMessageText parameter
* as this is the value that is parsed to build up the new message.
*/
assign
vcSubstitutions[1] = icSubstitutionText1
vcSubstitutions[2] = icSubstitutionText2
vcSubstitutions[3] = icSubstitutionText3
vcSubstitutions[4] = icSubstitutionText4
vcSubstitutions[5] = icSubstitutionText5
vcSubMessageText = bcMessageText
oiReturnStatus = -98.
/* Loop through the message text substituting arguments for #'s */
if(icSubstitutionText1 <> "" or
icSubstitutionText2 <> "" or
icSubstitutionText3 <> "")
then do:
/*
* Process each of the potential elements in the array and do the
* substitution.
*/
do viSubstitutionCount = 1 to 5 by 1:
if (vcSubstitutions[viSubstitutionCount] <> ?) then
vcCurrentSubstitution = vcSubstitutions[viSubstitutionCount].
else
vcCurrentSubstitution = "".
assign
viSubstitutionOffset = index(vcSubMessageText, "#":U).
if viSubstitutionOffset <> 0
then do:
assign
vcTempMessageText = vcTempMessageText +
substring(vcSubMessageText , 1, viSubstitutionOffset - 1, "character":U) +
vcCurrentSubstitution
vcSubMessageText = substring(vcSubMessageText, viSubstitutionOffset + 1, -1, "character":U).
if index(vcSubMessageText, "#":U) = 0
then
assign
vcTempMessageText = vcTempMessageText + vcSubMessageText.
assign
bcMessageText = vcTempMessageText.
end. /* IF viSubstitutionOffset <> 0 */
else if (vcCurrentSubstitution <> "") then
assign
bcMessageText = bcMessageText + " " + vcCurrentSubstitution.
end. /* viSubstitutionCount = 1 to 5 */
end. /* icSubstitutionText1,2,3 <> "" */
assign
oiReturnStatus = 0.