home *** CD-ROM | disk | FTP | other *** search
- --- Sbasic's XLATE function -------------------------------------------------
- -----------------------------------------------------------------------------
-
- A recent conversation on the obtuse subject of the fuctions
- and features of the Sbasic language raised the question; what the
- heck is that 'XLATE' function at the end of the function list.
-
- Well... as usual with these things, XLATE does what it says
- it is, namely it translates. What does it translate? Strings.
- Strings of what, though? Well.... (again) strings of almost anything
- (anything ascii) to almost anything else (ascii again).
-
- Does this all sound kind of obscure and confusing? Actually, I'm just
- trying to retain the spirit of the documentation for the language we
- are talking about. But you're right, we don't need any more confusion
- added to the heap of Sbasic documentation and speculation; so I'll
- cut the sarcasm and do this the simple way .
-
- The XLATE function is really quite straightforward. Lets look at the
- operation one step at a time;
-
- 1) XLATE takes the leftmost character from the string <source>.
-
- 2) XLATE uses the ASCII value of the character just extracted
- and uses this as the index value into the string <table>.
-
- 3) XLATE places the character found at the index position of <table>
- into the leftmost character position in the string <result>.
-
- 4) XLATE moves to the second character in the string <source> and
- repeats the process; (it continues until all of the characters of
- <source> have been translated.
-
- The Sbasic program included gives an example of this process. It is
- used to translate UPPER CASE to lower case letters while leaving the
- numbers and punctuation characters alone. By beginning the string
- <table> with 32 spaces, any control characters will be replaced
- (translated) with spaces. It is a simple program, but it does
- demonstrate the use of this (strange) function.
-
- May I suggest that you experiment by changing the characters in the
- variable <table> and re-compiling the program just to see how the
- thing works.
-
- J.P. Gordon
- C/O Silicom International
- 990 Hillside Ave.
- Victoria, BC, Canada V8T 2A1
-