.NET/Link and two-dimensional strings
- To: mathgroup at smc.vnet.net
- Subject: [mg66989] .NET/Link and two-dimensional strings
- From: "colin" <colin.ladyka at scf.sk.ca>
- Date: Tue, 6 Jun 2006 06:27:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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]]\)"; Export["C:\\Temp\\myText.jpg",Show[Graphics[Text[myText,{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 StreamReader(@"C:\Temp\myFile.txt"); string command1 = streamReader.ReadLine(); string command2 = streamReader.ReadLine(); streamReader.Close(); mathKernel.Compute(command1); string result1 = mathKernel.Result.ToString(); mathKernel.Compute(command2); 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? Colin