/[ascend]/trunk/tcltk/generic/interface/Driver.c
ViewVC logotype

Diff of /trunk/tcltk/generic/interface/Driver.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 585 by ben.allan, Tue May 9 19:14:25 2006 UTC revision 586 by johnpye, Thu May 11 00:47:54 2006 UTC
# Line 33  Line 33 
33  #include <tcl.h>  #include <tcl.h>
34  #include <tk.h>  #include <tk.h>
35  #include <utilities/ascConfig.h>  #include <utilities/ascConfig.h>
36    #include <general/ospath.h>
37    #include <utilities/ascPrint.h>
38    
39  #ifndef __WIN32__  #ifndef __WIN32__
40  # include <unistd.h>  # include <unistd.h>
# Line 118  extern int zz_debug; Line 120  extern int zz_debug;
120  extern int  Tktable_Init(Tcl_Interp*);  extern int  Tktable_Init(Tcl_Interp*);
121    
122  static void AscTrap(int);  static void AscTrap(int);
123  static int  AscCheckEnvironVars(Tcl_Interp*);  static int  AscCheckEnvironVars(Tcl_Interp*,const char *progname);
124  static void AscPrintHelpExit(CONST char *);  static void AscPrintHelpExit(CONST char *);
125  static int  AscProcessCommandLine(Tcl_Interp*, int, CONST char **);  static int  AscProcessCommandLine(Tcl_Interp*, int, CONST char **);
126  static void Prompt(Tcl_Interp*, int);  static void Prompt(Tcl_Interp*, int);
# Line 129  static void InitDebugMalloc(void); Line 131  static void InitDebugMalloc(void);
131  #endif /* DEBUG_MALLOC */  #endif /* DEBUG_MALLOC */
132    
133    
   
134  /*  /*
135   *  LOCALLY GLOBAL VARIABLES   *  LOCALLY GLOBAL VARIABLES
136   */   */
# Line 231  static char build_name[]="by anonymous"; Line 232  static char build_name[]="by anonymous";
232  static char build_name[]=TIMESTAMP;  static char build_name[]=TIMESTAMP;
233  #endif /* TIMESTAMP */  #endif /* TIMESTAMP */
234    
   
235  /**  /**
236      Moved 'main' and 'WinMain' to separate 'main.c'      Moved 'main' and 'WinMain' to separate 'main.c'
237      so that ascend4.exe can be built without linkage to Tcl/Tk      so that ascend4.exe can be built without linkage to Tcl/Tk
# Line 343  int AscDriver(int argc, CONST char *argv Line 343  int AscDriver(int argc, CONST char *argv
343     *  Now that our console and printing functions are properly     *  Now that our console and printing functions are properly
344     *  initialized, print our startup banner.     *  initialized, print our startup banner.
345     */     */
346    PRINTF("ASCEND VERSION IV\n");  
347    PRINTF("Compiler Implemention Version: 2.0\n");    color_on(stderr,"34;1");
348    PRINTF("Written by Tom Epperly, Kirk Abbott, and Ben Allan\n");    ASC_FPRINTF(stderr,"\nASCEND modelling environment\n");
349    PRINTF("  Built: %s %s %s\n",__DATE__,__TIME__,build_name);    ASC_FPRINTF(stderr,"Copyright(C) 1997, 2006 Carnegie Mellon University\n");
350    PRINTF("Copyright(C) 1990, 1993, 1994 Thomas Guthrie Epperly\n");    ASC_FPRINTF(stderr,"Copyright(C) 1993-1996 Kirk Andre Abbott, Ben Allan\n");
351    PRINTF("Copyright(C) 1993-1996 Kirk Andre Abbott, Ben Allan\n");    ASC_FPRINTF(stderr,"Copyright(C) 1990, 1993, 1994 Thomas Guthrie Epperly\n");
352    PRINTF("Copyright(C) 1997 Carnegie Mellon University\n");    ASC_FPRINTF(stderr,"Built %s %s %s\n\n",__DATE__,__TIME__,build_name);
353      ASC_FPRINTF(stderr,"ASCEND comes with ABSOLUTELY NO WARRANTY, and is free software that you may\n");
354      ASC_FPRINTF(stderr,"redistribute within the conditions of the GNU General Public License. See the\n");
355      ASC_FPRINTF(stderr,"included file 'LICENSE.txt' for full details.\n\n");
356      color_off(stderr);
357    
358    /*    /*
359     *  Call the init procedures for included packages.     *  Call the init procedures for included packages.
# Line 389  int AscDriver(int argc, CONST char *argv Line 393  int AscDriver(int argc, CONST char *argv
393     *  Set the environment, and set find the     *  Set the environment, and set find the
394     *  location of ASCEND's startup file.     *  location of ASCEND's startup file.
395     */     */
396    AscCheckEnvironVars(interp);    AscCheckEnvironVars(interp,argv[0]);
397    if( AscSetStartupFile(interp) != TCL_OK ) {    if( AscSetStartupFile(interp) != TCL_OK ) {
398      Asc_Panic(2, "Asc_Driver",      Asc_Panic(2, "Asc_Driver",
399                "Cannot find ~/.ascendrc nor the default AscendRC\n%s",                "Cannot find ~/.ascendrc nor the default AscendRC\n%s",
# Line 464  int AscDriver(int argc, CONST char *argv Line 468  int AscDriver(int argc, CONST char *argv
468    return 0;    return 0;
469  }  }
470    
471    /*-------------------------------------------------------
472      SETTING UP ENVIRONMENT...
473    */
474    
475  /*  #define GETENV Asc_GetEnv
476   *-----------------------------------------------------------------  #define PUTENV Asc_PutEnv
  *  int AscCheckEnvironVars(interp)  
  *      Tcl_Interp *interp;  
  *  
  *  This function checks the following environment variables and sets them  
  *  to the default value if they are not set.  This function will set  
  *  DIST_ENVIRONVAR to the parent of the directory where the ASCEND binary  
  *  lives if it is not set, e.g., if the ascend binary is  
  *      /foo/bar/ascend4  
  *  DIST_ENVIRONVAR is set to "/foo".  
  *  
  *  We check to see if ASCTK_ENVIRONVAR points to the proper place by  
  *  looking for the ASCEND startup script "AscendRC".  If we find it, set  
  *  the Tcl variable tcl_rcFileName to its location, otherwise, call  
  *  Asc_Panic() to exit.  
  *  
  *  Returns a standard Tcl return code.  
  *  
  *    CPP_MACRO            ENVIRONMENT VAR    DEFAULT VALUE  
  *    =================    ===============    =============  
  *    DIST_ENVIRONVAR      ASCENDDIST         /usr/share/ascend  
  *    ASCTK_ENVIRONVAR     ASCENDTK           $ASCENDDIST/TK  
  *    BITMAP_ENVIRONVAR    ASCENDBITMAPS      $ASCENDDIST/TK/bitmaps  
  *    LIBR_ENVIRONVAR      ASCENDLIBRARY      .:$ASCENDDIST/models  
  *  
  */  
 static int AscCheckEnvironVars(Tcl_Interp *interp)  
 {  
   char *tmpenv;               /* holds values returned by Asc_GetEnv() */  
   Tcl_DString ascenddist;     /* holds the value of DIST_ENVIRONVAR */  
   Tcl_DString buffer2;        /* used to incrementally build environment  
                                * variable values  
                                */  
   Tcl_DString buffer1;        /* holds the environment variable value in the  
                                * native format: result of passing buffer2  
                                * into Tcl_TranslateFileName()  
                                */  
   Tcl_Channel c;              /* used to test if file exists */  
   
   /* initialize */  
   Tcl_DStringInit(&ascenddist);  
   Tcl_DStringInit(&buffer1);  
   Tcl_DStringInit(&buffer2);  
   
   /*  
    *  Get the value of the ASCENDDIST environment variable;  
    *  if not set, set it to the parent of the directory containing  
    *  the ascend binary.  For example, if the ascend binary is  
    *  /foo/bar/bin/ascend4, set ASCENDDIST to /foo/bar  
    *  If Tcl doesn't know where we are---the Tcl command  
    *  `info nameofexecutable' returns ""---then ASCENDDIST is set  
   
     /home/john/ascroot/bin/ascend4  
     /home/john/ascroot/share/ascend/  
   
    *  to "."  
    */  
   if( Asc_ImportPathList(DIST_ENVIRONVAR) == 0 ) {  
     if( (tmpenv =  Asc_GetEnv(DIST_ENVIRONVAR)) == NULL ) {  
       /* shouldn't be NULL since we just imported it successfully */  
       Asc_Panic(2, "CheckEnvironmentVars",  
                 "Asc_GetEnv(%s) returned NULL value.", DIST_ENVIRONVAR);  
     }  
     Tcl_DStringAppend(&ascenddist, tmpenv, -1);  
     ascfree(tmpenv);  
   } else {  
     char cmd[] =  
       "file nativename [file dirname [file dirname [info nameofexecutable]]]";  
     if( Tcl_Eval(interp, cmd) == TCL_OK ) {  
       Tcl_DStringGetResult(interp, &ascenddist);  
       /* Tcl_DStringAppend(&ascenddist, "/share/ascend", -1); */  
       if(Asc_SetPathList(DIST_ENVIRONVAR,Tcl_DStringValue(&ascenddist)) != 0) {  
         Asc_Panic(2, "AscCheckEnvironVars",  
                   "Asc_SetPathList() returned Nonzero: "  
                   "Not enough memory to extend the environment");  
       }  
     }  
   }  
   /*  Make sure the Tcl side can also see this variable */  
   Tcl_SetVar2(interp, "env", DIST_ENVIRONVAR,  
               Tcl_DStringValue(&ascenddist), TCL_GLOBAL_ONLY);  
   
   /*  
    *  If the user's environment does not have ASCENDLIBRARY set, then set  
    *  it to a reasonable default.  
    */  
   if( Asc_ImportPathList(LIBR_ENVIRONVAR) == 0 ) {  
     if( (tmpenv = Asc_GetEnv(LIBR_ENVIRONVAR)) == NULL ) {  
       /* shouldn't be NULL since we just imported it successfully */  
       Asc_Panic(2, "CheckEnvironmentVars",  
                 "Asc_GetEnv(%s) returned NULL value.", LIBR_ENVIRONVAR);  
     }  
     /*  Make sure the Tcl side can also see this variable */  
     Tcl_SetVar2(interp, "env", LIBR_ENVIRONVAR, tmpenv, TCL_GLOBAL_ONLY);  
     ascfree(tmpenv);  
   } else {  
     /*  Add ``.'' to the ASCENDLIBRARY envar */  
     if( Asc_SetPathList(LIBR_ENVIRONVAR, ".") != 0 ) {  
       Asc_Panic(2, "AscCheckEnvironVars",  
                 "Asc_SetPathList() returned Nonzero: "  
                 "Not enough memory to extend the environment");  
     }  
   
     /* Add ``$ASCENDDIST/models'' to the ASCENDLIBRARY envar */  
   
     Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);  
     Tcl_DStringAppend(&buffer2, "/models", -1);  
     if( NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),  
                                        &buffer1))) {  
       if(Asc_AppendPath(LIBR_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {  
         Asc_Panic(2, "AscCheckEnvironVars",  
                   "Asc_AppendPath() returned Nonzero: "  
                   "Not enough memory to extend the environment");  
       }  
       Tcl_DStringFree(&buffer1);  
     }  
     Tcl_DStringFree(&buffer2);  
   
     /*  Get the full value of the environment variable and set  
      *  $env(ASCENDLIBRARY) in the Tcl code  
      */  
     if( (tmpenv = Asc_GetEnv(LIBR_ENVIRONVAR)) == NULL ) {  
       /* shouldn't be NULL since we just set it.  memory error! */  
       Asc_Panic(2, "CheckEnvironmentVars",  
                 "Asc_GetEnv(%s) returned NULL value.", LIBR_ENVIRONVAR);  
     }  
     /*  Make sure the Tcl side can also see this variable */  
     Tcl_SetVar2(interp, "env", LIBR_ENVIRONVAR, tmpenv, TCL_GLOBAL_ONLY);  
     ascfree(tmpenv);  
   }  
   
   /*  
    *  If the user's environment does not have ASCENDTK set, then set it  
    *  by appending 'TK' to ASCENDDIST.  Later in this function, we check  
    *  to make sure it is a valid directory by checking for the existence  
    *  of `AscendRC' in that directory.  
    *  
    *  The location of this directory is not subject to debate. It is  
    *  $prefix/TK. If one wants it anywhere else, for any reason, one  
    *  can provide a wrapper that sets the environment variable to override  
    *  it.  
    */  
   if( Asc_ImportPathList(ASCTK_ENVIRONVAR) == 0 ) {  
     if( (tmpenv = Asc_GetEnv(ASCTK_ENVIRONVAR)) == NULL ) {  
       /* shouldn't be NULL since we just imported it successfully */  
       Asc_Panic(2, "CheckEnvironmentVars",  
                 "Asc_GetEnv(%s) returned NULL value.", ASCTK_ENVIRONVAR);  
     }  
     /* store ASCENDTK in ``buffer1'' so we can check for ASCENDTK/AscendRC  
      * below  
      */  
     Tcl_DStringAppend(&buffer1, tmpenv, -1);  
     ascfree(tmpenv);  
   } else {  
     Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);  
     /* AWW20041208:    Tcl_DStringAppend(&buffer2, "/TK", -1);  
      */  
     Tcl_DStringAppend(&buffer2, "/TK", -1);  
     if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),  
                                       &buffer1))) {  
       if( Asc_SetPathList(ASCTK_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {  
         Asc_Panic(2, "Asc_EnvironmentInit",  
                   "Not enough memory to initialize the environment");  
       }  
     }  
     Tcl_DStringFree(&buffer2);  
   }  
   /*  Make sure the Tcl side can also see this variable */  
   Tcl_SetVar2(interp, "env", ASCTK_ENVIRONVAR,  
               Tcl_DStringValue(&buffer1), TCL_GLOBAL_ONLY);  
   
   /*  
    *  Check to see if ASCENDTK looks reasonable by checking  
    *  for ASCENDTK/AscendRC  We use the Tcl channel  
    *  mechanism to see if file exists.  
    */  
   Tcl_DStringAppend(&buffer1, "/AscendRC", -1 );  
   c = Tcl_OpenFileChannel( NULL, Tcl_DStringValue(&buffer1), "r", 0 );  
   if( c != (Tcl_Channel)NULL ) {  
     /*  
      *  file exists.  close the channel and set tcl_rcfilename to  
      *  this location  
      */  
     Tcl_Close( NULL, c );  
     Tcl_SetVar(interp, "tcl_rcFileName", Tcl_DStringValue(&buffer1),  
                TCL_GLOBAL_ONLY);  
   } else {  
     Asc_Panic(2, "AscCheckEnvironVars",  
               "ERROR: Cannot find the file \"%s\" in the subdirectory \"TK\"\n"  
               "under the directory \"%s\"\n"  
               "Please check the value of the environment variables %s and\n"  
               "and %s and start ASCEND again.\n",  
               "AscendRC", Tcl_DStringValue(&ascenddist), DIST_ENVIRONVAR,  
               ASCTK_ENVIRONVAR);  
   }  
   Tcl_DStringFree(&buffer1);  
   
   /*  
    *  If the user's environment does not have ASCENDBITMAPS set, then set  
    *  it by appending `bitmaps' to ASCENDTK.  
    */  
   if( Asc_ImportPathList(BITMAP_ENVIRONVAR) == 0 ) {  
     if( (tmpenv = Asc_GetEnv(BITMAP_ENVIRONVAR)) == NULL ) {  
       /* shouldn't be NULL since we just imported it successfully */  
       Asc_Panic(2, "CheckEnvironmentVars",  
                 "Asc_GetEnv(%s) returned NULL value.", BITMAP_ENVIRONVAR);  
     }  
     /*  Make sure the Tcl side can also see this variable */  
     Tcl_SetVar2(interp, "env", BITMAP_ENVIRONVAR, tmpenv, TCL_GLOBAL_ONLY);  
     ascfree(tmpenv);  
   } else {  
     Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);  
     Tcl_DStringAppend(&buffer2, "/TK/bitmaps", -1);  
     if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),  
                                       &buffer1))) {  
       if(Asc_SetPathList(BITMAP_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {  
         Asc_Panic(2, "Asc_EnvironmentInit",  
                   "Not enough memory to initialize the environment");  
       }  
     }  
     Tcl_DStringFree(&buffer2);  
     /*  Make sure the Tcl side can also see this variable */  
     Tcl_SetVar2(interp, "env", BITMAP_ENVIRONVAR,  
                 Tcl_DStringValue(&buffer1), TCL_GLOBAL_ONLY);  
     Tcl_DStringFree(&buffer1);  
   }  
477    
478    /*  Cleanup  */  /**
479    Tcl_DStringFree(&ascenddist);      This is a quick macro to output a FilePath to an environment
480        variable.
481    */
482    #define OSPATH_PUTENV(VAR,FP) \
483        snprintf(envcmd,MAX_ENV_VAR_LENGTH,"%s=",VAR); \
484        ospath_strcat(FP,envcmd,MAX_ENV_VAR_LENGTH); \
485        PUTENV(envcmd)
486    
487    return TCL_OK;  /**
488        This is a quick macro to send data to Tcl using Tcl_SetVar.
489        It uses an intermediate buffer which is assumed to be
490        empty already.
491    
492        usage: ASC_SEND_TO_TCL(tclvarname,"some string value");
493    */
494    #define ASC_SEND_TO_TCL(VAR,VAL) \
495        Tcl_DStringAppend(&buffer,VAL,-1); \
496        Tcl_SetVar(interp,#VAR,Tcl_DStringValue(&buffer),TCL_GLOBAL_ONLY); \
497        Tcl_DStringFree(&buffer);
498    
499    /**
500        This is a quick macro to send data to Tcl using Tcl_SetVar2.
501        It uses an intermediate buffer which is assumed to be
502        empty already.
503    
504        usage: ASC_SEND_TO_TCL2(arrayname,"keyname","some string value");
505    */
506    #define ASC_SEND_TO_TCL2(ARR,KEY,VAL) \
507        Tcl_DStringAppend(&buffer,VAL,-1); \
508        Tcl_SetVar2(interp,#ARR,KEY,Tcl_DStringValue(&buffer),TCL_GLOBAL_ONLY); \
509        Tcl_DStringFree(&buffer);
510    
511    /**
512        Ensure that all required environment variables are present
513        and set values for them if they are not present. The names
514        for the environment variables are specified in
515        <utilities/config.h>. The following comments assume that you
516        use the usual names for each of these:
517    
518        ASCENDDIST defaults to @ASC_DATADIR@ (also in config.h)
519        ASCENDTK defaults to $ASCENDDIST/@ASC_TK_SUBDIR_NAME@ (latter is from config.h)
520        ASCENDBITMAPS defaults $ASCENDTK/bitmaps
521        ASCENDLIBRARY defaults to $ASCENDDIST/models
522    
523        Also check for the existence of the file AscendRC in $ASCENDTK
524        and if found, export the location of that file to the Tcl
525        variable tcl_rcFileName.
526    */
527    static int AscCheckEnvironVars(Tcl_Interp *interp,const char *progname){
528        char *distdir, *tkdir, *bitmapsdir, *librarydir;
529        struct FilePath *fp, *fp1, *distfp, *tkfp, *bitmapsfp, *libraryfp;
530        char envcmd[MAX_ENV_VAR_LENGTH];
531        char s1[PATH_MAX];
532    
533        Tcl_DString buffer;
534    
535        Tcl_DStringInit(&buffer);
536    
537        /*
538        Asc_ImportPathList(ASC_ENV_DIST);
539        Asc_ImportPathList(ASC_ENV_TK);
540        Asc_ImportPathList(ASC_ENV_BITMAPS);
541        Asc_ImportPathList(ASC_ENV_LIBRARY);
542        */
543    
544        CONSOLE_DEBUG("IMPORTING VARS");
545    
546        distdir = getenv(ASC_ENV_DIST);
547        tkdir = getenv(ASC_ENV_TK);
548        bitmapsdir = getenv(ASC_ENV_BITMAPS);
549        librarydir = getenv(ASC_ENV_LIBRARY);
550    
551        int guessedtk=0;
552    
553        /* Create an ASCENDDIST value if it's missing */
554    
555        if(distdir == NULL){
556            CONSOLE_DEBUG("NO " ASC_ENV_DIST " VAR DEFINED");
557    
558    # ifdef ASC_RELATIVE_PATHS
559    
560            // read the executable's name/relative path.
561            fp = ospath_new(progname);
562    
563            ospath_strcpy(fp,s1,PATH_MAX);
564            CONSOLE_DEBUG("PROGNAME = %s",s1);
565    
566            // get the directory name from the exe path
567            CONSOLE_DEBUG("Calculating dir...");
568            fp1 = ospath_getdir(fp);
569            CONSOLE_DEBUG("Done calculating dir...");
570            ospath_free(fp);
571    
572            ospath_strcpy(fp1,s1,PATH_MAX);
573            CONSOLE_DEBUG("DIR = %s",s1);
574    
575            // append the contents of ASC_DISTDIR to this path
576            fp = ospath_new_noclean(ASC_DISTDIR);
577            distfp = ospath_concat(fp1,fp);
578            ospath_cleanup(distfp);
579    
580            ospath_strcpy(fp1,s1,PATH_MAX);
581            CONSOLE_DEBUG("DIST = %s",s1);
582    
583    # else
584            distfp = ospath_new(ASC_DATADIR);
585            fp = ospath_new("ascend");
586    
587            ospath_append(distfp,fp);
588            ospath_free(fp);
589    # endif
590            distdir = ospath_str(distfp);
591            ERROR_REPORTER_NOLINE(ASC_USER_NOTE,"GUESSING %s = %s\n",ASC_ENV_DIST,distdir);
592            OSPATH_PUTENV(ASC_ENV_DIST,distfp);
593        }
594    
595        if(tkdir == NULL){
596            CONSOLE_DEBUG("NO " ASC_ENV_TK " VAR DEFINED");
597    
598            guessedtk=1;
599            /* Create a path $ASCENDDIST/tcltk */
600            strcpy(envcmd,"$ASCENDDIST/");
601            strcat(envcmd,ASC_TK_SUBDIR_NAME);
602            CONSOLE_DEBUG("TK RAW = %s",envcmd);
603            tkfp = ospath_new_expand_env(envcmd, &GETENV);
604            tkdir = ospath_str(tkfp);
605    
606            ospath_strcpy(tkfp,envcmd,MAX_ENV_VAR_LENGTH);
607            CONSOLE_DEBUG("TK = %s",envcmd);
608    
609            OSPATH_PUTENV(ASC_ENV_TK,tkfp);
610        }
611    
612        if(bitmapsdir == NULL){
613            CONSOLE_DEBUG("NO  " ASC_ENV_BITMAPS " VAR DEFINED");
614            /* Create a path $ASCENDTK/bitmaps */
615            bitmapsfp = ospath_new_expand_env("$ASCENDTK/bitmaps", &GETENV);
616            OSPATH_PUTENV(ASC_ENV_BITMAPS,bitmapsfp);
617        }
618    
619        /**
620            @TODO FIXME Note, at present this default library path only caters for a
621            ** SINGLE PATH COMPONENT **
622    
623            @TODO Also, what about ASCEND_DEFAULTLIBRARY ?
624        */
625        if(librarydir == NULL){
626            CONSOLE_DEBUG("NO  " ASC_ENV_LIBRARY " VAR DEFINED");
627            libraryfp = ospath_new_expand_env("$ASCENDDIST/models", &GETENV);
628            ospath_free(fp);
629            OSPATH_PUTENV(ASC_ENV_LIBRARY,libraryfp);
630        }
631    
632    
633        CONSOLE_DEBUG("CHECKING FOR AscendRC FILE");
634    
635        fp1 = ospath_new("AscendRC");
636        fp = ospath_concat(tkfp,fp1);
637        ospath_free(fp1);
638        FILE *f = ospath_fopen(fp,"r");
639        if(f==NULL){
640            if(guessedtk){
641                Asc_Panic(2, "AscCheckEnvironVars",
642                    "Cannot located AscendRC file in expected (guessed) location:\n%s\n"
643                    "Please set the %s environment variable to the correct location (typically\n"
644                    "it would be c:\\Program Files\\ASCEND\\TK or /usr/share/ascend/tcltk/TK. You\n"
645                    "should do this, then start ASCEND again."
646                        ,tkdir,ASC_ENV_TK
647                );
648            }else{
649                Asc_Panic(2, "AscCheckEnvironVars",
650                    "Cannot located AscendRC file in the specified location:\n%s\n"
651                    "Please check your value for the %s environment variable.\n"
652                        ,tkdir,ASC_ENV_TK
653                );
654            }
655            /* can't get here, hopefully */
656        }
657        fclose(f);
658        /* reuse 'envcmd' to get the string file location for AscendRC */
659        ospath_strcpy(fp,envcmd,MAX_ENV_VAR_LENGTH);
660        ospath_free(fp);
661    
662        /* export the value to Tcl/Tk */
663        ASC_SEND_TO_TCL(tcl_rcFileName, envcmd);
664    
665        /* send all the environment variables to Tcl/Tk as well */
666        ASC_SEND_TO_TCL2(env,ASC_ENV_DIST,distdir);
667        ASC_SEND_TO_TCL2(env,ASC_ENV_LIBRARY,librarydir);
668        ASC_SEND_TO_TCL2(env,ASC_ENV_BITMAPS,bitmapsdir);
669        ASC_SEND_TO_TCL2(env,ASC_ENV_TK,tkdir);
670  }  }
671    
672    
673    
674  /*  /*
675   *  int AscSetStartupFile(interp)   *  int AscSetStartupFile(interp)
676   *      Tcl_Interp *interp;   *      Tcl_Interp *interp;

Legend:
Removed from v.585  
changed lines
  Added in v.586

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22