Tcl Database Fixed-Point Number API

The Tcl database fixed-point number API module has the file name dbfxp.tcl. This module provides the programmer with a callable API that will store or retrieve database fields, subfields or subsubfields containing fixed-point numbers.

The fixed-point numbers are stored in database fields, subfields or subsubfields without the decimal point. The application designer must decide and keep track of where the decimal is placed. This is referred to in this document as the scale.

Each procedure requires a tid as the first parameter.

Here is a list of procedures in this module:

- dbfxp_get
- dbfxp_put
- dbfxp_get_subfield
- dbfxp_put_subfield
- dbfxp_get_subsubfield
- dbfxp_put_subsubfield

# Module Dependencies

This module requires the following modules:

- either the complete single user database suite or the complete client/server database suite
- fixed-point number API

# Module Definition Files

The following modules are required along with this module:

- stdhead.tcl
- dbmess.tcl

# Module Procedures

## dbfxp_get

    Declaration   :  proc dbfxp_get {tid field_no sc fxp_list_out}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : positive integer
    Description   : field number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list_out
          Type    : list
    Description   : returned fixed-point number

    Returns       : dbeng code

This procedure will obtain the field contents from the tid table, in the field number field. The field contents will be used to create a fixed-point number with the decimal located in the precision or scale of number position (from the right). Procedure returns an fxp list upon success. The field contents must be a number (0-9,-) without any decimal point.

## dbfxp_put

    Declaration   :  proc dbfxp_put {tid field_no sc fxp_list}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : integer
    Description   : field number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list
          Type    : list
    Description   : fixed-point number

    Returns       : dbeng code

This procedure will write a fixed-point number to a database field. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the field contents. The field number parameter may be zero to indicate an append to the record.

## dbfxp_get_subfield

    Declaration   :  proc dbfxp_get_subfield {tid field_no sf sc fxp_list_out}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : positive integer
    Description   : field number

          Name    : sf
          Type    : positive integer
    Description   : subfield number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list_out
          Type    : list
    Description   : returned fixed-point number

    Returns       : dbeng code

This procedure will obtain subfield contents from the tid table in the field number and subfield number. The subfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Procedure returns an fxp list upon success. The subfield contents must be a number (0-9,-) without any decimal point.

## dbfxp_put_subfield

    Declaration   :  proc dbfxp_put_subfield {tid field_no sf sc fxp_list}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : integer
    Description   : field number

          Name    : sf
          Type    : integer
    Description   : subfield number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list
          Type    : list
    Description   : fixed-point number

    Returns       : dbeng code

This procedure will write a fixed-point number to a database subfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subfield contents. The field number and/or the subfield number parameter may be zero to indicate an append to the record.

## dbfxp_get_subsubfield

    Declaration   :  proc dbfxp_get_subsubfield {tid field_no sf ssf sc fxp_list_ot}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : positive integer
    Description   : field number

          Name    : sf
          Type    : positive integer
    Description   : subfield number

          Name    : ssf
          Type    : positive integer
    Description   : subsubfield number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list_ot
          Type    : list
    Description   : returned fixed-point number

    Returns       : dbeng code

This procedure will obtain subsubfield contents from the tid table in the field number, subfield number and subsubfield number. The subsubfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Procedure returns an fxp list upon success. The subsubfield contents must be a number (0-9,-) without any decimal point.

## dbfxp_put_subsubfield

    Declaration   :  proc dbfxp_put_subsubfield {tid field_no sf ssf sc fxp_list}
    Parameters    :
          Name    : tid
          Type    : positive integer
    Description   : tid

          Name    : field_no
          Type    : integer
    Description   : field number

          Name    : sf
          Type    : integer
    Description   : subfield number

          Name    : ssf
          Type    : integer
    Description   : subsubfield number

          Name    : sc
          Type    : integer
    Description   : precision or scale of number

          Name    : fxp_list
          Type    : list
    Description   : fixed-point number

    Returns       : dbeng code

This procedure will write a fixed-point number to a database subsubfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subsubfield contents. The field number and/or subfield number and/or subsubfield number parameter may be zero to indicate an append to the record.

Goto Top | Tcl Database Engine and API's | Tcl Applications | Tcl Software Overview | Tcl Library Overview
| Future Lab Home | Contact Webmaster | Feedback

Copyright © 2006 Future Lab, Last Updated Jul 01, 2006