Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange Syntax problem

773 views
Skip to first unread message

KvS

unread,
Feb 7, 2006, 3:56:28 AM2/7/06
to
Hi all,

I'm new here, have some experience with Mathematica, currently running
version 5.1 under Windows XP Prof. I've written a reasonably large
piece of code (about 50 lines) in a single cell. It contains some
comments troughout and a few loops. If I run this piece of code the way
it was saved it all works fine.

But if I now simply try to add a line somewhere in the code, a simple
Print-statement e.g., I suddenly get the error

Syntax::bktmcp : Expression "(Log[s])^m" has no closing ")".

This expression (Log[s])^m is in the last part of the code and the line
I added is close to the beginning so they're relatively far apart. It
doesn't make any sense because even if I comment out the added line by
adding "(*" and "*)" around them (so that I have effectively only added
comment to the original code) the same error keeps coming up.

If I then reopen the original saved file and add a Print-statement
close to the end of the code it does run...

How could this have happened, is anybode familiar with this behaviour?
I wouldn't mind rewriting the code if the notebook somehow became
corrupt only if I knew for sure it wouldn't happen again...

Thanks in advance!

- Kees

David Park

unread,
Feb 8, 2006, 4:10:12 AM2/8/06
to
Kees,

If Mathematica says you have a missing bracket you almost certainly do.
However, it might not always be the type of bracket they indicate.

You can sometimes trace this down by placing the cursor in an expression and
then using Ctrl-'.' Keep pressing '.' and Mathematica will select ever
larger subexpressions. This will usually show when an expression is not
being terminated properly because of a missing bracket.

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

KvS

unread,
Feb 9, 2006, 3:38:41 AM2/9/06
to
Hi David,

thanks for the hint with Ctrl & ., that's a good one to keep in mind.
Unfortunately it didn't solve my problem so far, there's no missing
bracket to be found. Plus, what I find so weird, is that when there'd
be a missing bracket it shouldn't matter where I put the simple
(one-line) Print-statement because that doesn't change the config. of
brackets right?

While searching a bit more through this group yesterday I found
somebody with a similar problem and that person (just as I have) had
used different font colors for the comments. Setting a certain option
in the Inspector did the trick for him, not for me unfortunately. So
apparently it's not a completely new problem. If anybody has something
more to add, I'd be pleased :).

- Kees

Pratik Desai

unread,
Feb 10, 2006, 3:32:35 AM2/10/06
to
KvS wrote:

>Hi David,
>
>thanks for the hint with Ctrl & ., that's a good one to keep in mind.
>Unfortunately it didn't solve my problem so far, there's no missing
>bracket to be found.
>

You can also use Ctrl+Shift+B to find the missing bracket. Maybe you
should send this to Wolfram Support, they might have figured out a work
around

Pratik

KvS

unread,
Feb 11, 2006, 3:46:22 AM2/11/06
to
Ok, thanks. There was also another reply which for some reason unknown
to me didn't appear in this thread so I'll just quote it here:

------

Hi Kees,
I have also seen similar problems from time to time, often in cases
where it
is difficult to isolate the problem in a nice way. Typically such
problems
could be caused by an invisible StyleBox, a peculiar invisible
character, an
invisible embedded cell or errors in the parsing of the mathematical
structure. If you look at the internal BoxData structure of a
StandardForm
Input cell (use the menu command "Show expression"), it is easy to
understand that pasting of expressions into such a structure sometimes
might
cause some errors. You might try to convert the expression into
InputForm
(by Shift+Ctrl+I in Windows) and back again (by Shift+Ctrl+N). Then the
expression is first turned into a string or TextData object, and then
turned
back into a BoxData structure. This might help or might mess things up
worse, which is hard to predict. You could also try to convert it to
InputForm, copy it and paste it into some external editor, and check
what
happens. Maybe you might correct something and then you might paste
back
into a Mathematica Input cell.
There is also a chance that my buttons "StyleRemove" or
"CopyAsInputFormK"
might help. They use other mechanisms than those built into "Convert To
InputForm" and "Convert To StandardForm". The buttons are located on my
SetFaceAndFont palette, see
http://web.telia.com/~u31815170/Mathematica/ .

Best regards

Ingolf Dahl
Sweden

-----

Thanks for the extensive response Ingolf, I'll have a go at your hints
tonight.

- Kees

0 new messages