Re: Tentative conclusion: Mathematica cannot output plain text
- To: mathgroup at smc.vnet.net
- Subject: [mg39828] Re: Tentative conclusion: Mathematica cannot output plain text
- From: Rolf Mertig <rolf at mertig.com>
- Date: Sat, 8 Mar 2003 02:48:31 -0500 (EST)
- Organization: Mertig Consulting
- Reply-to: rolf at mertig.com
- Sender: owner-wri-mathgroup at wolfram.com
<Because of the lack of response to my previous 2 <queries, I take it that it is impossible to get <Mathematica's front end to produce notebook output in <plain text. Is this a correct statement? Not quite. With a little help of the Kernel it is possible, even for the notebook Mathematica front end: PrintNodeCoordinates[xyzcoor_] := Module[{numnod = Length[xyzcoor], t, n, c, tt, mx, nt}, t = Table[" ", {numnod + 1}, {4}]; For[n = 1, n <= numnod, n++, c = xyzcoor[[n]]; If[Length[c] <= 2, AppendTo[c, 0]]; If[Length[c] == 1, AppendTo[c, 0]]; t[[n + 1, 1]] = ToString[n]; t[[n + 1, 2]] = c[[1]]; t[[n + 1, 3]] = c[[2]]; t[[n + 1, 4]] = c[[3]]];; t[[1]] = {"node", "x", "y", "z"}; tt = Map[ToString, t, {2}]; mx = Max[Map[StringLength, tt, {2}]]; nt = Map[(StringJoin @@ PadLeft[{#}, mx - StringLength[#], " "]) &, tt, {2}]; Print @ StringDrop[ExportString[nt, "Table"], -1] ]; PrintNodeCoordinates[{{2, 3, 2000}, {5, a + b, 168.09}, {x_dir, y_dir, z_dir}}] This gives (unformatted) Cell[BoxData["\<\" node .... \"\>"], "Print"], which is quite plain text. BTW: does anybody know if there exists a ConversionOptions setting for ExportString to not get the "\n" at the end of ExportString? Right now ExportString[{"a"},"Table"] returns "a\n" . This may be fine in some situations, but not for the case above (this is why I added the StringDrop[ ,-1] There should be more ConversionOptions documentation really. E.g., does Export[ { { ... }, ... {} }, "Table" ]also take ConversionOptions similar to TableForm? I don't know ... (anybody?, PJ?) Maybe one could also get this type of formatting with J/Link and the apropriate Java (JTable?) classes, but I found this too complicated. Rolf Mertig Mertig Consulting http://www.mertig.com http://www.mathxls.com