YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Trying to evaluate expression in string
Kelvin
#1 Posted : Saturday, March 19, 2022 12:30:51 PM(UTC)
Rank: Advanced Member

Groups: Registered, Moderator
Joined: 3/26/2015(UTC)
Posts: 66
Man
Location: Georgia

Thanks: 3 times
Was thanked: 0 time(s) in 0 post(s)
So, I want to make a function that takes a string like, for example, "return 1+1", and returns the result. I have a function that runs strings as code already:

Code:

SQInteger sqDoString(HSQUIRRELVM v) {
    const char* a;
    sq_getstring(v, 2, &a);

    SQInteger oldtop = sq_gettop(gvSquirrel);
    sq_compilebuffer(gvSquirrel, a, (int)strlen(a) * sizeof(SQChar), "string", 1);
    sq_pushroottable(gvSquirrel);
    sq_call(gvSquirrel, 1, SQFalse, SQTrue);
    sq_settop(gvSquirrel, oldtop);

    return 0;
}


The issue here is that simply setting SQFalse to SQTrue and returning 1 didn't work; this just results in it returning the same string it was given as an argument. What do I do to make it return what the string function returns?
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.089 seconds.