api:else

Version 22.0.8500


api:else

Version 22.0.8500


The api:else keyword is used to execute an alternate block of code when a test like api:exists or api:match fails. It can also be used to execute an alternate block of code within an api:call when the call fails to produce any output items.

Unlike other languages APIScript requires the api:else statement to be within the scope of the test it belongs to.

Parameters

None

Control Attributes

None

Examples

Return a placeholder title if the file does not have a name:

<api:call op="fileListDir" out="out">
  <api:null attr="filename">
    <api:set attr="title" value="Unnamed File"/>
    <api:else>
      <api:set attr="title" value="[filename]"/>
    </api:else>
  </api:null>
  <api:push title="[title]">
  [out.*]
  </api:push>
</api:call> 

See Also