20 Reputation

2 Badges

7 years, 220 days

MaplePrimes Activity

These are replies submitted by jeffx

Hi, Paul,
  First, thank you for your wonderful post "Using OpenMaple with C#" in Mapleprimes!
  When I run the C# code test.cs (from Maple 16 Programming Guide, shown at the bottom) in C# Console with replacing "MapleEngine.EvalMapleStatement(kv,"int(x,x);")" by "Console.WriteLine(MapleEngine.EvalMapleStatement(kv, Encoding.ASCII.GetBytes("int(x,x);")));", I get the printout "276684308
". If I use "Console.WriteLine(MapleEngine.EvalMapleStatement(kv, Encoding.ASCII.GetBytes("int(x^2,x);")));", I get the printout "276684628
". Could you please tell me why and how this happens?

Thank you very much in advance!
Sincerely Yours

test.cs code:
using System;
using System.Text;
using System.Runtime.InteropServices;
class MainApp {
// When evaluating an expression, Maple sends all of the displayed
// output through this function.
    public static void cbText( IntPtr data, int tag, String output )
public static void Main(string[] args) {
MapleEngine.MapleCallbacks cb;
byte[] err = new byte[2048];
IntPtr kv;
// pass -A2 which sets kernelopts(assertlevel=2) just to show
// how in this example. The corresponding argc parameter
// (the first argument to StartMaple) should then be 2
// argv[0] should always be filled in with a value.
String[] argv = new String[2];
argv[0] = "maple";
argv[1] = "-A2";
// assign callbacks
cb.textCallBack = cbText;
cb.errorCallBack = null;
cb.statusCallBack = null;
cb.readlineCallBack = null;
cb.redirectCallBack = null;
cb.streamCallBack = null;
cb.queryInterrupt = null;
cb.callbackCallBack = null;
try {
kv = MapleEngine.StartMaple(2,argv,ref
catch(DllNotFoundException e) {
catch(EntryPointNotFoundException e) {
// make sure we have a good kernel vector handle back
if( kv.ToInt64() == 0 ) {
// If Maple does not start properly, the "err" parameter  will be filled
// in with the reason why (usually a license error).
// Note that since we passed in a byte[] array, we need to remove
// the characters past \0 during conversion to string
Console.WriteLine("Fatal Error, could not start Maple: "

Page 1 of 1