Home > Archive > Tcl > September 2005 > init.tcl problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi folks,
I have a little problem:
I embed Tcl/Tk into an application, but there is a nerve-racking
init.tcl error, here is the important code:
#####
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
...
/*
* tcl_library
*/
Tcl_Obj* restcl;
Tcl_Obj* libtcl;
if (Tcl_Eval(interp, "file join [file normalize $::env(APP_HOME)]
tcl lib tcl8.4") != TCL_OK) {
return TCL_ERROR;
}
libtcl = Tcl_GetObjResult(interp);
restcl = Tcl_SetVar2Ex(interp, "tcl_library", NULL, libtcl,
TCL_GLOBAL_ONLY);
/*
* Init Tcl/Tk
*/
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Init [incr Tcl/Tk]
*/
if (Itcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Itk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* load framework
*/
if (Tcl_Eval(interp, "source [file join [file normalize
$::env(APP_HOME)] scripts init init.tcl]") != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_Eval(interp, "::CreateTopLevel") != TCL_OK) {
return TCL_ERROR;
}
####
Everything works fine, but the last Tcl_Eval calls a new proc which is
defined in the init.tcl I source before.
and then the error is the misssing useable init.tcl.
When I put the lib/tcl8.4 into an other directory it works fine, but I
want to put it my way!
I though setting the tcl_library is enough, and it seems to be enough,
but this last Tcl_Eval fails because of that reason.
Some advice?
Regards,
Sascha
| |
| Don Porter 2005-09-24, 9:56 pm |
| eiji wrote:
> restcl = Tcl_SetVar2Ex(interp, "tcl_library", NULL, libtcl,
> TCL_GLOBAL_ONLY);
....
> if (Tcl_Init(interp) == TCL_ERROR) {
> return TCL_ERROR; /* HERE */
> }
....
> if (Tcl_Eval(interp, "source [file join [file normalize
> $::env(APP_HOME)] scripts init init.tcl]") != TCL_OK) {
> return TCL_ERROR;
> }
> if (Tcl_Eval(interp, "::CreateTopLevel") != TCL_OK) {
> return TCL_ERROR; /* NOT HERE */
> }
> ####
> Everything works fine, but the last Tcl_Eval calls a new proc which is
> defined in the init.tcl I source before.
> and then the error is the misssing useable init.tcl.
First thing I would recommend is to give your file to be [source]d
a different name from the file evaluated by Tcl_Init() so there will
be no chance of confusion reading the error messages.
I think your last paragraph above is misreading the error message.
I suspect the message is really coming from /* HERE */ and not
from /* NOT HERE */. Renaming your file should help clarify that.
Post again when you're able to verify that suspicion, or have evidence
that the suspicion is false and something else is happening you can
describe in more detail.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|_______________________________________
_______________________________|
| |
|
| I will give you more information and the exakt code:
######################
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
/*
* argc, argv0 and argv
*/
char *args;
Tcl_DString argString;
char buf[TCL_INTEGER_SPACE];
args = Tcl_Merge(argc, (CONST char **)argv);
Tcl_ExternalToUtfDString(NULL, args, -1, &argString);
Tcl_SetVar(interp, "argv", Tcl_DStringValue(&argString),
TCL_GLOBAL_ONLY);
Tcl_DStringFree(&argString);
ckfree(args);
sprintf(buf, "%d", argc);
Tcl_ExternalToUtfDString(NULL, argv[0], -1, &argString);
Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&argString),
TCL_GLOBAL_ONLY);
/*
* tcl_library
*/
Tcl_Obj* restcl;
Tcl_Obj* libtcl;
if (Tcl_Eval(interp, "file join [file normalize $::env(FEMESH_HOME)]
tcl lib tcl8.4") != TCL_OK) {
return TCL_ERROR;
}
libtcl = Tcl_GetObjResult(interp);
restcl = Tcl_SetVar2Ex(interp, "tcl_library", NULL, libtcl,
TCL_GLOBAL_ONLY);
/*
* Init Tcl/Tk
*/
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Init [incr Tcl/Tk]
*/
if (Itcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Itk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* load framework
*/
if (Tcl_Eval(interp, "source [file join [file normalize
$::env(FEMESH_HOME)] scripts init FD_init.tcl]") != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_Eval(interp, "::FD_Framework_base::CreateTopLevel") != TCL_OK)
{
return TCL_ERROR;
}
#################
FEMesh/tcl/lib/tcl8.4
Before the last Tcl_Eval the result is empty, and the last Tcl_Eval
fills the result with "cant find init.tcl in the following directo...".
I use VC++, so this is easy to find out.
Any suggestions?
| |
| Don Porter 2005-09-26, 3:57 am |
| eiji wrote:
> I will give you more information and the exakt code:
<snip>
> if (Tcl_Init(interp) == TCL_ERROR) {
> return TCL_ERROR; /* HERE */
> }
> if (Tcl_Eval(interp, "::FD_Framework_base::CreateTopLevel") != TCL_OK)
> {
> return TCL_ERROR; /* NOT HERE */
> }
> Before the last Tcl_Eval the result is empty, and the last Tcl_Eval
> fills the result with "cant find init.tcl in the following directo...".
I don't believe you.
I recognize the error message. It comes from a failed Tcl_Init call.
That is, as I told you the first time it comes from /* HERE */
and not from /* NOT HERE */.
> Any suggestions?
Do as I asked the first time. That's my suggestion.
Or don't.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|_______________________________________
_______________________________|
|
|
|
|
|