passing a prolog string to tcl and unbalanced braces 
Author Message
 passing a prolog string to tcl and unbalanced braces

Hi,

I want to pass a string from prolog to tcl and I use the command:

call_log(Term) :-
    call_to_chars((user:Term),String,Res),
    ( nonvar(String),String\==[] ->
      tcl_eval(['log_write',br(chars(String))])
    ; true
    ),
    Res.

log::write is a tcl procedure that just inserts the argument to a text
widget:

proc log_write { msg } {
    text .t
    .t insert 0 "$msg\n\n"
    pack .t

Quote:
}

This work fine for all cases except the one with an unbalanced curly brace
in the String (the error message 'unbalanced braces "{" at pos 10' for
instance).
I know that I could choose to enclose the String into quotes, but this will
fail for all strings with a quote, dollar or [ brace.

Of cource the error that I get is something like:

missing close-braceException during Prolog execution:
call_log(exec_macro('o806'))
tcl_error(tcl_eval/3,[109,105,115,115,105,110,103,32,99,108,111,115,101,45,9
8,114,97,99,101])
missing close-brace
    while executing
"log::write"
    invoked from within
"::prolog {call_log(exec_macro('o806'))}"
    ("uplevel" body line 1)

any ideas on how to make it work.

thanks,
Alexios



Tue, 11 May 2004 01:33:14 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. unbalanced braces when passing a prolog string to tcl

2. Unbalanced braces in variable names

3. BUG: [incr tcl] and commented unbalanced curly brackets

4. Brackets in brackets, braces in braces

5. Passing string from Tcl to C

6. Brackets in brackets, braces in braces

7. Braces within a string

8. Help using [ as a string character not a Command Brace

9. syntax parser in tcl8.1 - wrong usage of braces in comments or strings

10. Matching strings that contain braces

11. how to access prolog from tcl?(not using tcl/tk interface from prolog)

12. TCL evaluation curly brace that is part of my variable value

 

 
Powered by phpBB® Forum Software