$Translate and $Replace Functions
You use the $Translate function to translate one or more characters in a string into different characters. You can also use it to remove characters from a string. In the lookup routine, you will use it to translate lowercase letters to uppercase and vice versa.
Recall that the name prompt of the mydatent routine you wrote is case-sensitive (“Agee,Tommie”). Using $Translate will allow the name string that the user submits for lookup to be not case-sensitive (“a” or “AGEE”).
The $Replace function is similar to $Translate, except it treats its second and third arguments as complete strings, rather than lists of characters.
SAMPLES>write $translate( "abcde", "ad", "yz" ) ; translate a->y, and d->z
ybcze
SAMPLES>write $translate( "abcde", "ad", "zz" ) ; translate a->z, and d->z
zbcze
SAMPLES>write $translate( "abcde", "ad", "z") ; translate a->z, and d->nothing
zbce
SAMPLES>write $translate( "abcdebcbc", "abc", "yz" ) ; translate a->y, b->z, and c->nothing
yzdezz
SAMPLES>write $replace( "abcdebcbc", "abc", "yz" ) ; replace abc->yz
yzdebcbc
SAMPLES>read "String to translate: ", x
SAMPLES>set lower = "abcdefghijklmnopqrstuvwxyz"
SAMPLES>set upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SAMPLES>write !, $translate( x, lower, upper )
String to translate: the quick brown fox jumps over the lazy dog
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
SAMPLES>