Create .txt file

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
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: 9037
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 Programming, Script Programming and Contributing”