Menu

ScriptCommunicator Launcher

Anonymous
2016-01-16
2016-01-25
  • Anonymous

    Anonymous - 2016-01-16

    Hi Stefan,
    in attachment a small project for demonstrating the use of ScriptCommunicator as Runtime for complex multithreading applications.
    Kindest Regards,
    Pier Andrea.

     
  • Anonymous

    Anonymous - 2016-01-16

    The idea is to put Scriptcommunicator inside a folder called Runtime (in the example).. Then I've created a small Wrapper application that uses its name (without .exe under Windows) for looking at the right folder and launching all .JS files inside. You can use sub-folders for extra .js include files.

    #include <QProcess>
    #include <QDir>
    
    int main(int argc, char *argv[])
    {
           QObject *parent;
           QString program = "./Runtime/ScriptCommunicator.exe";
           QString name = QString("%1").arg(argv[0]).section('\\',-1);
           QString dirName = "./" + name.left(name.lastIndexOf(".")) + "/";
           QDir dir(dirName);
           if (!dir.exists()) return 1;
           QStringList filters;
           filters << "*.js";
           QStringList arguments;
           //arguments << "-withScriptWindow"; // for debugging purposes
           arguments << dir.entryList(filters, QDir::Files);
           QProcess *myProcess = new QProcess(parent);
           myProcess->setWorkingDirectory(dirName);
           myProcess->start(program,  arguments );
    
    }
    

    Under Windows 7 it works very well.
    Without recompiling the Launcher it is possible to make extra "applications" just renaming it and creating a folder with the right name (the renamed exe name without the extension).
    In this manner ScriptCommunicator is also a runtime for portable applications.
    I do know if it is useful and how to port to other platforms (MAC, LINUX), but the code is available.
    Kindest regards,
    Pier Andrea.

     

    Last edit: Anonymous 2016-01-16
  • Stefan Zieker

    Stefan Zieker - 2016-01-17

    Hi Pier,

    simple and useful. Thx for sharing this.

    PS: I have made a new post here: https://sourceforge.net/p/scriptcommunicator/discussion/usercontributions/thread/44346da9/.

    Best regards,
    Stefan

     

    Last edit: Stefan Zieker 2016-01-17
  • Anonymous

    Anonymous - 2016-01-18

    Hi Stefan,
    a small improvement in the source code for simple switching between "debug" and "release" with the help of the launcher:

    #include <QProcess>
    #include <QDir>
    
    int main(int argc, char *argv[])
    {
           QObject *parent;
           QString program = "./Runtime/ScriptCommunicator.exe";
           QString name = QString("%1").arg(argv[0]).section('\\',-1);
           QString dirName = "./" + name.left(name.lastIndexOf("."));
           QString debugDirName = dirName + "Debug";
           QDir debugDir(debugDirName);
           QDir dir(dirName);
           QStringList filters;
           QStringList arguments;
           QProcess *myProcess = new QProcess(parent);
    
           filters << "*.js";
    
           if (debugDir.exists()) {
               arguments << "-withScriptWindow";
               arguments << debugDir.entryList(filters, QDir::Files);
               myProcess->setWorkingDirectory(debugDirName);
               myProcess->start(program,  arguments );
           }
           else {
               if (dir.exists()){
                 arguments << dir.entryList(filters, QDir::Files);
                 myProcess->setWorkingDirectory(dirName);
                 myProcess->start(program,  arguments );
               }
           }
    
    }
    

    If your fileName is "FileName.exe" then the "release" directory is "FileName".
    If you change the directory name into "FileNameDebug" (or create another directory with this name) then the scripts will be launched from this directory and the ScriptWindow wll be opened (for debug purpose).
    In this way is very simple to launch and debug multiscript applications ready to deploy.

    Kindest regards,
    Pier Andrea.

     
  • Stefan Zieker

    Stefan Zieker - 2016-01-18

    Hi Pier,

    but then you have to copy the scripts or rename the directory. Wouldn't it be better if you create a file with all command-line options for ScriptCommunicator (maybe they will be increase in the future).

    Best regards,
    Stefan

     

    Last edit: Stefan Zieker 2016-01-18
  • Anonymous

    Anonymous - 2016-01-25

    Hi Stefan,
    yes this may be an alternative solution.
    Kindest regards,
    Pier Andrea.

    ps: the idea is to have a simple runtime version of SC in the tree of another "app". A lot of distributable system have their own runtime engine that is a simplified (strippen-down) version of the main app.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.