Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

ExecuteString vs AddScriptSection + Build


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 21 July 2004 - 03:05 AM

Hello, Till now I was using AngelScript in a very simple way : ExecuteString(...) This was well working. Then I have decided to work another way : AddScriptSection + Build + GetFunctionID ... Well, this doesn't work. What I'm doing is : AddScriptSection("module", "funcname", "void funcname() {" + same code that was working with ExecuteString + "}", strlen(..)) as many time as i have pieces of code. Then I call Build and I get : Building... Parsing: "XPNTree_TIMEOUT" Error : (1, 13) Expected identifier Parsing: "TheOtherCode" Error : (1, 101) Expected identifier Error : (1, 145) Unexpected token 'if' Parsing: "FlipImage" Error : (1, 84) Expected identifier ... What I am doing wrong ? Thanks for any answer. AbrKen.

Sponsor:

#2 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 21 July 2004 - 03:31 AM

some more elements :

this code :

void XPNTree_TIMEOUT() {
int i; i = 50;
}

void TheOtherCode() {
...

Generate :
Building...
Parsing: "XPNTree_TIMEOUT"
Error : (1, 13) Expected identifier
...

this code :

void XPNTree_TIMEOUT() {
int i;
}

void TheOtherCode() {
...

is well compiling.



#3 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 21 July 2004 - 04:03 AM

more clues for anyone that can answer the first message :

If I call AddScriptSection only one time (with all the script functions concatenated of course), this works just fine.

Why ?

#4 Andreas Jonsson   Moderators   -  Reputation: 3414

Like
0Likes
Like

Posted 21 July 2004 - 05:59 AM

I can't see any error in the way you're doing it. I'll have to make some tests.

Would it be possible for you to write a test case for the test framework that reproduces the errors and then pass that to me? That will make it easier for me to help you.

You'll find the test framework here:

http://www.angelcode.com/angelscript/files/testframe.zip

Calling AddScriptSection() only one time or multiple times shouldn't make any difference, except for the error reporting.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#5 Andreas Jonsson   Moderators   -  Reputation: 3414

Like
0Likes
Like

Posted 21 July 2004 - 10:32 AM

I tried the following and had no errors:


#include "angelscript.h"
#include <stdio.h>
#include <string.h>

static const char *script = "void XPNTree_TIMEOUT() {int i; i = 50;}";
static const char *script2 = "void TheOtherCode() {}";

class COutStream : public asIOutputStream
{
public:
void AS_CALL Write(const char *text) { printf(text); }
};

bool Test_Build()
{
bool ret = false;

asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

engine->AddScriptSection("test", "test", script, strlen(script));
engine->AddScriptSection("test", "test2", script2, strlen(script2));

COutStream out;

int r = engine->Build("test", &out);
if( r < 0 )
{
printf("Test_Build: Failed to build script.\n");
ret = true;
}

engine->Release();

return ret;
}




What are you different from my example above?

Could it be that you're not sending the correct length of the script? Verify the way you call strlen().
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#6 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 21 July 2004 - 08:19 PM

After having read your answer, I have re-examined my code, and was making a mistake.

I wasn't sending function declaration, eg :


/*
void FlipImage()
{
*/

bstr bstrTmp;
string strTmp;
CLuaXmlPresenter *xmlPresenter;

xmlPresenter = getReferencedPresenter("XPNPresenter");

if (xmlPresenter != 0) {
CLuaXmlPresenterElementBitmap *xmlBitmap;
xmlBitmap = xmlPresenter->GetBitmap(10);
if (xmlBitmap != 0) {
CImage *imageBitmap;
imageBitmap = xmlBitmap->GetImageBitmap();
if (imageBitmap != 0) {
imageBitmap->Flip();
xmlBitmap->Display(0, true);
}
}
}
/*
}
*/




The comment line are what was missing (not sent to AddScriptSection).

This is interristing, I have learned this way that ScriptCode MUST be contained in function, ans ONLY variable declaration is addmited as global.

Thank you for your answer, it helps.

Regards,
AbrKen.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS