home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / acharmap.x < prev    next >
Text File  |  1996-01-19  |  3KB  |  117 lines

  1. '
  2. ' ####################
  3. ' #####  PROLOG  #####
  4. ' ####################
  5. '
  6. PROGRAM    "acharmap"
  7. VERSION    "0.0001"
  8. '
  9. IMPORT    "xst"
  10. IMPORT    "xgr"
  11. IMPORT  "xui"
  12. '
  13. DECLARE FUNCTION  Entry ()
  14. '
  15. '
  16. ' ######################
  17. ' #####  Entry ()  #####
  18. ' ######################
  19. '
  20. FUNCTION  Entry ()
  21. '
  22.     DIM map[255]
  23.     FOR i = 0 TO 255
  24.         map[i] = i                ' create character map array with 1:1 mapping = no character translation
  25.     NEXT i
  26. '
  27. ' install a few character translations
  28. '
  29.     XstGetImplementation (@implementation$)
  30.     windows = INSTR (implementation$, "windows")
  31. '
  32.     IF windows THEN
  33.         map['a'] = 0x84            ' the following are interesting on my windows system
  34.         map['e'] = 0x89
  35.         map['i'] = 0x8C
  36.         map['o'] = 0x94
  37.         map['u'] = 0x81
  38.         map['y'] = 0x98
  39.         map['c'] = 0x87
  40.         map['n'] = 0xA4
  41.         map['?'] = 0xA8
  42.         map['!'] = 0xAD
  43.     ELSE
  44.         map['a'] = 0xE4            ' the following are interesting on my linux system
  45.         map['e'] = 0xEB
  46.         map['i'] = 0xEF
  47.         map['o'] = 0xF6
  48.         map['u'] = 0xFC
  49.         map['y'] = 0xFF
  50.         map['c'] = 0xE7
  51.         map['n'] = 0xF1
  52.         map['?'] = 0xBF
  53.         map['!'] = 0xA1
  54.     END IF
  55. '
  56. ' install into console
  57. '
  58.     XstGetConsoleGrid (@grid)
  59. '
  60. ' make a test string with all 256 characters (except newline = space)
  61. '
  62.     offset = 0
  63.     test$ = NULL$ (264)
  64.     FOR i = 0 TO 255
  65.         IF (i = 10) THEN
  66.             test${i+o} = ' '
  67.         ELSE
  68.             test${i+o} = i
  69.         END IF
  70.         IF ((i AND 0x1F) = 0x1F) THEN
  71.             INC o
  72.             test${i+o} = '\n'
  73.         END IF
  74.     NEXT i
  75. '
  76. ' change console character map and print the character set
  77. '
  78.     XuiSendStringMessage (grid, "SetCharacterMapArray", 0, 0, 0, 0, 1, @map[])
  79.     XuiSendStringMessage (grid, "SetTextArray", 0, 0, 0, 0, 0, @empty$[])
  80.     PRINT test$
  81. '
  82. ' make sure character map array is returned intact
  83. '
  84.     XuiSendStringMessage (grid, "GetCharacterMapArray", 0, 0, 0, 0, 1, @char[])
  85.     PRINT implementation$
  86.     PRINT "***  test character map array modified ***"
  87.     PRINT "Microsoft Windows is as wierd as Bill Gates!"
  88.     PRINT "Did the quick brown fox jump over the lazy dog?"
  89.     PRINT
  90. '
  91. ' show some mapped and unmapped characters in a dialog window
  92. '
  93.     a$ = implementation$ + "\n"
  94.     a$ = a$ + "**  test character map array modified ***\n"
  95.     a$ = a$ + "Microsoft Windows is as wierd as Bill Gates!\n"
  96.     a$ = a$ + "Did the quick brown fox jump over the lazy dog?\n\n"
  97.     a$ = a$ + " a e i o u y c n ? ! \n"
  98.     a$ = a$ + " \xDF \xE0 \xE1 \xE2 \xE3 \xE4 \xE5 \xE6 \xE7 \xE8 \xE9 \xEA \xEB \xEC \xED \xEE \xEF \n"
  99.     a$ = a$ + " \xA9 \xF0 \xF1 \xF2 \xF3 \xF4 \xF5 \xF6 \xF7 \xF8 \xF9 \xFA \xFB \xFC \xFD \xFE \xFF \n"
  100.     XgrSetGridCharacterMapArray (0, @map[])
  101.     XuiMessage (@a$)
  102.     XgrSetGridCharacterMapArray (0, @empty[])
  103. '
  104. ' remove character mapping from the console
  105. '
  106.     DIM map[]
  107.     XuiSendStringMessage (grid, "SetCharacterMapArray", 0, 0, 0, 0, 1, @map[])
  108. '
  109. ' make sure character mapping is gone
  110. '
  111.     PRINT "**  test character map array original ***"
  112.     PRINT "Microsoft Windows is as wierd as Bill Gates!"
  113.     PRINT "Did the quick brown fox jump over the lazy dog?"
  114.     PRINT
  115. END FUNCTION
  116. END PROGRAM
  117.