home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / misc / cp-4.2.lha / cP / Source / rexxif.c < prev    next >
C/C++ Source or Header  |  1994-05-01  |  6KB  |  309 lines

  1. #include "cp.h"
  2.  
  3. BOOL FEED = TRUE;
  4.  
  5. LONG HandleARexxMes()
  6. {
  7.  
  8.     struct    RexxMsg        *rmsg;
  9.  
  10.     char    cBuf[24];
  11.     char    *nextchar;
  12.     char errstr[64];
  13.     char    *error=NULL;
  14.     char    *result=NULL;
  15.     long    errlevel=0;
  16.     long loopflag=1;
  17.     LONG ch;
  18.  
  19.     while (rmsg=GetARexxMsg(RexxStuff))
  20.          {
  21.         
  22.         nextchar=stptok(ARG0(rmsg),cBuf,24," ,");
  23.         
  24.         if (*nextchar) nextchar++;
  25.  
  26.         if (!Stricmp("OPEN",cBuf))
  27.           {
  28.               FreeAllSets();
  29.               
  30.               if (strlen(nextchar))
  31.                 {
  32.                     if (! AddSet(nextchar))
  33.                       {
  34.                           error="unable to add file";
  35.                           errlevel = 10;
  36.                       }
  37.                 }
  38.               else  AddNewSet();
  39.           }
  40.         else if (!Stricmp("ADD",cBuf))
  41.           {
  42.           
  43.               if (strlen(nextchar))
  44.                 {
  45.                     if (! AddSet(nextchar))
  46.                       {
  47.                           error="unable to add file";
  48.                           errlevel = 10;
  49.                       }
  50.                 }
  51.               else  AddNewSet();
  52.           }
  53.         else if (!Stricmp("XMIN",cBuf))
  54.           {
  55.           
  56.               if (strlen(nextchar))
  57.                 {
  58.                     if (sscanf(nextchar,"%le",&cv.xmin)!=1)
  59.                       {
  60.                           error="unable to convert value";
  61.                           errlevel = 10;
  62.                       }
  63.                 }
  64.               else
  65.                   {
  66.                       error="no value given";
  67.                       errlevel = 10;
  68.                   }
  69.           }
  70.         else if (!Stricmp("XMAX",cBuf))
  71.           {
  72.           
  73.               if (strlen(nextchar))
  74.                 {
  75.                     if (sscanf(nextchar,"%le",&cv.xmax)!=1)
  76.                       {
  77.                           error="unable to convert value";
  78.                           errlevel = 10;
  79.                       }
  80.                 }
  81.               else
  82.                   {
  83.                       error="no value given";
  84.                       errlevel = 10;
  85.                   }
  86.           }
  87.         else if (!Stricmp("YMIN",cBuf))
  88.           {
  89.           
  90.               if (strlen(nextchar))
  91.                 {
  92.                     if (sscanf(nextchar,"%le",&cv.ymin)!=1)
  93.                       {
  94.                           error="unable to convert value";
  95.                           errlevel = 10;
  96.                       }
  97.                 }
  98.               else
  99.                   {
  100.                       error="no value given";
  101.                       errlevel = 10;
  102.                   }
  103.           }
  104.         else if (!Stricmp("YMAX",cBuf))
  105.           {
  106.           
  107.               if (strlen(nextchar))
  108.                 {
  109.                     if (sscanf(nextchar,"%le",&cv.ymax)!=1)
  110.                       {
  111.                           error="unable to convert value";
  112.                           errlevel = 10;
  113.                       }
  114.                 }
  115.               else
  116.                   {
  117.                       error="no value given";
  118.                       errlevel = 10;
  119.                   }
  120.           }
  121.         else if (!Stricmp("POINTS",cBuf))
  122.           {
  123.           
  124.               if (strlen(nextchar))
  125.                 {
  126.                     if (sscanf(nextchar,"%ld",&points)!=1)
  127.                       {
  128.                           error="unable to convert value";
  129.                           errlevel = 10;
  130.                       }
  131.                 }
  132.               else
  133.                   {
  134.                       error="no value given";
  135.                       errlevel = 10;
  136.                   }
  137.           }
  138.         else if (!Stricmp("THIN",cBuf))
  139.           {
  140.           
  141.               if (strlen(nextchar))
  142.                 {
  143.                     if (sscanf(nextchar,"%ld",&thin)!=1)
  144.                       {
  145.                           error="unable to convert value";
  146.                           errlevel = 10;
  147.                       }
  148.                 }
  149.               else
  150.                   {
  151.                       error="no value given";
  152.                       errlevel = 10;
  153.                   }
  154.           }
  155.         else if (!Stricmp("DELAY",cBuf))
  156.           {
  157.           
  158.               if (strlen(nextchar))
  159.                 {
  160.                     if (sscanf(nextchar,"%ld",&ch)!=1)
  161.                       {
  162.                           error="unable to convert value";
  163.                           errlevel = 10;
  164.                       }
  165.                     else
  166.                         Delay(ch);
  167.                 }
  168.               else
  169.                   {
  170.                       error="no value given";
  171.                       errlevel = 10;
  172.                   }
  173.           }
  174.         else if (!Stricmp("FULL",cBuf))
  175.           {
  176.             fullClicked();
  177.           }
  178.         else if (!Stricmp("REDRAW",cBuf))
  179.           {
  180.              DrawView( FALSE );
  181.           }
  182.         else if (!Stricmp("LINX",cBuf))
  183.           {
  184.             LOGX=FALSE;
  185.           }
  186.         else if (!Stricmp("LINY",cBuf))
  187.           {
  188.             LOGY=FALSE;
  189.           }
  190.         else if (!Stricmp("LOGX",cBuf))
  191.           {
  192.             LOGX=TRUE;
  193.           }
  194.         else if (!Stricmp("LOGY",cBuf))
  195.           {
  196.             LOGY=TRUE;
  197.           }
  198.         else if (!Stricmp("SYM",cBuf))
  199.           {
  200.               SymAllSets();
  201.             sym=TRUE;
  202.           }
  203.         else if (!Stricmp("NOSYM",cBuf))
  204.           {
  205.             sym=FALSE;
  206.           }
  207.         else if (!Stricmp("CPANEL",cBuf))
  208.           {
  209.             CPANEL=TRUE;
  210.           }
  211.         else if (!Stricmp("NOCPANEL",cBuf))
  212.           {
  213.             CPANEL=FALSE;
  214.           }
  215.         else if (!Stricmp("NOFILENAMEBOXES",cBuf))
  216.           {
  217.             NOFNAME=TRUE;
  218.           }
  219.         else if (!Stricmp("FILENAMEBOXES",cBuf))
  220.           {
  221.             NOFNAME=FALSE;
  222.           }
  223.         else if (!Stricmp("GRID",cBuf))
  224.           {
  225.                Grid();
  226.             grid=TRUE;
  227.           }
  228.         else if (!Stricmp("NOGRID",cBuf))
  229.           {
  230.              Grid();
  231.             grid=FALSE;
  232.           }
  233.         else if (!Stricmp("FEED",cBuf))
  234.           {
  235.             FEED=TRUE;
  236.           }
  237.         else if (!Stricmp("NOFEED",cBuf))
  238.           {
  239.             FEED=FALSE;
  240.           }
  241.         else if (!Stricmp("ERASE",cBuf))
  242.           {
  243.             Erase(TRUE);
  244.           }
  245.         else if (!Stricmp("SCREENTOFRONT",cBuf))
  246.           {
  247.             ScreenToFront(Scr);
  248.           }
  249.         else if (!Stricmp("SCREENTOBACK",cBuf))
  250.           {
  251.             ScreenToBack(Scr);
  252.           }
  253.         else if (!Strnicmp("XLAB",cBuf,4))
  254.           {
  255.             strcpy(XLAB,nextchar);
  256.           }
  257.         else if (!Strnicmp("YLAB",cBuf,4))
  258.           {
  259.             strcpy(YLAB,nextchar);
  260.           }
  261.         else if (!Stricmp("TITLE",cBuf))
  262.           {
  263.             strcpy(TITLE,nextchar);
  264.           }
  265.         else if (!Stricmp("PRINT",cBuf))
  266.           {
  267.             errlevel = Dump();
  268.             
  269.             if (errlevel != PDERR_NOERR)
  270.               {
  271.                 if      (errlevel == PDERR_CANCEL)             error = "user abort";
  272.                 else if (errlevel == PDERR_NOTGRAPHICS)     error = "not graphics";
  273.                 else if (errlevel == PDERR_INVERTHAM)        error = "invert ham";
  274.                 else if (errlevel == PDERR_BADDIMENSION)    error = "bad dimensions";
  275.                 else if (errlevel == PDERR_DIMENSIONOVFLOW) error = "dimension overflow";
  276.                 else if (errlevel == PDERR_INTERNALMEMORY)  error = "internal memory";
  277.                 else if (errlevel == PDERR_BUFFERMEMORY)    error = "buffer memory";
  278.                 errlevel = 20;
  279.               }
  280.  
  281.           }
  282.         else if (!Stricmp("QUIT",cBuf))
  283.           {
  284.             loopflag=FALSE;
  285.           }
  286.         else
  287.           {
  288.             error="unknown command";
  289.             errlevel=20;
  290.           }
  291.  
  292.         if (error)
  293.             {
  294.             strcpy(errstr,"REXX ERROR <<<");
  295.             strcat(errstr,cBuf);
  296.             strcat(errstr," ");
  297.             strcat(errstr,nextchar);
  298.             strcat(errstr,">>>  ***");
  299.             strcat(errstr,error);
  300.             strcat(errstr,"***");
  301.               SetWindowTitles( PlotWindowWnd, NULL,errstr );
  302.             SetARexxLastError(RexxStuff,rmsg,error);
  303.           }
  304.  
  305.         ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
  306.       }
  307.  
  308.     return (loopflag);
  309. }