"$SET_CHAR Has Invalid Non-Negative Integer Argument" Error Message If You Use a Negative Number with the $set_char Function (323281)



The information in this article applies to:

  • Microsoft Metadirectory Services 2.1
  • Microsoft Metadirectory Services 2.2
  • Microsoft Metadirectory Services 2.2 SP1

This article was previously published under Q323281

SYMPTOMS

If you use a negative number with the $set_char function, you receive the following error message:
19033-ERROR: $SET_CHAR has invalid non-negative integer argument: (-9)
This occurs if you use the $set_char function with the following arguments:
$set_char("~","$v_csp",-9)
				

CAUSE

The documentation in the Management Agent Toolkit Manual about the $set_char function incorrectly states the following:

Position is one-based, but can be positive or negative. A positive value indicates counting begins at the leftmost character. A negative value indicates that counting begins at the rightmost character.

Both of these statements are incorrect. The base is actually zero (0), and you cannot use negative numbers. In fact, negative numbers generate an error message if they are used. The zero-based nature of the function also precludes the use of negative numbers. $set_char() does not modify the buffer in place. This means that you have to assign the result to a variable, which is not stated in the documentation.

MORE INFORMATION

The following sample code demonstrates how the $set_char() function works, although the result is actually "AZena", because the offset at the end of the function call is zero-based:
$v_variable = $cd.givenName

IF $EMBEDDED("Adena",$v_variable,1) = T

THEN

$mv.zcMisc1 = $SET_CHAR("Z",$v_variable,1) 

ENDIF
				

Modification Type:MajorLast Reviewed:6/6/2003
Keywords:kberrmsg kbprb KB323281