What I am trying to do is to split the input file into two outputs based on the value of “Earning_col_31”. The Metadata of the input and output is exactly the same. I have the following code and I am getting the error `Cannot convert ‘string’ to ‘boolean’` next the last line of the code:
function integer transform() {
$out.0.* = $in.0.*;
$out.1.* = $in.0.*;
if ($out.0.Earning_col_31 = "401KMEM") return 1; else return 0;
}
Any idea what I possibly did wrong?
Hi yichuansancun,
Problem is in your if-statement using assignment operator “=”:
if ($out.0.Earning_col_31 = "401KMEM")
Which means store “401KMEM” into $out.0.Earning_col_31. So that produces string, but if-statement requires bool.
Please fix it to equality operator “==”:
if ($out.0.Earning_col_31 == "401KMEM")
I hope this helps.
Thanks!!! I will try that
Hi again,
This time, I am getting error “Unreachable code”
$out.0.* = $in.0.*;
if($out.0.MilitaryStatusName == "not found") return 1; else return 0;
Do you have any other return statement in this specific CTL code? Or any other code after the return statements? This would explain the error message. If not, send me the whole CTL code please for me to better localize the issue.
Thanks.
I had
return all
at the end of the function, which caused issue. I removed it and now it worked, thanks!