fb39ca4 / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Enhancement: add utility functions to scan/execute a script file #140

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. A predefined function to scan a script file would be handy. 

  void scanFile(char *pScriptFilename);

It is easy to create on our own:

void CscanFile(struct ParseState *Parser, struct Value *ReturnValue, struct 
Value **Param, int NumArgs)
{
    char *pScriptFileName = ( char *)Param[0]->Val->Pointer;
    PicocPlatformScanFile( pScriptFileName);
}

but it could maybe be a part of the standard package?

2. A predefined function to execute a script in its own context would be handy 
(see also issue 137):

    void executeFile(char *pScriptFileName);

Interprets the file content in its own picoc context.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by jjohans...@gmail.com on 9 Oct 2011 at 12:52

GoogleCodeExporter commented 8 years ago
I guess that the prototype for executeFile should read

  int executeFile(char *pScriptFileName);

and that the function could return the value returned by 'main' in the script 
executed? 

Using executeFile all scripts could have their own main and could be executed 
stand alone and also by other scripts (nested to (almost) any depth).

Original comment by jjohans...@gmail.com on 10 Oct 2011 at 8:07