Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

.NET/Link and two-dimensional strings

  • To: mathgroup at
  • Subject: [mg66989] .NET/Link and two-dimensional strings
  • From: "colin" <colin.ladyka at>
  • Date: Tue, 6 Jun 2006 06:27:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

The following two lines export a jpeg file containing RED text when
executed in a notebook:

myText="\!\(\*StyleBox[\"my text\",\nFontColor->RGBColor[1, 0, 0]]\)";

If I put these same lines in a file called myText.txt, and then read
this file with the following .NET code, the kernel produces a jpeg file
containing BLACK text.

using System;
using System.IO;
using Wolfram.NETLink;

namespace WriTest
    static class Program
         static void Main()
            MathKernel mathKernel = new MathKernel();

            StreamReader streamReader = new
            string command1 = streamReader.ReadLine();
            string command2 = streamReader.ReadLine();

            string result1 = mathKernel.Result.ToString();

            string result2 = mathKernel.Result.ToString();

Note an examination of command1 within the debugger, just before it is
sent to the kernel, produces the following string:

"myText=\"\\!\\(\\*StyleBox[\\\"my text\\\",\\nFontColor->RGBColor[1,
0, 0]]\\)\";"

Wrapping ToExpression around this string in a Mathematica notebook
results in the desired red text. This problem seems to be related to
the need for the StyleBox which can only be found in a two-dimensional
string.  Other two dimensional string also lead to problems.

What is my problem?


  • Prev by Date: RE: Function argument
  • Next by Date: Re: schur decomposition and mathematica
  • Previous by thread: Re: Table through zero...strange
  • Next by thread: Re: .NET/Link and two-dimensional strings