|
|
isempty
| Format:
isempty ( value ) |
Purpose:
Checks whether the value being tested is empty.
Return Values:
A value is empty if:
- it is a variable or object (field) and is not declared
- it is the null value
- it is a string which contains only spaces
- it is an empty string (a string of length 0)
- it is an object containing no fields
If one of the conditions is fulfilled, isempty() returns true, otherwise false.
Example:
| heitml input: | resulting output:
|
| <? isempty(ff.notdef)>
| true
| | <? isempty(null)>
| true
| | <? isempty(" ")>
| true
| | <? isempty("")>
| true
| | <? isempty(emptytuple)>
| true
| | <? isempty(5)>
| false
| | <? isempty(3.1415)>
| false
| | <? isempty(true)>
| false
| | <? isempty(false)>
| false
|
Tip:
The isempty() function should prove useful when you need to process user input from an HTML form. In most forms, there are some fields that can be left blank, and others that are required.
Example:
heitml input:
<if isempty(ZipCode)
> You <b>must</b> specify a Zip Code before
we can process your order. <
else
if len(ZipCode)!=5
> A Zip Code <b>must</b> be 5 digits long! <
else
if real(ZipCode)==null;
? ZipCode
> is <b>not</b> a legal Zip Code. <
/if;
/if;
/if>
| resulting output:
You must specify a Zip Code before
we can process your order.
|
Notice in the above example that we first made sure the ZipCode variable had a value assigned to it before doing any further validation checks. Had we omitted this test, heitml would have generated an error message when it tried to determine the length of a variable that had not previously been declared. Also note that our validation checks assume that we are using a five digit Zip Code instead of the newer Zip+4 format, which is why we tested for a length of 5 with the len() function. And, of course, U.S. Zip Codes contain only numbers, so if a User had entered something like "x0321", our real() function would not have been able to convert the string of characters contained within ZipCode to a numeric value. In both cases our program would have recognized that an invalid Zip Code had been entered and printed the appropriate message.
See Also:
isdecl().
This page was dynamically generated by
heitml
© 1996-2009 H.E.I. All Rights Reserved
|