home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ME22-OS2.ZIP / MACROS.ZIP / ACHART.M < prev    next >
Text File  |  1988-07-09  |  1KB  |  80 lines

  1. /*
  2.  
  3.   ACHART - ASCII Character chart (including PC's upper ASCII).
  4.            Invoked by pressing CTRL_A.
  5.  
  6.  
  7.   (C) Copyright 1988  Marc Adler/Magma Systems     All Rights Reserved
  8.  
  9. */
  10.  
  11. #define CTRL_A  1
  12.  
  13. init()
  14. {
  15.   assign_key("ASCII_Chart", CTRL_A);
  16. }
  17.  
  18.  
  19. ASCII_Chart()
  20. {
  21.   /* Get the color to display the chart in */
  22.   fg = get_option("fg");
  23.   bg = get_option("bg");
  24.   attr = bg * 16 + fg;
  25.  
  26.   for (i = 0;  i <= 1;  i++)
  27.   {
  28.     clear_screen();
  29.     row = 1;
  30.     col = 0;
  31.     
  32.     /* Print the column headings */
  33.     for (c = 0;  c < 6;  c++)
  34.       display(0, c*13, 79, attr, "CH DEC HEX");
  35.  
  36.     /* Determine the ending character for the loop */
  37.     if (i == 0)
  38.       endc = 128;
  39.     else
  40.       endc = 256;
  41.  
  42.     for (c = i * 127 + 1;  c < endc;  c++)
  43.     {
  44.       s = sprintf("%s  %d", chr(c), c);
  45.       display(row, col, 79, attr, s);
  46.       display(row, col+7, 79, attr, itox(c));
  47.  
  48.       if (++row % 24 == 0)
  49.       {
  50.         col += 13;
  51.         row = 1;
  52.       }
  53.     }
  54.     
  55.     get_tty_str("Press a key to continue...");
  56.  
  57.   } /* end for i */
  58. }
  59.  
  60.  
  61. /*
  62.   Itox() - takes the passed integer and returns the hex representation
  63. */
  64. itox(n)
  65. {
  66.   hi = n / 16;
  67.   if (hi >= 10)
  68.     hi = 'A' + hi - 10;
  69.   else
  70.     hi += '0';
  71.     
  72.   lo = n % 16;
  73.   if (lo >= 10)
  74.     lo = 'A' + lo - 10;
  75.   else
  76.     lo += '0';
  77.     
  78.   return strcat(chr(hi), chr(lo));
  79. }
  80.