Save / Read a file

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
brazoayeye
Posts: 30
Joined: Wed Jul 15, 2009 10:34 am

Save / Read a file

Post by brazoayeye » Thu Mar 13, 2014 6:28 pm

Hi!

I did lots of js scripts for firefox time ago, and i usually use the java vm like described in this post: http://forum.imacros.net/viewtopic.php?p=22731#p22731 .
I had problems sometimes with portable version of firefox but i always solved with a new jre installation.

Now i'm going to make a script but java doesn't start (java not defined). I tired LOTS of time to enable java plugin and to reinstall jre but it doesn't works.

This use javascript and doesn't works too
http://stackoverflow.com/questions/1239 ... javascript

I have to load and save files in local directory differents from datasource...

I could use more google sheet to save and load data everytime the program starts, but it's NOT SWEG
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Save / Read a file

Post by chivracq » Fri Mar 14, 2014 4:16 am

brazoayeye wrote:Hi!

I did lots of js scripts for firefox time ago, and i usually use the java vm like described in this post: http://forum.imacros.net/viewtopic.php?p=22731#p22731 .
I had problems sometimes with portable version of firefox but i always solved with a new jre installation.

Now i'm going to make a script but java doesn't start (java not defined). I tired LOTS of time to enable java plugin and to reinstall jre but it doesn't works.

This use javascript and doesn't works too
http://stackoverflow.com/questions/1239 ... javascript

I have to load and save files in local directory differents from datasource...

I could use more google sheet to save and load data everytime the program starts, but it's NOT SWEG
Your Thread looks interesting but mention your Configuration with all Versions (iMacros, Browser, OS) and "faulty" Script for me to do some digging in it...

"tired" = tried... (I suppose...)
But what does "NOT SWEG" mean...?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
brazoayeye
Posts: 30
Joined: Wed Jul 15, 2009 10:34 am

Re: Save / Read a file

Post by brazoayeye » Fri Mar 14, 2014 8:55 am

right for tried :D

I used imacros for firefox since 2010, with firefox 3.6. (i don't remember the java version and the iMacros version i used, but looking at revision history i think it was java 6.10 and maybe iMacros V7.0.0.0)
Now i'm trying with firefox 27.0.1 (over 9000 :D) and IM 8.2.4, Java 7.51.

I used it with windows XP, with windows 7 and with ubuntu (3 different versions) without problems with different versions of Java, firefox and iMacros. Few mounth ago i realized the script doesn't works but i solved using an old portable firefox with imacros installed. Now it doesn't work too.

The code i used is a functio like this:

Code: Select all

function writeFile(file, text){ //write text into file
	var BufferedWriter = new java.io.BufferedWriter(new java.io.FileWriter(file)); 
	BufferedWriter.write(text);
	BufferedWriter.close(); 
	}

function loadFile(filePath){ // read a file as an array
	var bufferedReader = new java.io.BufferedReader(new java.io.FileReader(filePath) );
	var read = new Array();
	while( ( line = bufferedReader.readLine()) != null)
	read.push(line);
	bufferedReader.close();
	return read
	}
PS: SWEG is a SWEG word, used by SWEG people and (i'm not sure :D) it's similar to cool. (SWEG = SWAG)

EDIT: Does imacros use Java dev kit? https://addons.mozilla.org/it/firefox/blocked/p428
I can't enable it but i have the "Java SE platform" activated, is it the jre needed by imacros?
chivracq
Posts: 9494
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Save / Read a file

Post by chivracq » Fri Mar 14, 2014 2:04 pm

OK, now we can talk...!

I wanted to refer you to some other Sun Java Thread but that's already the Thread you mentioned at the Beginning of your first Post...

You mention that you are at iMacros v8.2.4 for FF, which is quite an old Version of iMacros, current Version is v8.8.1. And there was a while ago some Problems with "URL GOTO + Local Files" that was broken for 1 or 2 Versions (though I thought it was for v8.5.x), so that might be related to your 'Local Files' Problem (as 'URL GOTO' might be using the same Mechanism like in your StackOverflow Link)) and v8.8.1 could solve that Problem. (And before investigating anything, TechSupport will ask you to update iMacros to the latest Version anyway...)

Your "a few months ago" was probably in October 2013 when Firefox automatically disabled the Java Plugin known for several Security Vulnerabilities. On a FF27.0.1 on Win7, I have the 'Java Deployment Toolkit' (v7-51) set to 'click-to-play' (Ask) (only other Option is "Never") and the 'Java(TM) Platform SE' (v7-51) set to 'click-to-play' (Ask) (other Options are "Never" and "always"). But on my current Pale Moon 24.4.0 (=FF27) on WinXP, I don't have any Java Plugin and iMacros (v8.8.1 for FF) works fine, so it doesn't need any Java Plugin. It uses only the native Firefox JavaScript Engine. But some Java Plugin might be required by your Java Function in your Script, I don't know...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
brazoayeye
Posts: 30
Joined: Wed Jul 15, 2009 10:34 am

Re: Save / Read a file

Post by brazoayeye » Tue Apr 01, 2014 2:22 pm

No1 know how to read / write a file using js?
Rammsis
Posts: 17
Joined: Mon Apr 05, 2010 1:37 pm

Re: Save / Read a file

Post by Rammsis » Sun Apr 20, 2014 11:50 am

brazoayeye wrote:.......Few mounth ago i realized the script doesn't works but i solved using an old portable firefox with imacros installed.........
please link for that.... if it solved "java is not defined" error im tired of reinstalling jre IM PRETTY SURE THAT I HAVE LATEST JAVA INSTALLED !!! Anyway i cant run buferreader
brazoayeye
Posts: 30
Joined: Wed Jul 15, 2009 10:34 am

Re: Save / Read a file

Post by brazoayeye » Sun Apr 20, 2014 2:07 pm

If i have been able to obtain (or if i have been able to remember the number of) the release i think i didn't post the question.

I think that the problem is that java isn't portable, so i cannot use an old version of it.

I think that there is not good solutions to solve the problem, maybe u can make a function called readCSV and saveCSV than can help you to read and save files in datasources folder using

http://wiki.imacros.net/!DATASOURCE
EXTRACT

Plz let me know if u find a better solution.
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: Save / Read a file

Post by skippyto » Wed May 14, 2014 10:39 am

Hi brazoayeye !

Firefox is not able anymore to use java functionnality.
You can still read/write file and more using the browser's objects (Components).

You find more informations here : http://forum.imacros.net/viewtopic.php? ... ect#p50608

Skippyto.
Post Reply