This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tutorials:faq:main [2020/10/19 21:20] miconda |
tutorials:faq:main [2021/04/03 13:18] s.safarov_gmail.com |
||
---|---|---|---|
Line 615: | Line 615: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | To compare the return code of a function with a number is recommended to use the value stored in $rc, because the priority of the operators can convert function return code to internal-true or internal-false. Therefore the next approach should be used: | ||
+ | |||
+ | <code c> | ||
+ | function_returns_four(); | ||
+ | $var(rc4) = $rc; | ||
+ | if($var(rc4)==4) { | ||
+ | # it goes here | ||
+ | } else { | ||
+ | # it doesn' | ||
+ | } | ||
+ | ... | ||
+ | function_returns_two(); | ||
+ | $var(rc2) = $rc; | ||
+ | if($var(rc4)==$var(rc2)) { | ||
+ | # it doesn' | ||
+ | } else { | ||
+ | # it goes here | ||
+ | } | ||
+ | ... | ||
+ | if (function_returns_four() && $rc ieq 6 ) { | ||
+ | # it doesn' | ||
+ | } else if ($rc ieq 4) { | ||
+ | # it goes here | ||
+ | } else { | ||
+ | # it doesn' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Note that $rc is overwritten by a new function call, therefore store its value in another variable (like $var(...)) if it is needed for longer time. | ||
For pseudo-variables, | For pseudo-variables, |