CTRANS

Contents


ctrans transforms the 8-bit characters in a string into 7-bit code, or as specified in a conversion table.

 

Syntax

 

   ctrans ( expr_c [ , chaine_i, chaine_o ] )

 

Parameters

 

Element

Description

Restrictions

expr_c

Alphanumeric expression

None.

chaine_i

Alphanumeric expression.

None

chaine_o

Alphanumeric expression.

None

 

Examples

   # Programme showing "Deletion of characters: a e i o u ..."
 
  Infbox ctrans ("Deletion of characters : à è î ô ù ...")

   # Comparison of 2 character strings, not case-sensitive.
   
If toupper(ctrans (A)) = toupper(ctrans (B))
      Infbox "A is equal to B"
  Endif

   # Display prepared from one name in a mask zone only
   # accepting uppercase characters and spaces.

   MAJ = toupper(ctrans([F]VILLE))
   ENTREE = sigma(I=32,64,chr$(I))+sigma(I=91,127,chr$(I))

   # all printable characters, apart from upper-case.
 
MAJ = ctrans (MAJ,ENTREE,space$(127)
  # no problem if the output string is too long…
 
[M]VILLE = vireblc(MAJ,5)
# simply remove excess blanks
# "23020 Saint-Thomas d'Aquîn s/mer" -> " SAINT THOMAS D AQUIN S MER"

# Same process, but without spaces
 
[M]VILLE = ctrans (MAJ,ENTREE,"")
   # the same string will be "SAINTTHOMASDAQUINSMER"

 

Description and comments

 

ctrans with one argument is used to transform a string of characters into one of the same length but where all the characters are coded over 7 bits. Accented letters (upper or lower case) are changed to non-accented letters, non-printing characters are changed to spaces, and semi-graphics to "+", the – character to "-", and the | character to "!". Other characters remain the same.

ctrans with 3 arguments is used to transform one character string to another. Each character in the string to be transformed is searched for in the second string – known as input string. If it does not appear, it will not be changed. If it appears, its position in the input string is noted and it is replaced by the character in the third string, the output string, from the same position. If its position is higher than the length of the output string, it will not appear in the result.
The result is a Char type.

 

Associated errors

Error

Description

ERMODE (10)

The argument is not a Char type.

 

Associated key words

TOUPPER - TOLOWER - CHR$ - ASCII


CONTENTS


Copyright © Sage 1999 - 2007