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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
AnthonyHarrison
Posts: 1
Joined: Sat Oct 19, 2019 7:05 pm

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

Post by AnthonyHarrison »

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
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
JeJe
Volunteer
Posts: 2780
Joined: Wed Mar 09, 2016 2:40 pm

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

Post by JeJe »

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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply