40 lines
898 B
C
Raw Normal View History

2021-10-01 00:21:50 +08:00
/* this demo shows the usage of method */
#include "pikaScript.h"
#include <stdio.h>
void obj_runWithInfo(PikaObj *self, char *cmd)
{
printf(">>> %s\r\n", cmd);
obj_run(self, cmd);
}
int main()
{
PikaObj *pikaMain = pikaScriptInit();
/* user input buff */
char inputBuff[256] = {0};
/* run the script with check*/
printf(">>> ");
while (1)
{
/* get user input */
fgets(inputBuff, sizeof(inputBuff), stdin);
/* run PikaScript and get res */
2021-10-30 22:29:10 +08:00
PikaObj *globals = obj_runDirect(pikaMain, inputBuff);
2021-10-01 00:21:50 +08:00
/* get system output of PikaScript*/
char *sysOut = args_getSysOut(globals->list);
2021-10-01 00:21:50 +08:00
if (!strEqu("", sysOut))
{
/* print out the system output */
printf("%s\r\n", sysOut);
}
printf(">>> ");
/* deinit the res */
2021-11-23 12:15:12 +08:00
// obj_deinit(globals);
2021-10-01 00:21:50 +08:00
}
}