set dest = “$arg1”
set field = “$arg2”
set label = argx($field,-1,".")
if ( $label == $field ) then
set label = “”
else
set field = substr($field,0,strlen($field)-strlen($label)-1)
endif
set totparms = `tabrc(“$dest/MAPPER”,“$field”,“NPARMS”)
for cp = 1 to $totparms
set doit = 1
echo A - label $label
if ( strcmp("$label", "") != 0 ) then
set curlabel = tabrc("$dest/MAPPER","$field","L$cp")
echo A.1
if ( strcmp("$label", $curlabel) ) then
set doit = 0
endif
echo A.2
endif
echo B
if ( $doit ) then
table -r “$field” -c “V$cp” $dest/MAPPER “.!”
endif
end
here’s the output when it’s called a few times:
A - label x
A.1
A.2
B
A - label x
A.1
A.2
B
A - label
/GLOBAL/SCRIPTS/CMD/UI_BLOCK_PARM (Line 31) Expression error: Undefined variable
B
A - label
/GLOBAL/SCRIPTS/CMD/UI_BLOCK_PARM (Line 31) Expression error: Undefined variable
B
A - label
/GLOBAL/SCRIPTS/CMD/UI_BLOCK_PARM (Line 31) Expression error: Undefined variable
B
A - label
/GLOBAL/SCRIPTS/CMD/UI_BLOCK_PARM (Line 31) Expression error: Undefined variable
B
you can see how when label is empty, the line:
if ( strcmp("$label", $curlabel) ) then
is still parsed and generates an error, even though it’s inside an if statement that should be skipped (and it is, since no echo A.1 A.2 are happening)
btw, as a possible side bug, I’m using strcmp because the syntax
if ( $label != $curlabel ) then
generates a syntax error.
maybe I’ve done something wrong in the script that I can’t see?
d
It’s annoying, often I have to use a weird workflow, like putting “continue” commands everywhere when mixing for, foreach and if() statements to get rid of those erros. And it’s eating away unnecessary ressources.
hello, I’ve got a solution to one of the if problems. in the next build, you can use
a parse command
parse -i 1
to turn of parsing for if blocks that are not execute. for now, we are still testing this,
so the default is off. but we may switch it to on sometime.
I haven’t dug too deep at the if expressions if ( $a, 1, 0) and ifs($a, "true", false"),
but will keep you guys posted on my progress.