PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Using the SDK

After examining the SDK header and demo, I've got some questions and comments...

First, to avoid confusion - I would add something to the demo:
Code:

if (InitializePPL())
...
else
printf("InitializePPL failed!\n");



Also, it looks like the Eval() will take some PPL code and compile/run it. It also appears to make separate spaces for variables, etc... so, that's good (i.e. I could use the same code running multiple times independant from each other). But I don't see a way to make a function in PPL and call it repeatedly.

Here's an example - the user specifies a calculation to be made 'x+y'. So I would want to do something like this:
Code:

app *pplapp = Eval("global(x$,y$,r$); proc calc r=x+y; end");

while(loop)
{
SetVariable(a, "x$", x);
SetVariable(a, "y$", y);
CallProc(a, "calc");
GetVariable(a, "r$", &r);
...
}

FreeApp(a);



Does that make sense? Basically, go ahead and compile it for speed's sake and then call it multiple times.

Thanks.

edit: could you also explain the need for all the variables passed to GetVariable? I would have expected to see something along the lines of GetVariable(app, void *, var_type).
Hi,

To call a label from an application already created, simply use the SearchLabel() function like this:

tbytecode *b = SearchLabel(a, "calc");

Run(a, b);

I don't have support for passing parameters to the procedure or function yet, this will come later.
I assume you meant RunEx()...

Anyway, I had tried that and I get an unhandled exception when running the SearchLabel function. Is it searching for a 'proc' or something else? Either way, it shouldn't crash if it doesn't find it.

Code:

app *b = Eval("global(a$); a$ = {Goodbye Cruel World!}; proc testit ShowMessage(a$); end;");

tbytecode * func = SearchLabel(b, "testit");
if(func != NULL)
RunEx(b, func);
else
MessageBox(GetForegroundWindow(), "SearchLabel failed", "err", MB_OK);

Yes, I meant RunEx, sorry. :(

Eval is not working like it should, therefore the application handle doesn't exists anymore after the call.

I will need to do some more experimenting next week on this, I will release a new version of the SDK early next week.
Hi fast_rx,

I have fixed a few things with the SDK. There will be a new demo (demo2) that will show you how to call a ppl subroutine. Here is the main code:

Code:
// demo2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "..\\ppl.h"

int main(int argc, char* argv[])
{
printf("PPL integration test!\n");
if (InitializePPL())
{
app *a = Eval("proc test ShowMessage({Test Function!}); end;");
tbytecode *b = SearchLabel(a, "TEST");
if (b)
RunEx(a, b);
FreeApp(a);

ShutdownPPL();
}
else
printf("InitializePPL failed!\n");
return 0;
}


You have to make sure the procedure name you are passing in SearchLabel() is uppercase.
When you get the new one out, post here so I'll know it's available.

Thanks.


BTW, having this capability reminds me of a game from a while back. You had to program your robot to do things, and then it was autonomous. Seems like this would be easy to do - aside from the editor you'd have to write.
<a href="http://www.robotbattle.com">Robot Battle</a>?