|
of_processmessagesubstitution
|
|
Full name
|
pfc_n_cst_error.of_processmessagesubstitution
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_processmessagesubstitution(string[])
|
Name
|
Datatype
|
li_counter
|
Integer
|
li_parmscount
|
Integer
|
li_replacearraybound
|
Integer
|
li_replacecount
|
Integer
|
ls_errtext
|
String
|
ls_newerrtext
|
String
|
ls_parms
|
String[]
|
ls_replacearray
|
String[]
|
ls_stringparms
|
String
|
protected function integer of_processmessagesubstitution (string as_parms[]);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_ProcessMessageSubstitution
//
// Access: protected
//
// Arguments:
// as_parms[] Array of parms.
//
// Returns: integer
// 1 if it succeeds
// 0 could not correctly convert.
// -1 fatal error.
//
// Description: Replace %s in the error text in the instance structure
// with passed in parms.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Prevent duplication of single argument messages.
// 5.1 Changed the way arguments get displayed, when the number of expected
// arguments does not match the passed in arguments. (debugging assistance)
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
String ls_parms[]
String ls_replacearray[]
String ls_errtext
String ls_newerrtext
String ls_stringparms
Integer li_counter
Integer li_replacecount
Integer li_parmscount
Integer li_replacearraybound
// Get local copy of error text.
ls_errtext = inv_errorpass.is_text
// Make local copy of parms and get count.
ls_parms = as_parms
li_parmscount = upperbound(ls_parms)
// Get number of parms in error message that need to be replaced.
li_replacecount = inv_string.of_countoccurrences(ls_errtext, "%s")
// Check if there is anything to replace.
If li_parmscount=0 And li_replacecount=0 Then
// Nothing to replace.
Return 1
End If
// Stop function if number of parms don't equal.
If li_replacecount <> li_parmscount Then
// Display the parms on the Message window.
// Note: This is provided as a debugging assistance.
ls_stringparms = '~r~n ~r~n' + 'Message Arguments:'
For li_counter= 1 to li_parmscount
ls_stringparms = ls_stringparms + '~r~n' + &
string(li_counter)+ ') '+ ls_parms[li_counter]
Next
// Add the display parms to the text for the message window.
inv_errorpass.is_text = inv_errorpass.is_text + ls_stringparms
Return 0
End If
// Call function to break up error text string into an array of strings.
// Note: The function strips out all of the '%s'.
If inv_string.of_parsetoarray (ls_errtext, "%s", ls_replacearray) <= 0 Then
Return 0
End If
// Add the passed in parms to the end using the strings in the two arrays.
For li_counter = 1 to li_replacecount
ls_replacearray[li_counter] = ls_replacearray[li_counter] + ls_parms[li_counter]
Next
// Rebuild error text using the array.
li_replacearraybound = upperbound(ls_replacearray)
For li_counter = 1 to li_replacearraybound
ls_newerrtext = ls_newerrtext + ls_replacearray[li_counter]
Next
// Set error text in instance structure.
inv_errorpass.is_text = ls_newerrtext
Return 1
end function