return code

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
pmakowski
Newbie Member
Posts: 5
Joined: Thu Jun 16, 2016 8:59 am

return code

Post by pmakowski » Tue Aug 16, 2016 10:54 am

Hi,

we have a plugin that we run in command line mode

Code: Select all

qcad.exe" -no-gui -allow-multiple-instances -autostart "C:\Program Files\QCAD\/scripts/Tools/VisionOnly.js"
we would like to get a return code in case of success or failure, because we launch that with a dos bat file, we tried this way without success :

Code: Select all

 int = function main() {
    if (testArgument(args, "-h", "-help")) {
        printHelp();
        return 0;
    }
    
    if (args.length < 3) {
        print("No input file given. Try -h for help.");
        return 595;
    }

    var cadFileName = args[args.length - 1];
    if (isNull(cadFileName) || cadFileName.indexOf("-") === 0) {
        print("No input file. Try -h for help.");
        return 2;
    }
return main();
Any clue ?
Thanks

User avatar
andrew
Site Admin
Posts: 9061
Joined: Fri Mar 30, 2007 6:07 am

Re: return code

Post by andrew » Tue Aug 16, 2016 11:39 am

The return code of qcad.exe is the return code of main implemented in C++ which is 0 if there was no error in the script or 1 if there are uncaught exceptions.

A potential workaround might be to exit the application with:
QCoreApplication.exit(returnCode);

pmakowski
Newbie Member
Posts: 5
Joined: Thu Jun 16, 2016 8:59 am

[Solved]Re: return code

Post by pmakowski » Wed Aug 17, 2016 8:14 am

Thanks, it is what we need.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”