Problem: Passing Variables within Expressions To Mathematica through JLink
- To: mathgroup at smc.vnet.net
- Subject: [mg26190] Problem: Passing Variables within Expressions To Mathematica through JLink
- From: "rani olam" <okayr9 at cool.com.jo>
- Date: Thu, 30 Nov 2000 22:02:09 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi
The following program is a visual basic program to send request to
Mathematica Kernel to calculate Pi to arbitrary decimal digits throught
JLink using the expression
N[Pi, NumOfDigits] and sending it Packet by Packet, the problem is
that i could not send this expression as a whole using the following
line :
Text1.Text=link.evaluateToOutputForm("N[Pi, NumOfDigits]", 0)
i could not pass the variable NumOfDigits within the expression to
Kernel.
it work if we replaced the variable with a number such as 10000:
Text1.Text=link.evaluateToOutputForm("N[Pi, 10000]", 0)
unfortunately the user's guide give us only examples about calculating
2+2, an the packet by packet method.
any help?
rani olam
okayr9 at cool.com.jo
'remember to adjust the mathematica kernel path as in your system
'Text1.Text is for displaying Pi digits in the Text window
'Text2.Text is for entering the number of digits you want to calculate
'The main method is from the User's Manual of JLink which could be
obtained from:
'http://www.wolfram.com/solutions/mathlink/jlink
Private Sub Command1_Click()
NumOfDigits= Val(Text2.Text)
Set link = GetObject("java:com.wolfram.jlink.KernelLinkCOM")
link.setLink ("-linkname 'C:\Program Files\Wolfram
Research\Mathematica\4.0\\mathkernel' -linkmode launch")
link.discardAnswer
link.putFunction "EvaluatePacket", 1
link.putFunction "ToString", 1
link.putFunction "N", 2
link.putSymbol ("Pi")
link.put (NumOfDigits)
link.waitForAnswer
Text1.Text =link.getString
link.Close
End Sub