[scilab-Users] Re: Use of SendScilabJob

Mike Page Mike at Page-One.Waitrose.com
Wed Jul 11 13:12:33 CEST 2012


Hi

Not sure which part of my previous explanation you didn't understand...

Yes - you can use SendScilabJob from your C code.

This function does exactly what would happen if you typed the string at the
Scilab console.  So if you do SendScilabJob("disp(%pi)"); it will cause
3.1416 to be printed on the terminal.

So you need first to send a string to exec your function file, then another
string to call the function, just like you would at the Scilab console.

If you want to pass and retrieve large argument arrays, use
createNamedMatrixOfDouble and readNamedMatrixOfDouble (see help text or
example below).  If not, just insert the argument values into the string in
C using for example sprintf.

Maybe an example would make it easier to follow.  Have you tried the example
provided (SendScilabJob("myMatrix=['sample','for the help']");) that you
quoted in your code?  Did it work?  If not, what happened?  Did it fail to
compile or fail to link?  What was the error?

I can't write your code for you, but here's an example that works for me.
It's more complicated than you need, but it might help.

Mike.


==========================================================

#include <windows.h>
#include <stdio.h>
#include <process.h>
#include "call_scilab.h"
#include "api_scilab.h"


HANDLE	PlotCmd[2];
HANDLE	Reply;
double	x[100];
double	y[100];


/*--------------------------------------------------------------------------
*/
static void SciPlot (void* Params)
{
	DWORD	Event;
	BOOL	Exit = FALSE;

	if (StartScilab (NULL, NULL, 0) == FALSE)
	{
		printf ("Error : StartScilab\n");
	}

	Reply = CreateEvent (NULL, FALSE, FALSE, NULL);

	while (!Exit)
	{
		Event = WaitForMultipleObjects (2, PlotCmd, FALSE, INFINITE);

		switch (Event)
		{
			case	(WAIT_OBJECT_0 + 0):
			{
				createNamedMatrixOfDouble (pvApiCtx, "x", 1, 100, x);
				createNamedMatrixOfDouble (pvApiCtx, "y", 1, 100, y);
				SendScilabJob ("delete (e);");
				SendScilabJob ("plot2d(x,y);");
				SendScilabJob ("e = gce ();");
				printf ("...Plot started\n");
				SetEvent (Reply);
				break;
			}
			case	(WAIT_OBJECT_0 + 1):
			{
				Exit = TRUE;
				break;
			}
		}
	}

	if (TerminateScilab (NULL) == FALSE)
	{
		printf ("Error : TerminateScilab\n");
	}

	SetEvent (Reply);
}

/*--------------------------------------------------------------------------
*/
int main(void)
{
	int	i, j;

	printf ("Starting\n");
	PlotCmd[0] = CreateEvent (NULL, FALSE, FALSE, NULL);
	PlotCmd[1] = CreateEvent (NULL, FALSE, FALSE, NULL);
	_beginthread (SciPlot, 0, NULL);
	Sleep (1000);

	for (j=1; j<100; j++)
	{
		x[j] = j;
	}

	for (i=0; i<10; i++)
	{
		for (j=1; j<100; j++)
		{
			y[j] = (2.0 *(double)rand () / (double)RAND_MAX) - 1.0;
		}
		printf ("Update Plot\n");
		SetEvent (PlotCmd[0]);
		WaitForSingleObject (Reply, INFINITE);
		Sleep (1000);
	}
	printf ("Terminate Plot\n");
	SetEvent (PlotCmd[1]);
	WaitForSingleObject (Reply, INFINITE);
	CloseHandle (PlotCmd[0]);
	CloseHandle (PlotCmd[1]);
	return 0;
}
/*--------------------------------------------------------------------------
*/

==========================================================


-----Original Message-----
From: hehiha [mailto:dungnguyenbk at gmail.com]
Sent: 11 July 2012 10:30
To: users at lists.scilab.org
Subject: [scilab-Users] Re: Use of SendScilabJob


Hi
I implement external module.
my module have block ABC
In ABC.sci file
I implement 2 function
1. Function to show interface ABC block
2. Function XYZ
in ABC.C file computation file
do some thing for ABC block and call XYZ function.

Do I use SendScilabJob function, all right ?
How to use SendScilabJob function for my code ?


--
View this message in context:
http://mailinglists.scilab.org/Use-of-SendScilabJob-tp3880580p4024559.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.

--
To unsubscribe from this mailing-list, please send an empty mail to
users-unsubscribe at lists.scilab.org
To check the archives of this mailing list, see
http://mailinglists.scilab.org/



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2195 / Virus Database: 2437/5124 - Release Date: 07/10/12




More information about the users mailing list