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:

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:

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 the web application development tool RADpage of H.E.I.
© 1996-2017 H.E.I. All Rights Reserved.



Homepage
Intro/Features
Component Guide
Programming
  Language Guide
  Language Ref.
    General Design
    Lexical Structure
    Expressions
    Objects
    Methods
    Classes
    heitml Tags
    heitml Functions
      ArAppend
      ArConcat
      ArSearch
      array
      asc
      caltime
      chr
      class
      clone
      contains
      ContainsCase
      copy
      copyfile
      crypt
      _dbcolumns
      _dbforeignkey
      _dbprimarykey
      _dbtables
      _dbtypes
      default
      deletefile
      difftime
      directory
      findex
      flush
      fname
      gmtime
      htmlbool
      http_content_type
      http_empty_document
      http_expires
      http_header
      http_last_modified
      http_location
      http_set_cookie
      http_request_header
      _includefilepreprocessed
      index
      IndexCase
      integer
      isbool
      isdecl
      isempty
      isinteger
      isnull
      isstring
      istuple
      isreal
      left
      len
      localtime
      MD5
      mkdir
      mktime
      movefile
      offstotabcol
      random
      readFileLines
      _readini
      _readodbcdrv
      _readodbcdsn
      real
      resize
      right
      _serverdocroot
      _shelltemp
      srandom
      splitstring
      stat
      strftime
      strptime
      subst
      substall
      substring
      tabcoltooffs
      tolower
      toupper
      trim
      trimleft
      trimright
      TuAppField
      TuAssField
      TuAssign
      TuSlice
      TuDelField
      TuFieldSort
      TuInsField
      TuMerge
      TuName
      TuProject
      utime
      _writeini
    Advanced Functions
    Database Access
    Global Variables
    Form Fields
    Server Variables
    Sessions
    heitml Syntax
  Component Ref.
  Class Library
  User Components
  Tryout Form
  Tutorial
  New Features
  heitml 1
User Guide
FAQ
Mailinglist
Discussion Group
Services
Pricing/Register
Download
Frame
 
Contact
 
 
 
Search: