Create .txt file

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

Moderator: andrew

Post Reply
pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Create .txt file

Post by pmbrull » Mon Oct 15, 2018 11:19 am

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

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

Re: Create .txt file

Post by andrew » Mon Oct 15, 2018 11:32 am

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

pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Re: Create .txt file

Post by pmbrull » Mon Oct 15, 2018 11:41 am

Thanks for the guidance,

works like a charm.

Pere,

Post Reply

Return to “QCAD Developers and Contributors”