Skip to main content
1-Visitor
July 23, 2014
Question

a couple of different tests of empty

  • July 23, 2014
  • 0 replies
  • 372 views
Sometimes you want to do one thing if an element is empty and another if it
is not. Here are a couple of tests of empty we have used. I'm not sure if
both are still in use in different places, they may be. One looks for and
ignores XML comments and our <remarks> tags which have no output other than
on-screen.


function is_element_empty(win, oid) {
empty = 'yes';
children = oid_children($oid);
for (i = 1; i <= $children; i++) {
if (oid_name(oid_child($oid,$i)) != 'remarks' &&
oid_name(oid_child($oid,$i)) != '_comment') {
empty = 'no';
}
}
return $empty
}

<e-i-c gi="svalue" context="product_name">
<charlist inherit="1">
<savetext textid="product_name-value.txt" conrule="\\">
</charlist>
<att>
<charsubset>
<suppress sup="1">
</charsubset>
</att>
<att>
<specval attname="my_fosi::is_element_empty" attloc="system-func"&lt;br"/>attval="no">
<charsubset>
<savetext textid="product_name-value.txt" conrule="#CONTENT">
<savetext textid="publish-product.txt" conrule="\yes\">
</charsubset>
</att>
</e-i-c>




function is_empty(win, oid) {
empty = 'yes';
$rt = oid_empty($oid);
if ($rt != 1) {empty = 'no'}
return $empty
}


<att>
<specval attname="my_fosi::is_empty" attloc="system-func" attval="no">
<charsubset>
<savetext textid="field_index_row.txt" conrule="\yes\">
<savetext textid="number_fld-value.txt" conrule="#CONTENT">
</charsubset>
</att>
<att>
<specval attname="my_fosi::is_empty" attloc="system-func" attval="yes">
<charsubset>
<savetext textid="field_index_row.txt" conrule="\no\">
</charsubset>
</att>

--
Paul Nagai