For Programmers: Free Programming Magazines  


Home > Archive > Tcl > July 2005 > sintax error?









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]

 

Author sintax error?
sunos.x86@gmail.com

2005-07-25, 5:35 pm

Hello all..
I'm having a strange problem, that i guess you will know the answer
quickly...
I'm writing a expect script, and i will use some procedures that David
L. Fisher has wrote (send_expect, send_expect_init, send_only and
send_expect_report). When i try to "source" that procedures, three of
them works fine, but the send_expect procedure, gives me errors...
The question is:
"What can make a procedure be executed when we are sourcing it?"
I have put the four procedures in one file, and the last line is "puts
test...", and when i try to execute the program, i did receive the same
error... about a global variable that does not exists. I think that is
a logical error, that should appears just in the execution...
Sorry by the english...
Thanks.

Kevin Kenny

2005-07-26, 9:05 am

sunos.x86@gmail.com wrote:
The question is:
> "What can make a procedure be executed when we are sourcing it?"


The answer is:
There is an extra } somewhere, so that the procedure ends
before you think it does (or else the file contains top-level
code as well as procedures, and that's what's failing).

Is $::errorInfo informative? Usually code that's intended to
be in a proc crashes pretty quickly at top level, so the
unbalanced brace is generally pretty close to the line
where the error is reported.
--
73 de ke9tv/2, Kevin
sunos.x86@gmail.com

2005-07-26, 9:05 am


Thanks very much! I'm looking for it, but without luck... The
procedures are in:

http://www.cotse.com/dlf/man/expect/bulletproof1.htm

Thanks again!

Kevin Kenny wrote:
> sunos.x86@gmail.com wrote:
> The question is:
>
> The answer is:
> There is an extra } somewhere, so that the procedure ends
> before you think it does (or else the file contains top-level
> code as well as procedures, and that's what's failing).
>
> Is $::errorInfo informative? Usually code that's intended to
> be in a proc crashes pretty quickly at top level, so the
> unbalanced brace is generally pretty close to the line
> where the error is reported.
> --
> 73 de ke9tv/2, Kevin


Donal K. Fellows

2005-07-26, 9:05 am

sunos.x86@gmail.com wrote:
> Thanks very much! I'm looking for it, but without luck... The
> procedures are in:
>
> http://www.cotse.com/dlf/man/expect/bulletproof1.htm


Looking at the send_expect code linked off that page (that's where the
problem is, yes?) I notice that you've got an extra } towards the end of
the MODE 3 branch, probably immediately after you print the message
"Mode 3 failed". Deleting that line is probably what you want (it
produces code that looks like what you want to achieve).

As advice for the future, the editor Emacs has a key sequence for going
forwards (Ctrl-Alt-f) or backwards (Ctrl-Alt-b) over a bracketed chunk
of code, which makes finding this sort of problem *much* easier. I
believe that there's an equivalent for users of vi (and its derivatives,
of course).

Donal.
Bryan Oakley

2005-07-26, 9:05 am

sunos.x86@gmail.com wrote:
> Thanks very much! I'm looking for it, but without luck... The
> procedures are in:
>
> http://www.cotse.com/dlf/man/expect/bulletproof1.htm


The error appears to be in send_expect.tcl. In my editor (emacs) it is
reporting that the curly brace on line 397 belongs to the preceeding
proc definition (send_expect), but the comments in the code and the
indentation implies you think it belongs to an if statement. Thus, the
proc is being closed early and the remaining body of the proc is being
executed since it is outside the proc definition.

In case you've added or removed lines since your last post, This is the
abridged version of how my editor sees the code. Notice how the comment
"# if failmax not reached" appears to apply to the wrong curly brace.

proc send_expect { id command { flags "" } } {
...
if { $sendGlobals(useMode) <= 3 } {
...
}
# if failmax not reached
}
# if use this mode

##------------------------------------------------------------------------
## MODE 4 - index ...





sunos.x86@gmail.com

2005-07-26, 5:03 pm

So, thanks!!
I will learn about that "vi" sequence, because in the "highlight"
configuration, that error is not showed. Looking for that type of error
is anoying, and a nice editor is the answer (or better skills :). That
four procedures are not mines. i'm going to use them in another app
that i'm writing... I have removed the "}", but the error continues...
but now you make me have sure that is a sintaxe error, so i can look.
:)
Did you remove the "}" ? Can you source that procedure in expect promp
without problems?
Thanks again.

Darren New

2005-07-26, 5:03 pm

Donal K. Fellows wrote:

> believe that there's an equivalent for users of vi (and its derivatives,


The % sign. Or
:set automatch
which will supposedly flash the cursor to the matching element when you
type a balanced characte ([{()]})

--
Darren New / San Diego, CA, USA (PST)
Indications you're in trouble, #37:
Your accountant charges you interest for
not paying bills for which you already have
the canceled checks back.
Glenn Jackman

2005-07-26, 5:03 pm

NNTP-Posting-Host: smeagol.ncf.ca
X-Trace: theodyn.ncf.ca 1122396857 13362 134.117.136.48 (26 Jul 2005 16:54:17 GMT)
X-Complaints-To: complaints@ncf.ca
NNTP-Posting-Date: 26 Jul 2005 16:54:17 GMT
User-Agent: slrn/0.9.7.4 (SunOS)
Xref: number1.nntp.dca.giganews.com comp.lang.tcl:249852

At 2005-07-26 12:43PM, sunos.x86@gmail.com <sunos.x86@gmail.com> wrote:
> So, thanks!!
> I will learn about that "vi" sequence,

[...]

In vi, you want %
:help %

In vim, these are handy: [{ and ]}

--
Glenn Jackman
NCF Symin
glennj@ncf.ca
sunos.x86@gmail.com

2005-07-26, 5:03 pm

Hello again...
I guess it's solved. I did remove the "}" towards the Mode 3 end, and
did put one "{" in the for statement:
for {set sendGlobals(index) 0} \
---------> {(sendGlobals(index) < $sendLength} \
{incr sendGlobals(index)} {

Now, if there is a error, is logical...
Thanks very much!
ps.: I did try notify the author about that errors, but he did not
answer... :(

Bryan Oakley

2005-07-26, 5:03 pm

sunos.x86@gmail.com wrote:
> Hello again...
> I guess it's solved. I did remove the "}" towards the Mode 3 end, and
> did put one "{" in the for statement:
> for {set sendGlobals(index) 0} \
> ---------> {(sendGlobals(index) < $sendLength} \
> {incr sendGlobals(index)} {
>


Is that the real code? It looks like you have an extra "(" in there:
'{(sendGlobals..'. Perhaps the problem is, instead of adding a "{" you
should have changed the "(" to a "{".
sunos.x86@gmail.com

2005-07-27, 5:06 pm

yeap, and put a "$", because sendGlobas(index) is a variable... :)
Now it's "sourcing", and i'm having "logical" errors... but it is
another problem.
Thanks.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com