home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / misc / cp-4.3.lha / cP / Source / rexxif.c < prev    next >
C/C++ Source or Header  |  1994-08-03  |  7KB  |  350 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.     UBYTE fn[128];
  18.     LONG ch;
  19.     LONG xpos=0;
  20.     LONG ypos=0;
  21.  
  22.     while (rmsg=GetARexxMsg(RexxStuff))
  23.          {
  24.         
  25.         nextchar=stptok(ARG0(rmsg),cBuf,24," ,");
  26.         
  27.         if (*nextchar) nextchar++;
  28.  
  29.         if (!Stricmp("OPEN",cBuf))
  30.           {
  31.               FreeAllSets();
  32.               
  33.               if (strlen(nextchar))
  34.                 {
  35.                     if (! AddSet(nextchar))
  36.                       {
  37.                           error="unable to add file";
  38.                           errlevel = 10;
  39.                       }
  40.                 }
  41.               else  AddNewSet();
  42.           }
  43.         else if (!Stricmp("ADD",cBuf))
  44.           {
  45.           
  46.               if (strlen(nextchar))
  47.                 {
  48.                     if (! AddSet(nextchar))
  49.                       {
  50.                           error="unable to add file";
  51.                           errlevel = 10;
  52.                       }
  53.                 }
  54.               else  AddNewSet();
  55.           }
  56.         else if (!Stricmp("XMIN",cBuf))
  57.           {
  58.           
  59.               if (strlen(nextchar))
  60.                 {
  61.                     if (sscanf(nextchar,"%le",&cv.xmin)!=1)
  62.                       {
  63.                           error="unable to convert value";
  64.                           errlevel = 10;
  65.                       }
  66.                 }
  67.               else
  68.                   {
  69.                       error="no value given";
  70.                       errlevel = 10;
  71.                   }
  72.           }
  73.         else if (!Stricmp("XMAX",cBuf))
  74.           {
  75.           
  76.               if (strlen(nextchar))
  77.                 {
  78.                     if (sscanf(nextchar,"%le",&cv.xmax)!=1)
  79.                       {
  80.                           error="unable to convert value";
  81.                           errlevel = 10;
  82.                       }
  83.                 }
  84.               else
  85.                   {
  86.                       error="no value given";
  87.                       errlevel = 10;
  88.                   }
  89.           }
  90.         else if (!Stricmp("YMIN",cBuf))
  91.           {
  92.           
  93.               if (strlen(nextchar))
  94.                 {
  95.                     if (sscanf(nextchar,"%le",&cv.ymin)!=1)
  96.                       {
  97.                           error="unable to convert value";
  98.                           errlevel = 10;
  99.                       }
  100.                 }
  101.               else
  102.                   {
  103.                       error="no value given";
  104.                       errlevel = 10;
  105.                   }
  106.           }
  107.         else if (!Stricmp("YMAX",cBuf))
  108.           {
  109.           
  110.               if (strlen(nextchar))
  111.                 {
  112.                     if (sscanf(nextchar,"%le",&cv.ymax)!=1)
  113.                       {
  114.                           error="unable to convert value";
  115.                           errlevel = 10;
  116.                       }
  117.                 }
  118.               else
  119.                   {
  120.                       error="no value given";
  121.                       errlevel = 10;
  122.                   }
  123.           }
  124.         else if (!Stricmp("POINTS",cBuf))
  125.           {
  126.           
  127.               if (strlen(nextchar))
  128.                 {
  129.                     if (sscanf(nextchar,"%ld",&points)!=1)
  130.                       {
  131.                           error="unable to convert value";
  132.                           errlevel = 10;
  133.                       }
  134.                 }
  135.               else
  136.                   {
  137.                       error="no value given";
  138.                       errlevel = 10;
  139.                   }
  140.           }
  141.         else if (!Stricmp("THIN",cBuf))
  142.           {
  143.           
  144.               if (strlen(nextchar))
  145.                 {
  146.                     if (sscanf(nextchar,"%ld",&thin)!=1)
  147.                       {
  148.                           error="unable to convert value";
  149.                           errlevel = 10;
  150.                       }
  151.                 }
  152.               else
  153.                   {
  154.                       error="no value given";
  155.                       errlevel = 10;
  156.                   }
  157.           }
  158.         else if (!Stricmp("DELAY",cBuf))
  159.           {
  160.           
  161.               if (strlen(nextchar))
  162.                 {
  163.                     if (sscanf(nextchar,"%ld",&ch)!=1)
  164.                       {
  165.                           error="unable to convert value";
  166.                           errlevel = 10;
  167.                       }
  168.                     else
  169.                         Delay(ch);
  170.                 }
  171.               else
  172.                   {
  173.                       error="no value given";
  174.                       errlevel = 10;
  175.                   }
  176.           }
  177.         else if (!Stricmp("TEXT",cBuf))
  178.           {
  179.               if (sscanf(nextchar,"%ld%ld",&xpos,&ypos)==2)
  180.                 {
  181.                     while( isspace(*nextchar) && *nextchar!='\0')++nextchar;
  182.                     while(!isspace(*nextchar) && *nextchar!='\0')++nextchar;
  183.                     while( isspace(*nextchar) && *nextchar!='\0')++nextchar;
  184.                     while(!isspace(*nextchar) && *nextchar!='\0')++nextchar;
  185.                     SetDrMd( rp,JAM1);
  186.                      SetAPen( rp, (MONO ? 1 : 2));
  187.                     Move( rp,xpos,ypos);
  188.                     Text( rp,nextchar,strlen(nextchar));
  189.                 }
  190.               else
  191.                   {
  192.                       error="invalid arg string";
  193.                       errlevel = 10;
  194.                   }
  195.           }
  196.         else if (!Stricmp("VERTTEXT",cBuf))
  197.           {
  198.               if (sscanf(nextchar,"%ld%ld",&xpos,&ypos)==2)
  199.                 {
  200.                     while( isspace(*nextchar) && *nextchar!='\0')++nextchar;
  201.                     while(!isspace(*nextchar) && *nextchar!='\0')++nextchar;
  202.                     while( isspace(*nextchar) && *nextchar!='\0')++nextchar;
  203.                     while(!isspace(*nextchar) && *nextchar!='\0')++nextchar;
  204.                     SetDrMd( rp,JAM1);
  205.                      SetAPen( rp, (MONO ? 1 : 2));
  206.                     Move( rp,xpos,ypos);
  207.                     VertText( rp,nextchar,strlen(nextchar));
  208.                 }
  209.               else
  210.                   {
  211.                       error="invalid arg string";
  212.                       errlevel = 10;
  213.                   }
  214.           }
  215.         else if (!Stricmp("FULL",cBuf))
  216.           {
  217.             fullClicked();
  218.           }
  219.         else if (!Stricmp("REDRAW",cBuf))
  220.           {
  221.              DrawView( FALSE );
  222.           }
  223.         else if (!Stricmp("LINX",cBuf))
  224.           {
  225.             LOGX=FALSE;
  226.           }
  227.         else if (!Stricmp("LINY",cBuf))
  228.           {
  229.             LOGY=FALSE;
  230.           }
  231.         else if (!Stricmp("LOGX",cBuf))
  232.           {
  233.             LOGX=TRUE;
  234.           }
  235.         else if (!Stricmp("LOGY",cBuf))
  236.           {
  237.             LOGY=TRUE;
  238.           }
  239.         else if (!Stricmp("SYM",cBuf))
  240.           {
  241.               SymAllSets();
  242.             sym=TRUE;
  243.           }
  244.         else if (!Stricmp("NOSYM",cBuf))
  245.           {
  246.             sym=FALSE;
  247.           }
  248.         else if (!Stricmp("CPANEL",cBuf))
  249.           {
  250.             CPANEL=TRUE;
  251.           }
  252.         else if (!Stricmp("NOCPANEL",cBuf))
  253.           {
  254.             CPANEL=FALSE;
  255.           }
  256.         else if (!Stricmp("NOFILENAMEBOXES",cBuf))
  257.           {
  258.             NOFNAME=TRUE;
  259.           }
  260.         else if (!Stricmp("FILENAMEBOXES",cBuf))
  261.           {
  262.             NOFNAME=FALSE;
  263.           }
  264.         else if (!Stricmp("GRID",cBuf))
  265.           {
  266.                Grid();
  267.             grid=TRUE;
  268.           }
  269.         else if (!Stricmp("NOGRID",cBuf))
  270.           {
  271.              Grid();
  272.             grid=FALSE;
  273.           }
  274.         else if (!Stricmp("FEED",cBuf))
  275.           {
  276.             FEED=TRUE;
  277.           }
  278.         else if (!Stricmp("NOFEED",cBuf))
  279.           {
  280.             FEED=FALSE;
  281.           }
  282.         else if (!Stricmp("ERASE",cBuf))
  283.           {
  284.             Erase(TRUE);
  285.           }
  286.         else if (!Stricmp("SCREENTOFRONT",cBuf))
  287.           {
  288.             ScreenToFront(Scr);
  289.           }
  290.         else if (!Stricmp("SCREENTOBACK",cBuf))
  291.           {
  292.             ScreenToBack(Scr);
  293.           }
  294.         else if (!Strnicmp("XLAB",cBuf,4))
  295.           {
  296.             strcpy(XLAB,nextchar);
  297.           }
  298.         else if (!Strnicmp("YLAB",cBuf,4))
  299.           {
  300.             strcpy(YLAB,nextchar);
  301.           }
  302.         else if (!Stricmp("TITLE",cBuf))
  303.           {
  304.             strcpy(TITLE,nextchar);
  305.           }
  306.         else if (!Stricmp("PRINT",cBuf))
  307.           {
  308.             errlevel = Dump();
  309.             
  310.             if (errlevel != PDERR_NOERR)
  311.               {
  312.                 if      (errlevel == PDERR_CANCEL)             error = "user abort";
  313.                 else if (errlevel == PDERR_NOTGRAPHICS)     error = "not graphics";
  314.                 else if (errlevel == PDERR_INVERTHAM)        error = "invert ham";
  315.                 else if (errlevel == PDERR_BADDIMENSION)    error = "bad dimensions";
  316.                 else if (errlevel == PDERR_DIMENSIONOVFLOW) error = "dimension overflow";
  317.                 else if (errlevel == PDERR_INTERNALMEMORY)  error = "internal memory";
  318.                 else if (errlevel == PDERR_BUFFERMEMORY)    error = "buffer memory";
  319.                 errlevel = 20;
  320.               }
  321.  
  322.           }
  323.         else if (!Stricmp("QUIT",cBuf))
  324.           {
  325.             loopflag=FALSE;
  326.           }
  327.         else
  328.           {
  329.             error="unknown command";
  330.             errlevel=20;
  331.           }
  332.  
  333.         if (error)
  334.             {
  335.             strcpy(errstr,"REXX ERROR <<<");
  336.             strcat(errstr,cBuf);
  337.             strcat(errstr," ");
  338.             strcat(errstr,nextchar);
  339.             strcat(errstr,">>>  ***");
  340.             strcat(errstr,error);
  341.             strcat(errstr,"***");
  342.               SetWindowTitles( PlotWindowWnd, NULL,errstr );
  343.             SetARexxLastError(RexxStuff,rmsg,error);
  344.           }
  345.  
  346.         ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
  347.       }
  348.  
  349.     return (loopflag);
  350. }