home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxtk12.zip / rexxtk.c < prev    next >
Text File  |  2002-08-07  |  21KB  |  607 lines

  1. /*
  2.  *  Rexx/Tk
  3.  *  Copyright (C) 1999       Roger O'Connor <ocon@metronet.com>
  4.  *  Copyright (C) 2000-2001  Mark Hessling  <M.Hessling@qut.edu.au>
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. #include "rexxtk.h"
  23.  
  24. #define MAX_VARIABLE_NAME_LENGTH 350
  25. /* take the 'start'th argument and check what kind of option parsing
  26.  * we are going to be doing and pass it off to the routine that will
  27.  * handle that type. */
  28. int rtk_procOptArgs(RFH_ARG0_TYPE name,char czCommand[], RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG1_TYPE start) {
  29.    int rc;
  30.  
  31.    /* If the first character of the first argument is
  32.     * a dash, then we process them in a row as is. */
  33.    if ( argv[start].strptr[0] == '-' )
  34.      rc =  rtk_procOptArgDash(name,czCommand, argc, argv, start);
  35.  
  36.    /* if the last character of the first arg is a dot,
  37.     * then we parse as option arrays */
  38.    else if ( argv[start].strptr[argv[start].strlength-1] == '.' )
  39.       rc =rtk_procOptArgArray(name,czCommand, argv, start);
  40.  
  41.    /* otherwise, we assume the indirect opt arg name
  42.     * variable usage */
  43.    
  44.    else
  45.       rc =rtk_procOptArgIndirect(name,czCommand, argc, argv, start);
  46.    return rc;
  47. }
  48.  
  49. /* take the next args (starting at start) and parses them as 'option'
  50.  * and 'value' pairs for tk and adds them to the czCommand string */
  51. int rtk_procOptArgDash(RFH_ARG0_TYPE name,char czCommand[], RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG1_TYPE start) {
  52.  
  53.    ULONG i;
  54.  
  55.    if ( argc > start
  56.    &&  (argc-start) % 2 == 0 )
  57.    {
  58.       for (i=start; i<argc; i=i+2)
  59.       {
  60.          /* if this argument starts with a dash then its a valid
  61.           * switch; the next argt is a value and it should
  62.           * be quoted */
  63.          if (argv[i].strptr[0] == '-')
  64.          {
  65.             /* check the option name for options
  66.              * that require special handling. */
  67.             if (!strncmp(argv[i].strptr, "-rexx", argv[i].strlength))
  68.             {
  69.                /*
  70.                 * If -rexx; convert to -command and value to
  71.                 * {setRexxtk value}
  72.                 */
  73.                strcat(czCommand, " -command {setRexxtk ");
  74.                strncat(czCommand, argv[i+1].strptr, argv[i+1].strlength);
  75.                strcat(czCommand, "}");
  76.             } 
  77.             else if (!strncmp(argv[i].strptr, "-xscrollrexx", argv[i].strlength))
  78.             {
  79.                /*
  80.                 * If -xscrollrexx; convert to -xscrollcommand and value to
  81.                 * {setRexxtk value}
  82.                 */
  83.                strcat(czCommand, " -xscrollcommand {setRexxtk ");
  84.                strncat(czCommand, argv[i+1].strptr, argv[i+1].strlength);
  85.                strcat(czCommand, "}");
  86.             } 
  87.             else if (!strncmp(argv[i].strptr, "-yscrollrexx", argv[i].strlength))
  88.             {
  89.                /*
  90.                 * If -yscrollrexx; convert to -yscrollcommand and value to
  91.                 * {setRexxtk value}
  92.                 */
  93.                strcat(czCommand, " -yscrollcommand {setRexxtk ");
  94.                strncat(czCommand, argv[i+1].strptr, argv[i+1].strlength);
  95.                strcat(czCommand, "}");
  96.             } 
  97.             else 
  98.             { /* normal quoting */
  99.                strcat(czCommand, " ");
  100.                strncat(czCommand, argv[i].strptr, argv[i].strlength);
  101.                strcat(czCommand, " {");
  102.                strncat(czCommand, argv[i+1].strptr, argv[i+1].strlength);
  103.                strcat(czCommand, "}");
  104.             }
  105.          } 
  106.          else 
  107.          {
  108.             RxDisplayError(name, "*ERROR* Option switches must be specified in pairs: -switch value");
  109.             return 1;
  110.          }
  111.       }
  112.    }
  113.    else
  114.    {
  115.       RxDisplayError(name, "*ERROR* Option switches must be specified in pairs: -switch value");
  116.       return 1;
  117.    }
  118.    return 0;
  119. }
  120.  
  121. /* takes the remaining arguments and parses them as names
  122.  * of options with the matching value stored in the rexx
  123.  * variable of the same name. */
  124. int rtk_procOptArgIndirect(RFH_ARG0_TYPE name,char czCommand[], RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG1_TYPE start) {
  125.  
  126.    char varname[MAX_VARIABLE_NAME_LENGTH+1];
  127.    RXSTRING value;
  128.  
  129.    ULONG i;
  130.    
  131.    for (i=start; i<argc; i++) 
  132.    {
  133.       /* get the rexx variable and if it has anything
  134.        * in it, treat that as the option value */
  135.       if ( argv[i].strlength > MAX_VARIABLE_NAME_LENGTH )
  136.          return 40;
  137.       varname[0] = '\0';
  138.       strncat(varname, argv[i].strptr, argv[i].strlength);
  139.       varname[argv[i].strlength] = '\0';
  140.       if (GetRexxVariable(varname,&value,-1) != NULL) 
  141.       {
  142.          /* check the option name for options
  143.           * that require special handling. */
  144.          if (!strncmp(argv[i].strptr, "rexx", argv[i].strlength)) 
  145.          {
  146.             /*
  147.              * If rexx; convert to -command and value to
  148.              * {setRexxtk value}
  149.              */
  150.             strcat(czCommand, " -command {setRexxtk ");
  151.             strncat(czCommand, value.strptr, value.strlength);
  152.             strcat(czCommand, "}");
  153.          } 
  154.          else if (!strncmp(argv[i].strptr, "xscrollrexx", argv[i].strlength))
  155.          {
  156.             /*
  157.              * If xscrollrexx; convert to -xscrollcommand and value to
  158.              * {setRexxtk value}
  159.              */
  160.             strcat(czCommand, " -xscrollcommand {setRexxtk ");
  161.             strncat(czCommand, value.strptr, value.strlength);
  162.             strcat(czCommand, "}");
  163.          } 
  164.          else if (!strncmp(argv[i].strptr, "yscrollrexx", argv[i].strlength))
  165.          {
  166.             /*
  167.              * If yscrollrexx; convert to -yscrollcommand and value to
  168.              * {setRexxtk value}
  169.              */
  170.             strcat(czCommand, " -yscrollcommand {setRexxtk ");
  171.             strncat(czCommand, value.strptr, value.strlength);
  172.             strcat(czCommand, "}");
  173.          } 
  174.          else 
  175.          {
  176.             strcat(czCommand, " -");
  177.             strncat(czCommand, argv[i].strptr, argv[i].strlength);
  178.             strcat(czCommand, " {");
  179.             strncat(czCommand, value.strptr, value.strlength);
  180.             strcat(czCommand, "}");
  181.          }
  182.          free(value.strptr);
  183.       }
  184.    }
  185.    return 0;
  186. }
  187.  
  188. /* takes the next two args from the rexx argument list and treats them as
  189.  * the names of a pair of name/value arrays to fetch the remaining Tcl
  190.  * arguments from */
  191. int rtk_procOptArgArray(RFH_ARG0_TYPE name,char czCommand[], RFH_ARG2_TYPE argv, RFH_ARG1_TYPE start) {
  192.  
  193.    char nameName[MAX_VARIABLE_NAME_LENGTH+1]="\0";
  194.    char valueName[MAX_VARIABLE_NAME_LENGTH+1]="\0";
  195.    static char sbuff[1024];
  196.    RXSTRING varname;
  197.    RXSTRING value;
  198.    RXSTRING *rc_value;
  199.  
  200.    ULONG i;
  201.    
  202.    if ( argv[start].strlength > MAX_VARIABLE_NAME_LENGTH )
  203.       return 40;
  204.    if ( argv[start+1].strlength > MAX_VARIABLE_NAME_LENGTH )
  205.       return 40;
  206.    strncat(nameName, argv[start].strptr,argv[start].strlength);
  207.    nameName[argv[start].strlength] = '\0'; /* NULL terminate */
  208.    strncat(valueName, argv[start+1].strptr,argv[start+1].strlength);
  209.    valueName[argv[start+1].strlength] = '\0'; /* NULL terminate */ 
  210.    
  211.    for (i=1;1;i++) {
  212.       
  213.       if (GetRexxVariable(nameName,&varname,i) == NULL)
  214.          /* then it wasn't defined, so we're done */
  215.          break;
  216.       rc_value = GetRexxVariable(valueName,&value,i);
  217.  
  218.       sbuff[0] = '\0';
  219.       strncat(sbuff, varname.strptr, varname.strlength);
  220.       
  221.       /*
  222.        * Check the options and handle the value based on some
  223.        * special situations for various options.
  224.        */
  225.       if (!strcmp(sbuff, "rexx")) 
  226.       {
  227.          /*
  228.           * If rexx; convert to -command and value to
  229.           * {setRexxtk value}
  230.           */
  231.          strcat(czCommand, " -command {setRexxtk ");
  232.          strncat(czCommand, value.strptr, value.strlength);
  233.          strcat(czCommand, "}");
  234.       } 
  235.       else if (!strcmp(sbuff, "xscrollrexx"))
  236.       {
  237.          /*
  238.           * If xscrollrexx; convert to -xscrollcommand and value to
  239.           * {setRexxtk value}
  240.           */
  241.          strcat(czCommand, " -xscrollcommand {setRexxtk ");
  242.          strncat(czCommand, value.strptr, value.strlength);
  243.          strcat(czCommand, "}");
  244.       } 
  245.       else if (!strcmp(sbuff, "yscrollrexx"))
  246.       {
  247.          /*
  248.           * If yscrollrexx; convert to -yscrollcommand and value to
  249.           * {setRexxtk value}
  250.           */
  251.          strcat(czCommand, " -yscrollcommand {setRexxtk ");
  252.          strncat(czCommand, value.strptr, value.strlength);
  253.          strcat(czCommand, "}");
  254.       } 
  255.       else 
  256.       {
  257.          /* cat the option name with a hyphen */
  258.          strcat(czCommand, " -");
  259.          strncat(czCommand, varname.strptr, varname.strlength);
  260.          /* cat the value if there is one */
  261.          if (rc_value!=NULL) 
  262.          {
  263.             strcat(czCommand, " {");
  264.             sbuff[0] = '\0';
  265.             strncat(czCommand, value.strptr, value.strlength);
  266.             strcat(czCommand, "}");
  267.          }
  268.       }
  269.  
  270.       free(varname.strptr);
  271.       free(value.strptr);
  272.    }
  273.    return 0;
  274. }
  275.  
  276. /*
  277.  * Handle the Tcl RexxTkInterp error message...
  278.  *  at this time we are just outputting to stdout.
  279.  */
  280. void SetIntError(REXXTKDATA *RexxTkData,int errnum, char *errstr )
  281. {
  282.    char    buf[20];
  283.    RexxTkData->REXXTK_IntCode = errnum;
  284.    InternalTrace("SetIntError", "Error Number: %d String: %s", errnum, errstr );
  285.    (void)sprintf(buf, "%ld", errnum);
  286.    (void)SetRexxVariable("TKRC", 4,buf, strlen(buf));
  287.    (void)sprintf(RexxTkData->REXXTK_ErrMsg, "Rexx/Tk:%ld: Tcl Line: %d: %s", errnum, RexxTkData->RexxTkInterp->errorLine,errstr);
  288. }
  289.  
  290. /*
  291.  * Clear the internal error code, error message etc.
  292.  */
  293. void ClearIntError(REXXTKDATA *RexxTkData)
  294. {
  295.    RexxTkData->REXXTK_IntCode = 0;
  296.  
  297.    InternalTrace("ClearIntError", NULL );
  298.  
  299.    /* 
  300.     * Set RC variable
  301.     */
  302.    (void)SetRexxVariable("TKRC", 4,"0", 1);
  303.    strcpy(RexxTkData->REXXTK_ErrMsg,"");
  304.    return;
  305. }
  306.  
  307. int ReturnError
  308.    ( REXXTKDATA *RexxTkData, RXSTRING *retstr, int errnum, char *errstr )
  309. {
  310.    InternalTrace( "ReturnError", "%x,%d %s", retstr, errnum, errstr );
  311.  
  312.    SetIntError(RexxTkData,errnum, errstr );
  313.    sprintf( (char *)retstr->strptr, "%ld", errnum );
  314.    retstr->strlength = strlen( (char *)retstr->strptr );
  315.    return( 0 );
  316. }
  317.  
  318. /*
  319.  * A routine to handle a generic type of Tcl Function - TYPE A
  320.  * which are in the tcl form:
  321.  *   command pathName ?options?
  322.  * and are in the rexx form:
  323.  *   TkCommand(pathName, [options...])
  324.  */
  325. RFH_RETURN_TYPE rtk_TypeA
  326.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr )
  327. {
  328.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  329.  
  330.    if ( my_checkparam( name, argc, 1, 0 ) )
  331.       return 1;
  332.  
  333.    czTclCommand[0] = '\0';
  334.  
  335.    strcat(czTclCommand, czCommand);
  336.    strcat(czTclCommand, " ");
  337.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  338.    if (argc >= 2)
  339.    {
  340.       if ( rtk_procOptArgs(name,czTclCommand,argc,argv,1) )
  341.          return 1;
  342.    }
  343.    
  344.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  345.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  346.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  347.    }
  348.  
  349.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  350. }
  351.    
  352. /*
  353.  * A routine to handle a generic type of Tcl Function - TYPE B
  354.  * which are in the tcl form:
  355.  *   command arg ?arg arg ...?
  356.  * and are in the rexx form:
  357.  *   TkCommand(arg, [arg, arg, ...])
  358.  */
  359. RFH_RETURN_TYPE rtk_TypeB
  360.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr)
  361. {
  362.    /*
  363.     * TODO: the quoting in this routine needs to be beefed up.
  364.     * Currently we are quoting everything with braces even if it's
  365.     * not needed.  This means that you can't use a brace in an argument.
  366.     */
  367.    int i;
  368.  
  369.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  370.  
  371.    if ( my_checkparam( name, argc, 1, 0 ) )
  372.       return 1;
  373.    
  374.    czTclCommand[0] = '\0';
  375.  
  376.    strcat(czTclCommand, czCommand);
  377.    strcat(czTclCommand, " {"); /* we want to quote all the args -- in case */
  378.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  379.    for (i = 1; i < (int)argc; i++){
  380.       strcat(czTclCommand, "} {");
  381.       strncat(czTclCommand, argv[i].strptr, argv[i].strlength);
  382.    }
  383.    strcat(czTclCommand, "}");
  384.    
  385.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  386.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  387.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  388.    }
  389.  
  390.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  391. }
  392.    
  393. /*
  394.  * A routine to handle a generic type of Tcl Function - TYPE C
  395.  * which are in the tcl form:
  396.  *   pathName command ?arg arg ...?
  397.  * and are in the rexx form:
  398.  *   TkCommand(pathName [,arg, arg, ...])
  399.  */
  400. RFH_RETURN_TYPE rtk_TypeC
  401.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr)
  402. {
  403.    int i;
  404.  
  405.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  406.  
  407.    if ( my_checkparam( name, argc, 1, 0 ) )
  408.       return 1;
  409.    
  410.    czTclCommand[0] = '\0';
  411.  
  412.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  413.    strcat(czTclCommand, " ");
  414.    strcat(czTclCommand, czCommand);
  415.    for (i = 1; i < (int)argc; i++){
  416.       strcat(czTclCommand, " \"");
  417.       strncat(czTclCommand, argv[i].strptr, argv[i].strlength);
  418.       strcat(czTclCommand, "\"");
  419.    }
  420.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  421.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  422.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  423.    }
  424.    
  425.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  426. }
  427.    
  428. /*
  429.  * A routine to handle a generic type of Tcl Function - TYPE D
  430.  * which are in the tcl form:
  431.  *   pathName command arg ?options?
  432.  * and are in the rexx form:
  433.  *   TkCommand(pathName, arg, [options...])
  434.  */
  435. RFH_RETURN_TYPE rtk_TypeD
  436.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name, char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr )
  437. {
  438.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  439.  
  440.    if ( my_checkparam( name, argc, 2, 0 ) )
  441.       return 1;
  442.    
  443.    czTclCommand[0] = '\0';
  444.  
  445.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  446.    strcat(czTclCommand, " ");
  447.    strcat(czTclCommand, czCommand);
  448.    strcat(czTclCommand, " ");
  449.    strncat(czTclCommand, argv[1].strptr, argv[1].strlength);
  450.    if (argc > 2)
  451.    {
  452.       if ( rtk_procOptArgs(name,czTclCommand,argc,argv,2) )
  453.          return 1;
  454.    }
  455.    
  456.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  457.  
  458.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  459.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  460.    }
  461.    
  462.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  463. }
  464.    
  465. /*
  466.  * A routine to handle a generic type of Tcl Function - TYPE E
  467.  * which are in the tcl form:
  468.  *   pathName command ?options?
  469.  * and are in the rexx form:
  470.  *   TkCommand(pathName, [options...])
  471.  */
  472. RFH_RETURN_TYPE rtk_TypeE
  473.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr)
  474. {
  475.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  476.  
  477.    if ( my_checkparam( name, argc, 1, 0 ) )
  478.       return 1;
  479.    
  480.    czTclCommand[0] = '\0';
  481.  
  482.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  483.    strcat(czTclCommand, " ");
  484.    strcat(czTclCommand, czCommand);
  485.    if (argc > 1)
  486.    {
  487.       if ( rtk_procOptArgs(name,czTclCommand,argc,argv,1) )
  488.          return 1;
  489.    }
  490.    
  491.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  492.  
  493.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  494.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  495.    }
  496.    
  497.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  498. }
  499.    
  500. /*
  501.  * A routine to handle a generic type of Tcl Function - TYPE F
  502.  * which are in the tcl form:
  503.  *   command pathName ?pathName? ?options?
  504.  * or
  505.  *   command arg ?arg? ?options?
  506.  * and are in the rexx form:
  507.  *   TkCommand(pathName [,pathName...] [options...])
  508.  * or
  509.  *   TkCommand(arg [,arg...] [options...])
  510.  */
  511. RFH_RETURN_TYPE rtk_TypeF
  512.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr)
  513. {
  514.    int i;
  515.  
  516.    FunctionPrologue( (char *)name, argc, argv );
  517.  
  518.    if (RexxTkData->REXXTK_IntCode) ClearIntError( RexxTkData);
  519.  
  520.    czTclCommand[0] = '\0';
  521.  
  522.    strcat(czTclCommand, czCommand);
  523.    for (i = 0; i < (int)argc; i++){
  524.       /* 
  525.        * check if the arg has a dash as the first char,
  526.        * if so, it's the start of the options
  527.        * This allows either pathnames or args before options
  528.        */
  529.       if (argv[i].strptr[0] == '-')
  530.       {
  531.          if ( rtk_procOptArgs(name,czTclCommand,argc,argv,i) )
  532.             return 1;
  533.          break;
  534.       }
  535.       strcat(czTclCommand, " ");
  536.       strncat(czTclCommand, argv[i].strptr, argv[i].strlength);
  537.    }
  538.  
  539.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  540.  
  541.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  542.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  543.    }
  544.  
  545.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  546. }
  547. /*
  548.  * A routine to handle a generic type of Tcl Function - TYPE G
  549.  * which are in the tcl form:
  550.  *   command pathName arg ?options?
  551.  * and are in the rexx form:
  552.  *   TkCommand(pathName, arg [,options...])
  553.  */
  554. RFH_RETURN_TYPE rtk_TypeG
  555.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr )
  556. {
  557.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  558.  
  559.    if ( my_checkparam( name, argc, 2, 0 ) )
  560.       return 1;
  561.  
  562.    strcpy(czTclCommand, czCommand);
  563.    strcat(czTclCommand, " ");
  564.    strncat(czTclCommand, argv[0].strptr, argv[0].strlength);
  565.    strcat(czTclCommand, " ");
  566.    strncat(czTclCommand, argv[1].strptr, argv[1].strlength);
  567.    if (argc >= 3)
  568.    {
  569.       if ( rtk_procOptArgs(name,czTclCommand,argc,argv,2) )
  570.          return 1;
  571.    }
  572.    
  573.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  574.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  575.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  576.    }
  577.  
  578.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  579. }
  580. /*
  581.  * A routine to handle a generic type of Tcl Function - TYPE H
  582.  * which are in the tcl form:
  583.  *   command ?options?
  584.  * and are in the rexx form:
  585.  *   TkCommand(option [,options...])
  586.  */
  587. RFH_RETURN_TYPE rtk_TypeH
  588.    (REXXTKDATA *RexxTkData, char czTclCommand[], RFH_ARG0_TYPE name,char *czCommand, RFH_ARG1_TYPE argc, RFH_ARG2_TYPE argv, RFH_ARG4_TYPE retstr )
  589. {
  590.    if (RexxTkData->REXXTK_IntCode) ClearIntError(RexxTkData);
  591.  
  592.    if ( my_checkparam( name, argc, 1, 0 ) )
  593.       return 1;
  594.  
  595.    strcpy(czTclCommand, czCommand);
  596.    strcat(czTclCommand, " ");
  597.    if ( rtk_procOptArgs(name,czTclCommand,argc,argv,0) )
  598.       return 1;
  599.    
  600.    DEBUGDUMP(fprintf(stderr,"%s-%d: (%s) command: %s\n",__FILE__,__LINE__,name,czTclCommand);)
  601.    if (Tcl_Eval(RexxTkData->RexxTkInterp, czTclCommand) != TCL_OK) {
  602.       return ReturnError( RexxTkData, retstr, -1, RexxTkData->RexxTkInterp->result );
  603.    }
  604.  
  605.    return RxReturnString( retstr, RexxTkData->RexxTkInterp->result ) ;
  606. }
  607.