[ic] Usertag return value
Greg Hanson
greg at perusion.com
Sat Feb 14 23:36:00 UTC 2009
Grant wrote:
>>>>>>>> $return= $image->Write(filename=>'/file/location/'.$name.'_image.jpg')
>>>>>>>> or return 0;
>>>>>>>> $Tag->log("1: return=$return error=$!");
>>>>>>>> $return= chmod(0644,"/file/location/".$name."_image.jpg") or return 0;
>>>>>>>> $Tag->log("2: return=$return error=$!");
>>>>>>>>
>>>>>> Why not write it like this:
>>>>>>
>>>>>> return 0
>>>>>> if ! $image->Write(filename=>'/file/location/'.$name.'_image.jpg');
>>>>>>
>>>>>> return 0
>>>>>> if ! chmod(0644,"/file/location/".$name."_image.jpg");
>>>>>>
>>>>> I tried this with the same results. The first 3 commands execute, the
>>>>> last 3 commands don't execute, and the usertag exits with '0'. If I
>>>>> remove:
>>>>>
>>>>> return 0
>>>>> if !
>>>>>
>>>>> everything executes, but I don't get the '0' in case of failure.
>>>>>
>>>> So, you want all commands to execute regardless and the tag to return 0
>>>> if any command fails?
>>>>
>>> Thanks Peter, but what I'm after is processing to stop and a return
>>> value of 0 in case a command fails. The usertag executes all the way
>>> through unless I set it up to return 0 in case of failure, in which
>>> case processing stops halfway through. I'd also like any error info
>>> to be printed to the error.log because my app needs a 1 or 0 returned
>>> by the usertag.
>>>
>> Try this then:
>>
>> command1 or do {
>> ::logError "Error running command1: $!";
>> return 0;
>> }
>>
>> command2 or do {
>> ::logError "Error running command2: $!";
>> return 0;
>> }
>>
>> ...
>>
>> commandn or do {
>> ::logError "Error running commandn: $!";
>> return 0;
>> }
>>
>
> This is weird. I changed it to:
>
> command or do {
> ::logError "Error running command: $!";
> return 0;
> };
>
>
try
command or do {
::logError("Error running command: %s" $!);
return 0;
};
> and the tag fails with this in error.log:
>
> Error running command:
>
> If I just use the command without the logging or returning 0 it works perfectly.
>
> - Grant
>
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
> .
>
>
--
Greg Hanson
Interchange Consulting
Perusion
1506 E Gilbert Ave
Coeur d'Alene, ID 83815
Email greg at perusion.com
Phone 208-667-2442
Toll Free 800-949-1889
Fax 775-256-2231
Web http://www.perusion.com
Nothing is fool proof to a sufficiently equipped fool
More information about the interchange-users
mailing list