Page 1 of 1

Create .txt file

Posted: Mon Oct 15, 2018 11:19 am
by pmbrull
Hello and thank you for your time,

I am trying to create a txt file with some results calculated inside a script. I was following this discussion:https://www.qcad.org/rsforum/viewtopic. ... +txt#p1788

Code: Select all

    include("scripts/File/File.js")
    
    var file = new File("file.txt");
    file.open(File.WriteOnly);
    file.writeLine("hello");
    file.close();
And I get a constructor error: Wrong number/types of arguments for RAction.setGuiAction(), which makes sense because in the docs File gets a void Gui Action.

Is there any way to save some results?

Thank you,
Pere

Re: Create .txt file

Posted: Mon Oct 15, 2018 11:32 am
by andrew
pmbrull wrote:
Mon Oct 15, 2018 11:19 am
I was following this discussion:https://www.qcad.org/rsforum/viewtopic. ... +txt#p1788
That thread refers to QCAD 2 with its QSA script interface (obsolete).

Our github repository is a good source for current / up to date scripts:
https://github.com/qcad/qcad/tree/master/scripts

Or the scripts/Misc/Examples folder of your QCAD installation. For example scripts/Misc/Examples/IOExamples/ExRegisterFileExporter/ExRegisterFileExporter.js

Re: Create .txt file

Posted: Mon Oct 15, 2018 11:41 am
by pmbrull
Thanks for the guidance,

works like a charm.

Pere,