Thunderstone Software Document Search, Retrieval, and Management
Search:
Vortex Manual
 

Function Parameters

 

Script functions can be declared with parameters, which are passed to the function when it is called. Parameters are declared by naming them in the <A NAME> declaration tag, after the NAME attribute and any scope attribute (PUBLIC/PRIVATE etc.) . Each parameter is a local variable (here) inside the function:

<A NAME=banner title="Untitled" bg>
  <HEAD>
    <TITLE>$title</TITLE>
  </HEAD>
  <BODY BGCOLOR=$bg>
  <CENTER>
    <H2>$title</H2>
  </CENTER>
</A>

This function has two parameters, $title and $bg. When the function is called, its arguments are named in the tag (like HTML attributes):

  <banner title="Search Results" bg=white>

Since the arguments are named, they need not be given in order (like HTML). Nor are all parameters required: the $title parameter was declared with a default value of "Untitled", so it will have that value if unspecified in a call:

  <banner bg=white>

Parameters without default values (e.g. $bg) are required, however. This provides the ability to force their setting in situations where a default value might not be useful. For example, a search-and-replace type function could require its search and buffer parameters: it may not be sensible to search a default buffer.

The default value for a parameter can also be a variable:

<A NAME=banner title=$DefaultTitle bg>
  ...
</A>

In this case, if $title is not specified in a call, it will have the value of the global (never local) variable $DefaultTitle.


Copyright © Thunderstone Software     Last updated: Mon Feb 18 10:28:15 EST 2013
 
Home   ::   Products   ::   Solutions   ::   How to Buy   ::   Support   ::   Contact Us   ::   News   ::   About
Copyright © 2013 Thunderstone Software LLC. All rights reserved.