api:else

Version 23.0.9145


api:else


Use the api:else keyword to execute an alternate block of code when a test like api:exists or api:match fails. You can also use it 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 that the api:else statement be within the scope of the test it belongs to.

Parameters

None

Control Attributes

None

Example

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