Is Defined and Is Visible tests: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 42: Line 42:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>fld
<tr><th>fld
</th><td>The name of a field, or a fieldname variable (%%var) containing the name of a field.
</th><td>The name of a field, or a <var class="product">User Language</var> fieldname variable (<code>%%var</code>) containing the name of a field.
</td></tr>
</td></tr>
<tr><th><var>Is Defined</var>
<tr><th><var>Is Defined</var>
</th><td>This test returns the value <code>1</code> if the field is defined in the current file (as given by the <var>$CurFile</var> function); otherwise it returns the value <code>0</code>.
</th><td>This test returns the value <code>1</code> if the field is defined in the current file (as given by the <var>$CurFile</var> function); otherwise it returns the value <code>0</code>.
</td></tr>
</td></tr>
<tr><th><var>Is Not Defined</var>
<tr><th nowrap="true"><var>Is Not Defined</var>
</th><td>This test returns the value <code>0</code> if the same <var>Is Defined</var> test would return <code>1</code>, and it returns the value <code>1</code> if <var>Is Defined</var> would return <code>0</code>.
</th><td>This test returns the value <code>0</code> if the same <var>Is Defined</var> test would return <code>1</code>, and it returns the value <code>1</code> if <var>Is Defined</var> would return <code>0</code>.
</td></tr>
</td></tr>
<tr><th><var>Is Visible</var>
<tr><th><var>Is Visible</var>
</th><td>This test returns the value <code>1</code> if the field is defined in the current file (as given by the $CurFile function) and does not have the <var>INVISIBLE</var> field attribute in that file; otherwise it returns the value <code>0</code>.
</th><td>This test returns the value <code>1</code> if the field is defined in the current file (as given by the <var>$CurFile</var> function) and does not have the <var>INVISIBLE</var> field attribute in that file; otherwise it returns the value <code>0</code>.
</td></tr>
</td></tr>
<tr><th><var>Is Not Visible</var>
<tr><th><var>Is Not Visible</var>
Line 67: Line 67:
This cancellation is consistent with the handling of fieldname variables
This cancellation is consistent with the handling of fieldname variables
throughout <var class="product">User Language</var>, and it has nothing to do with the request cancellation
throughout <var class="product">User Language</var>, and it has nothing to do with the request cancellation
introduced for <var class="product">Janus SOAP ULI</var>]] protection against nonsensical field references
introduced for <var class="product">Janus SOAP ULI</var> protection against nonsensical field references
([[File classes#Request cancelled if group field reference is nonsensical for file|"Request cancelled if group field reference is nonsensical for file"]]).
([[File classes#Request cancelled if group field reference is nonsensical for file|"Request cancelled if group field reference is nonsensical for file"]]).


[[Category: User Language syntax enhancements]]
[[Category: User Language syntax enhancements]]

Revision as of 23:42, 6 September 2011

Two forms of tests (and their negations) are new as of Sirius Mods version 7.0 for any field in a Model 204 file.

The tests are useful for User Language code which is (or may be) in the context of a Model 204 group (of files) when that code contains field references that may be nonsensical in one or more members of the group. An example of a nonsensical reference is a reference to a field that is missing in one file in the group yet defined in at least one other group member.

If working with Janus SOAP ULI File class objects, the Defined and Visible tests let you bracket field accesses (and certain updating statements) in group context if the rules described in "Request cancelled if group field reference is nonsensical for file" would cause undesirable request cancellation.

Examples of the tests are shown below with If blocks:

If GRPFLD1 Is Defined Then Add GRPFLD1 = %val End If If GRPFLD2 Is Visible Then Delete GRPFLD2 End If

The tests can be used wherever User Language tests can be made, which is, loosely speaking, as a User Language expression (not including the Print/Audit statement, nor "values" in the Find and field update statements). Typically, however, the tests will be used in the If, ElseIf, and Repeat statements.

These tests, like the Is Present test, can only be used in a record context, such as a For Each Record loop. The syntax is:

fld Is [Not] Defined fld Is [Not] Visible

Where:

fld The name of a field, or a User Language fieldname variable (%%var) containing the name of a field.
Is Defined This test returns the value 1 if the field is defined in the current file (as given by the $CurFile function); otherwise it returns the value 0.
Is Not Defined This test returns the value 0 if the same Is Defined test would return 1, and it returns the value 1 if Is Defined would return 0.
Is Visible This test returns the value 1 if the field is defined in the current file (as given by the $CurFile function) and does not have the INVISIBLE field attribute in that file; otherwise it returns the value 0.
Is Not Visible This test returns the value 0 if the same Is Visible test would return 1, and it returns the value 1 if Is Visible would return 0.

See "Using Is Defined and Is Visible to avoid cancellation" for more examples of the use of Is Defined and Is Visible.


Note: If a fieldname variable is used in any of the above tests, and it contains a string that is not defined in the current file (nor in any member of the current group, if the reference is in group context), the request is cancelled. This cancellation is consistent with the handling of fieldname variables throughout User Language, and it has nothing to do with the request cancellation introduced for Janus SOAP ULI protection against nonsensical field references ("Request cancelled if group field reference is nonsensical for file").