home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / sbasics.lbr / XLATE.DZC / XLATE.DOC
Encoding:
Text File  |  1993-10-25  |  2.3 KB  |  49 lines

  1. --- Sbasic's XLATE function -------------------------------------------------
  2. -----------------------------------------------------------------------------
  3.  
  4. A recent conversation on the obtuse subject of the fuctions 
  5. and features of the Sbasic language raised the question; what the 
  6. heck is that 'XLATE' function at the end of the function list.
  7.  
  8. Well... as usual with these things, XLATE does what it says 
  9. it is, namely it translates. What does it translate? Strings. 
  10. Strings of what, though? Well.... (again) strings of almost anything 
  11. (anything ascii) to almost anything else (ascii again).
  12.  
  13. Does this all sound kind of obscure and confusing? Actually, I'm just 
  14. trying to retain the spirit of the documentation for the language we 
  15. are talking about. But you're right, we don't need any more confusion 
  16. added to the heap of Sbasic documentation and speculation; so I'll 
  17. cut the sarcasm and do this the simple way .
  18.  
  19. The XLATE function is really quite straightforward. Lets look at the 
  20. operation one step at a time;
  21.  
  22. 1) XLATE takes the leftmost character from the string <source>.
  23.  
  24. 2) XLATE uses the ASCII value of the character just extracted
  25. and uses this as the index value into the string <table>.
  26.  
  27. 3) XLATE places the character found at the index position of <table> 
  28. into the leftmost character position in the string <result>.
  29.  
  30. 4) XLATE moves to the second character in the string <source> and 
  31. repeats the process; (it continues until all of the characters of 
  32. <source> have been translated.
  33.  
  34. The Sbasic program included gives an example of this process. It is 
  35. used to translate UPPER CASE to lower case letters while leaving the 
  36. numbers and punctuation characters alone. By beginning the string 
  37. <table> with 32 spaces, any control characters will be replaced 
  38. (translated) with spaces. It is a simple program, but it does 
  39. demonstrate the use of this (strange) function. 
  40.  
  41. May I suggest that you experiment by changing the characters in the 
  42. variable <table> and re-compiling the program just to see how the 
  43. thing works.
  44.  
  45. J.P. Gordon
  46. C/O Silicom International
  47. 990 Hillside Ave.
  48. Victoria, BC, Canada  V8T 2A1
  49.