RE: Using VAR1 in the filename

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
mrjjman
Posts: 18
Joined: Mon Apr 11, 2016 5:41 am

RE: Using VAR1 in the filename

Post by mrjjman » Tue Mar 20, 2018 10:13 pm

I'm trying to use the !VAR1 expression in the SAVEAS filename, but keep getting this error: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFileOutputStream.init], line 50 (Error code: -1001)

It works in iMacros 10, my program version, but I can't get it to work in the firefox version. Here's my config info: Windows 10 Pro, FF 56.0.2, Imacros for Firefox 8.9.7

Here's the code I'm using:
VERSION BUILD=10022823
SET !DATASOURCE SNAPWebUserNumbersEVEN.csv
SET !DATASOURCE_COLUMNS 20
SET !DATASOURCE_LINE {{!LOOP}}
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
'TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:login ATTR=INLINEFIELD:inlinefield&&ID:username&&NAME:username&&TYPE:text CONTENT=*****(Not needed here :))
'SET !ENCRYPTION NO
'TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:login ATTR=INLINEFIELD:inlinefield&&ID:password&&NAME:password&&TYPE:password CONTENT=*****(Not needed here :))
'TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:login ATTR=CLASS:button&&ID:login&&NAME:login&&VALUE:Login&&TYPE:submit
URL GOTO=https://*****(Not needed here :))
TAG POS=1 TYPE=LABEL ATTR=ID:barcodeIDlabel
TAG POS=R1 TYPE=P ATTR=* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\ FILE=SNAP<SP>Extracts<SP>For<SP>{{!VAR1}}.csv

It's entirely possible this function isn't supported by iMacros FF, but it would greatly help if it was or if there is an idea of a workaround. The variable would be from what's extracted on the webpage, so whether I need to use !VAR1 or some other format, whatever I can do to get it working!

Thanks!
chivracq
Posts: 8309
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: RE: Using VAR1 in the filename

Post by chivracq » Tue Mar 20, 2018 10:41 pm

mrjjman wrote:I'm trying to use the !VAR1 expression in the SAVEAS filename, but keep getting this error:

Code: Select all

NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFileOutputStream.init], line 50 (Error code: -1001)
It works in iMacros 10, my program version, but I can't get it to work in the firefox version. Here's my config info:

Code: Select all

Windows 10 Pro, 
FF 56.0.2, 
Imacros for Firefox 8.9.7
Here's the code I'm using:

Code: Select all

VERSION BUILD=10022823
SET !DATASOURCE SNAPWebUserNumbersEVEN.csv
SET !DATASOURCE_COLUMNS 20
SET !DATASOURCE_LINE {{!LOOP}}
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
'TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:login ATTR=INLINEFIELD:inlinefield&&ID:username&&NAME:username&&TYPE:text CONTENT=*****(Not needed here :))
'SET !ENCRYPTION NO
'TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:login ATTR=INLINEFIELD:inlinefield&&ID:password&&NAME:password&&TYPE:password CONTENT=*****(Not needed here :))
'TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:login ATTR=CLASS:button&&ID:login&&NAME:login&&VALUE:Login&&TYPE:submit
URL GOTO=https://*****(Not needed here :))
TAG POS=1 TYPE=LABEL ATTR=ID:barcodeIDlabel
TAG POS=R1 TYPE=P ATTR=* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\ FILE=SNAP<SP>Extracts<SP>For<SP>{{!VAR1}}.csv
It's entirely possible this function isn't supported by iMacros FF, but it would greatly help if it was or if there is an idea of a workaround. The variable would be from what's extracted on the webpage, so whether I need to use !VAR1 or some other format, whatever I can do to get it working!

Thanks!
Hum, good, you finally mention your FCI directly, and you handled your previous Thread "correctly"... :D

Euh..., but..., pfff..., I don't know... Probably related to what you've got in the Extract, which maybe contains some Chars that cannot be used at the OS Level for Filenames, like Double Quotes or a Question Mark for example... Different Browsers handle those excluded Chars differently, some replace them automatically with Underscores, and other "prefer" to throw a Runtime Error to let you correct the File Name. :idea:

Or even some (soft) 'Tab' or 'Returns' included in the Extract could cause the Pb, maybe iMB10 automatically trims them out and iMacros for FF v8.9.7 doesn't...
=> Use "PROMPT _{{!EXTRACT}}_" to check the exact Content of the Extract... (and 'EVAL()' if you need to "clean" it...)

And I see your Script is about Barcode Content, if you extract "directly" Barcodes, the Browser maybe relies on a specific Lettertype or Charset or Encoding to convert them to "Standard Chars" that can be used for a Filename accepted by Win10. :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
mrjjman
Posts: 18
Joined: Mon Apr 11, 2016 5:41 am

Re: RE: Using VAR1 in the filename

Post by mrjjman » Wed Mar 21, 2018 1:13 am

The barcodes are only a set of numbers, but I think iMacros FF puts all extracted data in either double quotes or soft tab/return. I have to use Excel's CLEAN function to remove the non-printable chars. Maybe it might work with newest version of iMacros FF, even though latest release came out 2 years ago?
chivracq
Posts: 8309
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: RE: Using VAR1 in the filename

Post by chivracq » Wed Mar 21, 2018 3:22 am

mrjjman wrote:The barcodes are only a set of numbers, but I think iMacros FF puts all extracted data in either double quotes or soft tab/return. I have to use Excel's CLEAN function to remove the non-printable chars. Maybe it might work with newest version of iMacros FF, even though latest release came out 2 years ago?
Well, if the Extract contains soft Tabs or Returns, which is very common actually..., then like I said, use 'PROMPT' to check the exact Content and then 'EVAL()' to clean it... (=> 'trim()')

iMacros for FF (v8.x + v9.x) indeed does put Double Quotes around each Extract but only when doing a 'SAVEAS TYPE=EXTRACT', not like you are using it (in some Temp Var) for the Filename.

And v9.0.3 won't change anything to that, stick to v8.9.7 is my Advice...

>>>

Oh but wait, I got it, ah-ah...!! Nearly funny (afterwards), oops...!

The Pb is your "SET !EXTRACT NULL" just before doing the 'SAVEAS TYPE=EXTRACT', I think...! :shock:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply