[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Chains Package

The SparForte built-in exceptions package provides subprograms to provide information about chains. Use this to determine if your procedure is in a chain, which call is this in the chain, or how many times your procedure has been called in the chain. This package currently only applies to user-defined procedures.

Introduced: SparForte 1.5

GCC Ada Equivalent: N/A (AdaScript extension)

This package includes an enumerated type, chains.context:

  • chains.context_first - this is the first call in the chain
  • chains.context_middle - this is neither the first nor last call in the chain
  • chains.context_last - this is the second call in the chain
  • chains.not_in_chain - this is not in a chain

A procedure is in a chain if it was called from a chain. Declare blocks will not change the results. If the procedure calls a second procedure, the second procedure is not in a chain.

For example,

my_proc( "A" ); my_proc( "B" ) @ ( "C" ) @ ( "D" );

Call chains.in_chain chains.chain_count chains.chain_context
my_proc( "A" ) false exception chains.not_in_chain
my_proc( "B" ) true 1 chains.context_first
my_proc( "C" ) true 2 chains.context_middle
my_proc( "D" ) true 3 chains.context_last
  p := chains.chain_count        e := chains.chain_context
  b := chains.in_chain
 
Help Command: Contents of the chains package

p := chains.chain_count

 

Return the ordinal position of this call in the chain. The first call is 1.

Example

pos := chains.chain_count

Parameters

Param Mode Type Default Description
p return value positive required the position in the chain

Exceptions

An exception is thrown if this is not in a chain

See Also

-

Compare With

-

Implementation Note

This currently only works for built-in procedure chains.

e := chains.chain_context

 

Return the relative position of the call in the chain, whether first, last or in the middle. This is useful when combined with a case statement to handle initialization or finalization for the chain.

Example

name := exceptions.exception_name

Parameters

Param Mode Type Default Description
e return value chains.context required the relative position of the call

Exceptions

-

See Also

-

Compare With

Ada: Ada.Exceptions.Exception_Name
PHP: N/A

Implementation Note

This currently only works for built-in procedure chains.

b := chains.in_chain

 

Return true if this procedure is part of a chain. It is equivalent to chains.chain_context /= chains.not_in_chain

Example

if chains.in_chain then ...

Parameters

Param Mode Type Default Description
b return value boolean required true if in a chain

Exceptions

-

See Also

-

Compare With

Ada: N/A (AdaScript extension)
PHP: N/A

 
[Right Submenu]

 Summary

 arrays

 btree_io

 calendar

 cgi

 chains

 command_line

 db/ postgresql

 dbm

 directory_operations

 doubly_linked...

 dynamic_hash_...

 enums

 exceptions

 files

 gnat.cgi

 gnat.crc32

 hash_io

 lock_files

 memcache

 memcache.highread

 mysql

 mysqlm

 numerics

 os

 pen

 pen (OpenGL)

 records

 sound

 source_info

 stats

 strings

 System

 teams

 templates

 text_io

 units

[Back to Top] Back To Top [Small Forte Symbol]