Page 1 of 1

!NOW without leading zero does not work

Posted: Fri Apr 16, 2010 12:52 pm
by Mythlord91
On http://wiki.imacros.net/!NOW it is said, that i can use {{!NOW:s}} to "Displays the second as a number without leading zeros"
So, the very simple macro:
PROMPT {{!NOW:s}}
should prompt something like:" 9 - ok"
but it always prompt " s - ok"

PROMPT {{!NOW:ss}}
works well - but I need the seconds without the leading zero - becouse it will be the line of a datasource...
Its the same issue with days and so on - everything without leading zeros does not work.

I am using Firefox 3.6.3 and iMacros 6.6.5.0

Any workarounds or fixes?

Re: !NOW without leading zero does not work

Posted: Mon Apr 19, 2010 10:44 am
by Daniel, Tech Support
Hello,

Thanks a lot for reporting this! I could reproduce the issue here. I will now give it over to our developers, so that they fix it.
I hope the fix will be available soon!

Best regards,

Re: !NOW without leading zero does not work

Posted: Wed Jan 19, 2011 5:52 pm
by cmuld3r
Without leading zeros still does not work... and I see the wiki page now doesn't even reflect the 'without leading zeros' format code - http://wiki.imacros.net/!NOW... but the Google cached version does.

Is it not supported?

Code: Select all

VERSION BUILD=7031111 RECORDER=FX
SET !VAR1 {{!NOW:m}}
SET !VAR2 {{!NOW:d}}
SET !VAR3 {{!NOW:yyyy}}
'm' and 'd' return the letters 'm' and 'd' respectively. Is there a workaround to get rid of the 0's, as 'mm' & 'dd' work, but I need without the leading zeros?

Thank you!

Re: !NOW without leading zero does not work

Posted: Thu Jan 20, 2011 9:40 am
by Tech Support
We updated the wiki page yesterday to reflect the fact that iMacros 7 (and iMacros for Firefox/Chrome) do not yet support

SET !VAR1 {{!NOW:m}}
SET !VAR2 {{!NOW:d}}

We are considering adding support for it to Version 7, but can you tell us why you need it? We want to make sure that we add the right features in the right way. So the question is, why is "s" better than "ss" in your use case?

Re: !NOW without leading zero does not work

Posted: Thu Jan 20, 2011 9:34 pm
by cmuld3r
Thanks for the response.

I'm using it with a form submission macro. The site records the date as drop-down entries which do not include leading zeros. If imacros outputs leading zeros, the date isn't recognized and macros don't work.

This is a really crucial feature for my organization ASAP. Is there any workaround you can think of? Or if not, is there a possibility of feature support?

Thank you!!!

Re: !NOW without leading zero does not work

Posted: Thu Jan 20, 2011 9:48 pm
by Tech Support
Are you using the iMacros Scripting Edition? If so, I can suggest a few workarounds.

Re: !NOW without leading zero does not work

Posted: Thu Jan 20, 2011 11:33 pm
by cmuld3r
Currently firefox addon, no scripting.

It's a pilot project with no funding as of yet. This set of macros would greatly improve the possibility of funding and wider implementation.

Can you please share scripting edition workarounds?

And what is the possibility of bringing back the 'm' & 'd' features?

Re: !NOW without leading zero does not work

Posted: Mon Jan 24, 2011 8:03 pm
by cmuld3r
Can anyone please suggest a Javascript workaround to insert a month and day without leading zeros?

This is the current code (which doesn't work when the month and/or day have a leading zero, as I explained earlier... the site's drop-down selections don't have the leading zeros):

Code: Select all

VERSION BUILD=7031111 RECORDER=FX

SET !VAR1 {{!NOW:mm}}
SET !VAR2 {{!NOW:dd}}
SET !VAR3 {{!NOW:yyyy}}

'SET MONTH
TAG POS=1 TYPE=SELECT ATTR=NAME:litmonth CONTENT=%{{!VAR1}}

'SET DAY
TAG POS=1 TYPE=SELECT ATTR=NAME:litday CONTENT=%{{!VAR2}}

'SET YEAR
TAG POS=1 TYPE=SELECT ATTR=NAME:lityear CONTENT=%{{!VAR3}}

Thank you!

Re: !NOW without leading zero does not work

Posted: Tue Jan 25, 2011 5:48 pm
by Tom, Tech Support
StripZerosFromDate.js:

Code: Select all

var macroExtractDate;
macroExtractDate =  "CODE:";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:mm}}" + "\n"; 
macroExtractDate +=  "ADD !EXTRACT {{!NOW:dd}}" + "\n"; 
macroExtractDate +=  "ADD !EXTRACT {{!NOW:yyyy}}" + "\n"; 
iimPlay(macroExtractDate)

var month = parseInt(iimGetLastExtract(1));
var day = parseInt(iimGetLastExtract(2));
var year = parseInt(iimGetLastExtract(3));

var macroSetDate;
macroSetDate =  "CODE:";
macroSetDate +=  "'SET MONTH" + "\n"; 
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:litmonth CONTENT=%{{month}}" + "\n"; 
macroSetDate +=  "'SET DAY" + "\n"; 
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:litday CONTENT=%{{day}}" + "\n"; 
macroSetDate +=  "'SET YEAR" + "\n"; 
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:lityear CONTENT=%{{year}}" + "\n"; 

iimSet("month", month.toString());
iimSet("day", day.toString());
iimSet("year", year.toString());

iimPlay(macroSetDate);

Re: !NOW without leading zero does not work

Posted: Tue Jan 25, 2011 8:37 pm
by cmuld3r
Thank you Tom! Works great!

To play the js script you gave, I set up a js file which calls a macro with the first section of the original macro, plays the date setting javascript, then plays a macros with the last part of the original macro, repeating when necessary:

MYJSMACRO.js:

Code: Select all

iimPlay("STARTSERVICE.iim");


var macroExtractDate;
...
iimPlay(macroSetDate);


iimPlay("SERVICE1.iim");
iimPlay("SUBMITSERVICE.iim");
iimPlay("STARTSERVICE.iim");


var macroExtractDate;
...
iimPlay(macroSetDate);


iimPlay("SERVICE2.iim");
iimPlay("SUBMITSERVICE.iim");
It would be easier for setup and editing to modify the function of the macro in one file, calling the set javascript where needed, rather than having multiple macros called from the js file which each contain parts of a complete macro and javascript inserted where needed.

Can javascript/js files be played from a macro? Or can macro code be placed in js files?

Or is there an easier way to do it that I'm not thinking of?

Thank you again!!!

update: I found the code creator which will convert macro code to javascript and other languages and vice versa (http://sourceforge.net/apps/trac/imacros-codegen). Is this my best bet? Any other possible solutions are still welcome :)

Thanks to all!

Re: !NOW without leading zero does not work

Posted: Wed Jan 26, 2011 3:19 pm
by Tom, Tech Support
Can javascript/js files be played from a macro? Or can macro code be placed in js files?
You can only call macro code/files from Javascript, not the other way around.
I found the code creator... Is this my best bet?
Yes, that is a great tool for working with iMacros and script, definitely use it!

Re: !NOW without leading zero does not work

Posted: Wed Feb 09, 2011 5:29 pm
by cmuld3r
Thank you for all the help. The given code was working beautifully until yesterday (2/8/11) when the output of {{day}} started coming up as '0'. Strange why it would occur on 2/8/11...

Please test the following date macro if you are also now getting '0' output for the day (the test goes to wikipedia and puts the date - month day year [supposedly without leading zeros] into the search box with spaces between):

Code: Select all

var macroExtractDate;
macroExtractDate =  "CODE:";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:mm}}" + "\n";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:dd}}" + "\n";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:yyyy}}" + "\n";
iimPlay(macroExtractDate)
var month = parseInt(iimGetLastExtract(1));
var day = parseInt(iimGetLastExtract(2));
var year = parseInt(iimGetLastExtract(3));
var macroSetDate;
macroSetDate =  "CODE:";
macroSetDate +=  "URL GOTO=http://en.wikipedia.org/wiki/Main_Page" + "\n";
macroSetDate +=  "TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/w/index.php ATTR=ID:searchInput CONTENT={{month}}<SP>{{day}}<SP>{{year}}" + "\n";
iimSet("month", month.toString());
iimSet("day", day.toString());
iimSet("year", year.toString());
iimPlay(macroSetDate);
Please advise!

Re: !NOW without leading zero does not work

Posted: Wed Feb 09, 2011 8:32 pm
by Tom, Tech Support
Ah, sorry about that cmuld3r. It's because the parseInt function assumes the radix is octal (base eight) if the string begins with "0". To correct this, we just specify a radix of 10 in the calls to parseInt.

Code: Select all

var month = parseInt(iimGetLastExtract(1), 10);
var day = parseInt(iimGetLastExtract(2), 10);
var year = parseInt(iimGetLastExtract(3), 10);

Re: !NOW without leading zero does not work

Posted: Thu Feb 10, 2011 11:43 pm
by cmuld3r
Thanks! :D

Here's the updated javascript code to set the date without leading zeros for anyone who needs it:

Code: Select all

//SET TODAY'S DATE

var macroExtractDate;
macroExtractDate =  "CODE:";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:mm}}" + "\n";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:dd}}" + "\n";
macroExtractDate +=  "ADD !EXTRACT {{!NOW:yyyy}}" + "\n";
iimPlay(macroExtractDate)

var month = parseInt(iimGetLastExtract(1), 10);
var day = parseInt(iimGetLastExtract(2), 10);
var year = parseInt(iimGetLastExtract(3), 10);

var macroSetDate;
macroSetDate =  "CODE:";
macroSetDate +=  "'SET MONTH" + "\n";
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:litmonth CONTENT=%{{month}}" + "\n";
macroSetDate +=  "'SET DAY" + "\n";
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:litday CONTENT=%{{day}}" + "\n";
macroSetDate +=  "'SET YEAR" + "\n";
macroSetDate +=  "TAG POS=1 TYPE=SELECT ATTR=NAME:lityear CONTENT=%{{year}}" + "\n";

iimSet("month", month.toString());
iimSet("day", day.toString());
iimSet("year", year.toString());

iimPlay(macroSetDate);