MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Odd Formatting Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35069] Re: [mg35033] Odd Formatting Problem
  • From: BobHanlon at aol.com
  • Date: Thu, 20 Jun 2002 23:56:31 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 6/20/02 5:01:34 AM, siegman at stanford.edu writes:

>I have several expressions inside a Module that I've typed in the 
>general form
>
>labelTwoText = "OUTPUT:\n"
>    <> "\nK2 = " <> ToString[K2]
>    <> "\nG2 = " <> ToString[G2 // N]
>    <> "\ntheta2 = " <> ToString[theta2/degrees // N]
>    <> "\nthetaC = " <> ToString[thetaC/degrees // N]
>    <> "\nk2 = " <> ToString[k2 // N];
>
>where I've inserted the CRs at the end of each line deliberately 
>for readability.
>
>(The expression is intended to collect text to be inserted into 
>graphics using Text[] and Show[].  The real-life examples are 
>three or four times as long.)
>
>Sometimes these work fine; sometimes for unknown reasons they get 
>screwed up -- especially if I cut and paste the expression within 
>the Module to move it or duplicate it.  When this happens:
>
>1) I get the error message
>
>      Syntax::sntxb: Expression cannot begin with "<>
>      K2 = <>ToString[K2//N]".
>
>2)  Some of the lines become indented by slightly different 
>amounts before the "<>"'s.
>
>3)  The program is now totally unstoppable:  Interrupt Evaluation 
>or Abort Evaluation no longer stop the program, which will 
>apparently Run forever.  Only way out is to Quit the front end, 
>then Quit the kernal, and restart the app.
>
>3)  Once you've reopened the notebook, laboriously doing a delete 
>and then CR at the beginning of each line is the only way to 
>restore functionality,
>
>Obviously I'll stop typing them this way and let Mathematica make the line
>
>breaks -- but this does seem like some kind of bug?
>
>(Mathematica 4.1.0.0 on a Mac G3 PB running OS 8.6)

First, do not break a line at a point that could represent a complete 
expression.  Specifically, always leave the StringJoin ( <> ) at the end 
of a line not at the start of a line.  That way Mathematica will know 
unambiguously that more follows in the current expression.

labelTwoText = "OUTPUT:\n" <>
 
    "\nK2 = " <> ToString[K2] <>
     "\nG2 = " <> ToString[G2 // N] <>
     
    "\ntheta2 = " <> ToString[theta2/degrees // N] <>
    "\nthetaC = " <> 
    ToString[thetaC/degrees // N] <>
    "\nk2 = " <> ToString[k2 // N]

Alternatively, use a form like SequenceForm which will clearly leave 
the expression open until the last right bracket ( ] ).

SequenceForm[
  "OUTPUT:\n\nK2 = ", ToString[K2],
  "\nG2 = ", ToString[G2 // N],
  "\ntheta2 = ", ToString[theta2/degrees // N],
  "\nthetaC = ", ToString[thetaC/degrees // N],
  "\nk2 = ", ToString[k2 // N]]


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: RE: Re: Friendly Challenge 2: sort by column
  • Next by Date: RE: Odd Formatting Problem
  • Previous by thread: Odd Formatting Problem
  • Next by thread: RE: Odd Formatting Problem