PERL $b->iimGetLastErrorMessage() method returns "undef"
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
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
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
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
PERL $b->iimGetLastErrorMessage() method returns "undef"
Dear iOpus folks
I am using iMacro mainly embedded in PERL scripts, where most of these are invoked by a scheduler, unattended. Nicely enough, iOpus provided a scripting interface class to iMacro to a number of languages, including PERL.
Since Internet sites responses are not 100% reliable, too often a macro hangs. When the macro is manually invoked, this is not much of a problem, you give it up and "play" it again.
But if the script is automatically invoked, unattended, this is a serious problem! so there are two issues:
1) Can I specify a time-out to have iMacro return control to the PERL script?
2) One method of the PERL class which is very important to this unattended application is the iimGetLastErrorMessage() method.
The last one is supposed to return an error message. In another post I mentioned that it always returns the "undef" value. In that post things didn't work at all so this one was considered a minor issue. Luckily, the more important issue there was satisfactorily solved. We were so happy about it that we ignored this one. But it is not minor. So please, how do we fix this?
Can you help?
Regards,
Meir
I am using iMacro mainly embedded in PERL scripts, where most of these are invoked by a scheduler, unattended. Nicely enough, iOpus provided a scripting interface class to iMacro to a number of languages, including PERL.
Since Internet sites responses are not 100% reliable, too often a macro hangs. When the macro is manually invoked, this is not much of a problem, you give it up and "play" it again.
But if the script is automatically invoked, unattended, this is a serious problem! so there are two issues:
1) Can I specify a time-out to have iMacro return control to the PERL script?
2) One method of the PERL class which is very important to this unattended application is the iimGetLastErrorMessage() method.
The last one is supposed to return an error message. In another post I mentioned that it always returns the "undef" value. In that post things didn't work at all so this one was considered a minor issue. Luckily, the more important issue there was satisfactorily solved. We were so happy about it that we ignored this one. But it is not minor. So please, how do we fix this?
Can you help?
Regards,
Meir
Regards,
Meir
Meir
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi, me again!
I tried the iimGetLastError() method too. Although this one returns a defined value, the value is always zero!
What do I do wrong???
Regards,
Meir
I tried the iimGetLastError() method too. Although this one returns a defined value, the value is always zero!
What do I do wrong???
Regards,
Meir
Regards,
Meir
Meir
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi everybody,
(It seems I am corresponding with myself only... !)
Well, I made some progress! I now use the "Return Code" of the scripting interface to find the result of the operation.
My PERL script shows some unexpected behavior:
* iimInit seems to consistently return the OK code - "1"
* iimPlay however returned once "-930" and then consistently "-971"
Despite the negative (i.e., error) last return code, the macro seems to work just fine, thank you!
I tried though to find the list of return codes. The obvious place was the Error and Return Codes Wiki Page. Down there there is the following "bullet":
Pray tell me what are the meanings of these codes...
(It seems I am corresponding with myself only... !)
Well, I made some progress! I now use the "Return Code" of the scripting interface to find the result of the operation.
My PERL script shows some unexpected behavior:
* iimInit seems to consistently return the OK code - "1"
* iimPlay however returned once "-930" and then consistently "-971"
Despite the negative (i.e., error) last return code, the macro seems to work just fine, thank you!
I tried though to find the list of return codes. The obvious place was the Error and Return Codes Wiki Page. Down there there is the following "bullet":
All links in that bullet point to itself. Very frustrating. Half an hour of search resulted in zilch.# -100...-999 (sMacroError)
sMacroError can have a value of -100 and lower (-101,-102,...,-999). These are NOT Scripting Interface error codes, but errors created by the iMacros browser and the macro itself. The Scripting Interface passes them from the browser to your script or application.
Pray tell me what are the meanings of these codes...
Regards,
Meir
Meir
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Meir,
Sorry for the delay. iimGetLastError will only return an error code if an error has really occured I.e. if a TAG command failed etc.
Have you tried in it Perl on a macro that definitely fails, e.g.
?
I will now look into the error codes.
Best regards,
Sorry for the delay. iimGetLastError will only return an error code if an error has really occured I.e. if a TAG command failed etc.
Have you tried in it Perl on a macro that definitely fails, e.g.
Code: Select all
URL GOTO=http://www.google.com
TAG POS=1 TYPE=A ATTR=TXT:microsoft
I will now look into the error codes.
Best regards,
Daniel, iOpus Support
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
With regards to the error codes, we will update the wiki shortly.
Daniel, iOpus Support
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Dear Daniel,
Well, it seems that my computer is jinxed or something! What works at your end doesn't at mine... Did you actually ran it from Perl?
I did try to find "Microsoft" on the Google page. Running iMacro directly from FF indeed ended with Error:
* The "Return code" was -921
* iimGetLastErrorMessage returned UNDEF.
(BTW, the "Return Codes" for iimPlay() and the other scripting I/F are still missing.)
Well, it seems that my computer is jinxed or something! What works at your end doesn't at mine... Did you actually ran it from Perl?
I did try to find "Microsoft" on the Google page. Running iMacro directly from FF indeed ended with Error:
However, running it from PERL did the following:"RuntimeError: element A specified by TXT:microsoft was not found, line: 4"
* The "Return code" was -921
* iimGetLastErrorMessage returned UNDEF.
(BTW, the "Return Codes" for iimPlay() and the other scripting I/F are still missing.)
Regards,
Meir
Meir
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Meir,
No, I didn't mean that code worked on my machine with Perl, I wanted to ask you if it does on your. I will try to reproduce it here then (will need to install Perl again as I've got a new machine ) and give you an update.
Best regards,
No, I didn't mean that code worked on my machine with Perl, I wanted to ask you if it does on your. I will try to reproduce it here then (will need to install Perl again as I've got a new machine ) and give you an update.
Best regards,
Daniel, iOpus Support
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Meir,
This code (a modified version of the script you once posted) works and returns correct value:
Could you please try it with this macro:
Best regards,
This code (a modified version of the script you once posted) works and returns correct value:
Code: Select all
use strict;
use Win32::OLE;
print "Just started\n";
my $b = Win32::OLE->new("imacros") or die "iMacros Browser could not be started by Win32:OLE\n";
$b->{Visible} = 1;
print "After invoking the OLE\n";
sleep 10;
# Start the iMacros Browser - Use iimInit("-ie"/"-fx") to start iMacros for IE/Firefox instead.
$b->iimInit("-fx");
print "After iimInit\n";
sleep 10;
my $macro = 'C:\\Users\\Daniel\\Documents\\Client Scripts\\Perl\\iim.iim';
print "\$macro = $macro\n";
$b->iimPlay($macro);
print "After 'playing' the iMacro\n";
sleep 10;
print $b->iimGetLastError();
$b->iimExit();
Code: Select all
URL GOTO=http://www.google.com
TAG POS=1 TYPE=A ATTR=TXT:ahdkjsahdjahs
URL GOTO=http://www.google.com
Daniel, iOpus Support
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hello, hello Daniel!
Hurray! Congratulations, it is working!
But now, please tell me what was changed??? For the life of me, I couldn't see any material difference to the original post.
Or did iMacro change? I am not aware of any upgrade to iMacro lately. Or is it silently upgraded?
Please enlighten,
Hurray! Congratulations, it is working!
But now, please tell me what was changed??? For the life of me, I couldn't see any material difference to the original post.
Or did iMacro change? I am not aware of any upgrade to iMacro lately. Or is it silently upgraded?
Please enlighten,
Regards,
Meir
Meir
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Meir,
No there were no updates to iMacros
See, my knowledge of Perl is quite limited, so I don't really know what was wrong with
It seems to be absolutely fine... May be something with operator precedence? I don't think so... I just simplified it as much as I could and... it worked...
No there were no updates to iMacros
See, my knowledge of Perl is quite limited, so I don't really know what was wrong with
Code: Select all
sub err {
$lastMessage = $b->iimGetLastErrorMessage();
if ($lastMessage =~ /Macro completed/) {
print("Success <$macro> $lastMessage\n");
#write a logger here for Success $lastMessage
}
else{
print("Failure <$macro> $lastMessage\n");
#write a logger here for Failure $lastMessage
}
}
Daniel, iOpus Support
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Daniel!
That's odd! I simplified it long ago. In fact, I looked at the original code deposited in my very first post and the sub() part was already commented out. So, as I said, for the life of me I cannot explain it...
Well, at least it works!
Thanks Daniel!
That's odd! I simplified it long ago. In fact, I looked at the original code deposited in my very first post and the sub() part was already commented out. So, as I said, for the life of me I cannot explain it...
Well, at least it works!
Thanks Daniel!
Regards,
Meir
Meir
-
- Posts: 1483
- Joined: Tue Jan 26, 2010 11:35 am
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Hi Meir,
May be I will investigate more when I have some time to play with Perl But for now I would leave it... working
Best wishes!
May be I will investigate more when I have some time to play with Perl But for now I would leave it... working
Best wishes!
Daniel, iOpus Support
-
- Posts: 1
- Joined: Sun Jun 20, 2010 5:47 pm
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Not sure if this was answered yet - but in your original post you had "iimGetLastErrorMessage" - and in the code that worked, it was just "iimGetLastError"
Matt
Matt
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
Dear Matt,
Well, not exactly answered yet. What I use now is to get the result code in $play_iret. But it often gives very little information. Basically, if it finished OK ($play_iret == 1) or not. If it didn't, I have very little to go on.
For example, I often get a -971 error code but I couldn't find any explanation as what might cause it.
Well, not exactly answered yet. What I use now is
Code: Select all
$play_iret = $b->iimPlay($macro_name, 60)
For example, I often get a -971 error code but I couldn't find any explanation as what might cause it.
Regards,
Meir
Meir
Re: PERL $b->iimGetLastErrorMessage() method returns "undef"
From the Wiki Reference http://wiki.imacros.net/Command_Referen ... d_Overview it's actually iimGetErrorText() while iimGetLastError() seems to be old (obviously still working). However, the Perl Example on the Wiki still has iimGetLastErrorMessag() which seems to be a typo since the example has been published.
To get the err() function in the example to work - as actually tested with iMacros v12 - validation has to be adapted to check for /^OK/ instead of /Macro completed/.
To make the long story short, here is a fixed sub err () with the 2 wrong lines commented out (the fixed entire script is attached):
To get the err() function in the example to work - as actually tested with iMacros v12 - validation has to be adapted to check for /^OK/ instead of /Macro completed/.
To make the long story short, here is a fixed sub err () with the 2 wrong lines commented out (the fixed entire script is attached):
Code: Select all
########################################################################
# Get the last message reported from iMacros upon macro completion status#
########################################################################
sub err {
# $lastMessage = $b->iimGetLastErrorMessage();
$lastMessage = $b->iimGetErrorText();
# if ($lastMessage =~ /Macro completed/) {
if ($lastMessage =~ /^OK/) {
print("Success <$macro> $lastMessage\n");
#write a logger here for Success $lastMessage
}
else{
print("Failure <$macro> $lastMessage\n");
#write a logger here for Failure $lastMessage
}
}
- Attachments
-
- iMacros_Perl_Example_fixed.zip
- Fixed Error Handling for Perl Example
- (824 Bytes) Downloaded 358 times