Javascript Macros: Read/Write Text File, MsgBox, the future!

Creating a macro - Writing a Script - Using the API

Javascript Macros: Read/Write Text File, MsgBox, the future!

Postby AnthonyHarrison » Sat Oct 19, 2019 7:23 pm

Hi, I'm an open source believer but the Javascript API documentation - and how Google returns information about it - is shocking. I thought I'd do a ticket on my current commercial project using Open Office to test the water, I can more or less get the information I want from Calc etc, manipulate it, and then put it back into the doc ... the three areas I have not been able to find are:

1. Javascript: How to read all the text from a text file (from other applications) so that I can manipulate it and insert it into the document,
2. Javascript: How to write text to a text file to export JSON data to other applications, and
3. Javascript: How to pop up message boxes to the user so that he knows what is happening.

The great thing about using Javascript for an Open Office API is that the Javascript community is advanced and supportive, so for Javascript Macros to be successful this community really just has to be able to support OO integration - eg. reading text files, writing text files, reading and writing JSON objects to cells etc et al.

Any help on how to read a text file and write a text file? And to easily do a message box?

The answer to those questions should allow anyone to consume or generate JSON files.

I'd be very appreciative, I really don't want to have to fall back on MS Office, and with these three answers I think I'll be ok!

Please, no Basic or Python answers, I can do these things in both but my customers are Javascript savvy.

Kind regards, please forgive my constructive criticism, I don't have to push this technology but with a few tricks up my sleeve such as the answers to these questions, I think it's a good approach to take!

Anthony!
NeoOffice 2.2.3 with MacOS 10.4
AnthonyHarrison
 
Posts: 1
Joined: Sat Oct 19, 2019 7:05 pm

Re: Javascript Macros: Read/Write Text File, MsgBox, the fut

Postby Zizi64 » Sat Oct 19, 2019 8:55 pm

Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.3.3; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8543
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Javascript Macros: Read/Write Text File, MsgBox, the fut

Postby JeJe » Sun Oct 20, 2019 12:17 pm

If Javascript doesn't have to tools to do it directly then you can open and save text files in Writer (and manipulate it and transfer it into another open document). You'll find plenty of Basic examples through a search for you to translate.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Javascript Macros: Read/Write Text File, MsgBox, the fut

Postby Villeroy » Sun Oct 20, 2019 4:43 pm

1. Javascript: How to read all the text from a text file (from other applications) so that I can manipulate it and insert it into the document,

Exactly like you do with any other language.
2. Javascript: How to write text to a text file to export JSON data to other applications, and

Well, as a JavaScript developer you know how to generate JSON from objects, from XML or anything.
3. Javascript: How to pop up message boxes to the user so that he knows what is happening.

Exactly like you do with any other language except StarBasic which comes with a helper.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27382
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests