[ic] Usertag return value

Grant emailgrant at gmail.com
Fri Feb 13 02:52:46 UTC 2009


>>> $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.

- Grant

> It seems to me you're trying to assign '$return' the value of 'return 0'
> in the case of failure. But 'return' can't be assigned to an lvalue,
> AFAIK. Even if it could, as soon as 'return 0' is called '$return' would
> go out of scope and you wouldn't be able to access it anyway.
>
> If you want to use '$return' then you could write it like this:
>
> $return
>   = $image->Write(filename=>'/file/location/'.$name.'_image.jpg');
> return $return if ! $return;
>
> $return
>   = chmod(0644,"/file/location/".$name."_image.jpg");
> return $return if ! $return;
>
> jimbo
> ;-)



More information about the interchange-users mailing list