Pages

Showing posts with label SELECTSTR. Show all posts
Showing posts with label SELECTSTR. Show all posts

Sunday, 12 May 2013

Microsoft Dynamics NAV String Function


CONVERTSTR Function (STRING)
CONVERTSTR Function is used to converts some characters in a string.

NewString := CONVERTSTR(String, FromCharacters, ToCharacters)

·         The characters in the FromCharacters parameter are replaced by the characters in the ToCharacters parameter.
·         A run-time error occurs if the lengths of the FromCharacters and ToCharacters strings are not equal.
·         If either the FromCharacters or the ToCharacters strings are empty the source is returned unchanged.

Example
OriginalString     :=            'Want to leave without saving?'
FromChars          :=           ‘lws’
ToChars                :=            ‘LWS’

NewString := CONVERTSTR(OriginalString, FromChars, ToChars);
MESSAGE (OriginalString);           ->     Want to leave without saving?
MESSAGE(NewString);                  ->    Want to Leave Without Saving?

COPYSTR Function (STRING)
COPYSTR function is used to copies a substring of any length from a specific position in a string (text or code) to a new string.

NewString := COPYSTR(String, Position [, Length])

·         If you omit Length, the resulting string includes all the characters from Position to the end of the string.
·         If Position is less than 1 or Length is less than 0, an error is returned.
·         If Position is beyond the length of the current string, an empty string is returned.
·         If Position combined with Length exceeds the length of the string, all the characters from Position to the end of the string are returned.
Example
Str             := 'Using the COPYSTR function';
Position   := 7;
Length := 8;

NewStr := COPYSTR(Str, Position, Length); 

MESSAGE(Str);                                   -> Using the COPYSTR function
MESSAGE(NewStr);       -> the COPY