home *** CD-ROM | disk | FTP | other *** search
-
- comment
- This is a demonstration of the Sbasic ' XLATE ' function
- which will, in this example;
-
- 1) convert Upper Case to lower case
- 2) leave all punctuation (except <"> ) alone
- 3) filter out all control characters by
- converting them to spaces
-
- The secret of this useful (?) function is that ' XLATE '
- takes the ascii value of each character in the <source>
- string and uses this value for its index into the
- <table> string. I suppose this might be used to
- translate between different character sets, ie: ascii to
- ebcdic or ascii to APL .
-
- end of comment
-
-
- rem (set up variables)
-
- var table ; table string for translation
- source ; source string for translation
- result ; result string of translation
- =string :128
-
- rem (32 spaces & new character set with UC and LC swapped )
-
- table=space$(32)+"!`#$%&'()*+,-./0123456789:;<=>?@"
- table=table+"abcdefghijklmnopqrstuvwxyz[\]^_~"
- table=table+"ABCDEFGHIJKLMNOPQRSTUVWXYZ{|} "
-
- rem get <source> and XLATE to <result> (^c to end)
-
- 0start print "enter text ";
-
- input2 source
- if source="\" then end
- result=xlate(source,table)
- print result
-
- goto 0start
-