What difference(s) am I missing? (Tcl_Eval) (Tcl_EvalFile) 
Author Message
 What difference(s) am I missing? (Tcl_Eval) (Tcl_EvalFile)

Hi I'm attempting to use TCL through a C/C++ interface and have ran into a
a problem that I can't seem to understand.

This is the script  that I saved to a file

set inexp {^:([^ ]*) ([^ ]*)(( ([^:][^ ]*))*)( :(.*))?$}
set lin ":irc.poker.net 001 Maniac :Welcome to the Internet Relay Network Maniac"
regexp $inexp $lin match field1 field2 field3 field4 field5 field6 field7

Using Tcl_EvalFile I can get all the parameters/variables correctly

but when using Tcl_Eval with

lin=":irc.poker.net 001 Maniac :Welcome to the Internet Relay Network Maniac";
pattern="{^:([^ ]*) ([^ ]*)(( ([^:][^ ]*))*)( :(.*))?$}";  
Tcl_SetVar(interp,"inexp",pattern,TCL_GLOBAL_ONLY);      
Tcl_SetVar(interp,"lin", line,TCL_GLOBAL_ONLY);    
cmd="regexp $inexp $lin match field1 field2 field3 field4 field5 field6 field7";

//      result=Tcl_Eval(interp,cmd);   // This doesn't work all fields are 0

        result=Tcl_EvalFile(interp,"TestTcl.tcl"); // This works!
        if(result==0) {
        prefix=Tcl_GetVar(interp,"field1",TCL_GLOBAL_ONLY);
        cm=Tcl_GetVar(interp,"field2",TCL_GLOBAL_ONLY);
        b=Tcl_GetVar(interp,"field3",TCL_GLOBAL_ONLY);
        c=Tcl_GetVar(interp,"field4",TCL_GLOBAL_ONLY);
        d=Tcl_GetVar(interp,"field5",TCL_GLOBAL_ONLY);
        e=Tcl_GetVar(interp,"field6",TCL_GLOBAL_ONLY);
        param=Tcl_GetVar(interp,"field7",TCL_GLOBAL_ONLY);
        }
All fields (1-7) end up being Null using Tcl_Eval(interp,cmd)

What am I missing?  I don't have much hair left anymore!




Fri, 03 May 2002 03:00:00 GMT  
 What difference(s) am I missing? (Tcl_Eval) (Tcl_EvalFile)

Quote:

> lin=":irc.poker.net 001 Maniac :Welcome to the Internet Relay Network Maniac";
> pattern="{^:([^ ]*) ([^ ]*)(( ([^:][^ ]*))*)( :(.*))?$}";
> Tcl_SetVar(interp,"inexp",pattern,TCL_GLOBAL_ONLY);
> Tcl_SetVar(interp,"lin", line,TCL_GLOBAL_ONLY);
> cmd="regexp $inexp $lin match field1 field2 field3 field4 field5 field6 field7";

> //      result=Tcl_Eval(interp,cmd);   // This doesn't work all fields are 0

My first guess would be to use Tcl_EvalEx and add the TCL_GLOBAL_ONLY
flag to the evaluation (IIRC).  Worth a try...

--
   Jeffrey Hobbs                          The Tcl Guy
   jeffrey.hobbs at scriptics.com         Scriptics Corp.



Fri, 03 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Different result with Tcl_Eval() or Tcl_EvalFile()

2. Tcl_Eval and Tcl_EvalFile

3. what am i missing? :(

4. I am missing this group!!!

5. Am i missing something with CW5Pe?

6. Am I missing something here?

7. Am I missing some patches on C4 OLE ?

8. Am I missing something here?

9. What am I missing????

10. What runtime file am I missing?

11. Displaying and Image in a simple report - What am I missing

12. Browse Column Counts - What am I missing?

 

 
Powered by phpBB® Forum Software