home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / DCFVBA.ZIP / DCFAST.C < prev    next >
Text File  |  1990-05-04  |  3KB  |  127 lines

  1. /**
  2. ***  This is a part of the PCL2VBA project.   This set of functions handle
  3. ***  The PCL datastreams beginning with:  <Esc>*
  4. **/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "dcfvba.h"
  10.  
  11. /* -------------------------------------------------------------------------- */
  12.  
  13. void pcl_asterisk(void)
  14.    {
  15.    char pcl_command;
  16.  
  17.    next_char();
  18.    pcl_command = (char)toupper(*current);
  19.    switch(pcl_command)
  20.       {
  21.       case 'P':
  22.          {
  23.          do
  24.             {
  25.             next_char();
  26.             pcl_asterisk_P();
  27.             } /* do */
  28.          while(strchr(PCL_END_SET,*current) == NULL);
  29.          break;
  30.          } /* case 'P' */
  31.       default:
  32.          {
  33.          char error_message[255];
  34.  
  35.          sprintf(error_message,"Unsupported PCL command: <Esc>*%c",*current);
  36.          error(error_message,8);
  37.          } /* default */
  38.       } /* switch */
  39.    } /* pcl_asterisk */
  40.  
  41. /* -------------------------------------------------------------------------- */
  42.  
  43. void pcl_asterisk_P(void)
  44.    {
  45.    int    signed_arg = NOSIGN; /* Flag indicating whether the argument was signed */
  46.    int    target_row;      /* Used to calculate what the new output row is */
  47.    char   pcl_char;
  48.    double number;
  49.  
  50.    /* Handle the sign if one exists */
  51.  
  52.    switch(*current)
  53.       {
  54.       case '+':
  55.          {
  56.          signed_arg = POSITIVE;
  57.          next_char();
  58.          break;
  59.          }
  60.       case '-':
  61.          {
  62.          signed_arg = NEGATIVE;
  63.          next_char();
  64.          break;
  65.          }
  66.       } /* switch */
  67.  
  68.    number = get_pcl_arg();
  69.  
  70.    pcl_char = (char)toupper(*current);
  71.    switch (pcl_char)
  72.       {
  73.       case 'X': /* Horizontal positioning by dot */
  74.          {
  75.          switch(signed_arg)
  76.             {
  77.             case POSITIVE:
  78.                {
  79.                strpad(column_by_dot(number)+strlen(line));
  80.                break;
  81.                }
  82.             case NOSIGN:
  83.                {
  84.                strpad(column_by_dot(number));
  85.                break;
  86.                }
  87.             case NEGATIVE:
  88.                {
  89.                strpad(column_by_dot(number)-strlen(line));
  90.                break;
  91.                }
  92.             }
  93.          break;
  94.          }
  95.       case 'Y': /* Absolute vertical position by dot */
  96.          {
  97.          target_row = row_by_dot(number);
  98.          switch(signed_arg)
  99.             {
  100.             case POSITIVE:
  101.                {
  102.                position_vertical(logical_vpos+target_row);
  103.                break;
  104.                }
  105.             case NOSIGN:
  106.                {
  107.                if (target_row < logical_vpos)
  108.                   {
  109.                   error("Negative vertical positioning may not work as expected.",0);
  110.                   logical_vpos = target_row;
  111.                   }
  112.                else
  113.                   position_vertical(target_row);
  114.                break;
  115.                }
  116.             case NEGATIVE:
  117.                {
  118.                error("Negative vertical positioning may not work as expected.",0);
  119.                logical_vpos -= target_row;
  120.                break;
  121.                }
  122.             } /* switch */
  123.          break;
  124.          } /* case 'Y' */
  125.       } /* Switch */
  126.    }  /* pcl_asterisk_P */
  127.