Difference between revisions of "Programmer Guide/Command Reference/TRANSLATE"

From STX Wiki
Jump to navigation Jump to search
Line 10: Line 10:
 
It is good practice to always use the [[Programmer_Guide/Command_Reference_Options/-|/|"end of options" option, <code>/-</code>]]. If it is missing, {{Stx}} will mistake any further arguments starting with a slash for a (probably invalid) option.
 
It is good practice to always use the [[Programmer_Guide/Command_Reference_Options/-|/|"end of options" option, <code>/-</code>]]. If it is missing, {{Stx}} will mistake any further arguments starting with a slash for a (probably invalid) option.
  
  #str := TRANSLATE 'I am getting tired of going to bed early' 'ing' 'ed'
+
  #str := TRANSLATE 'I am getting tired of going to bed early' 'ing' 'ed' 'bed' 'work'
 
  um $#str
 
  um $#str

Revision as of 16:13, 2 May 2014

#str := TRANSLATE /- string sub1 trn1 [ subX trnX … ]
#str := TRANSLATE /Variable /- variable sub1 trn1 [ subX trnX … ]
#str := TRANSLATE /Table /- table sub1 trn1 [ subX trnX … ]

The STx command TRANSLATE returns a modified copy of its argument, the modification being that all occurrences of the string subN are replaced by the string trnN.

In its first form, the argument string is taken as a string literal. With option /Variable, the command will be return the modified content of the STx variable variable, while with option /Table, TRANSLATE will return the modified contents of an STx table denoted by the table argument. In either case the content of the respective variable or table will be left untouched.

It is good practice to always use the /|"end of options" option, /-. If it is missing, STx will mistake any further arguments starting with a slash for a (probably invalid) option.

#str := TRANSLATE 'I am getting tired of going to bed early' 'ing' 'ed' 'bed' 'work'
um $#str