Module codeload.pkg

     1//************************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright 1987-1995 Data Access Corporation, Miami FL, USA
     5// All Rights reserved
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//************************************************************************
     9
    10//************************************************************************
    11// CodeLoad.pkg   - Code loading data-set
    12// Version: 1.1
    13//  03/18/94 - created
    14//  04/04/94 - modified and made more general
    15// 2/26/2002  JJT - 8.2 clean up (indirect_file, local, self, etc.)
    16//
    17// Author: John J. Tuohy
    18//
    19//
    20// Interface:
    21//
    22//  Procedure Initialize_File Integer File# Integer Index# Integer Code# ;
    23//                            Integer Desc# Integer Type# String Type
    24//
    25//      This initializes the data-set for finding. You MUST pass all five
    26//      parameters here. They are:
    27//          File#  -  main file to use
    28//         Index#  - Index to use for finding
    29//          Code#  - field number of the code
    30//          Desc#  - field number of the code's description
    31//          Type#  - field number of the constraining Type (0 if none)
    32//           Type  - the constrain type value ('' = allow all records)
    33//
    34//      You MUST send this message before finding records. Alternately,
    35//      you could set the individual properties and send rebuild_constraints
    36//      and CLEAR to initalize the file (see code on how to do this).
    37//
    38//    Get Next_Code_record to ret_Int
    39//
    40//      Returns the next record number. 0 if no more. If record exists it
    41//      sets the value of Current_Code and Crnt_Description.
    42//
    43//    Get Current_Code to Ret_String
    44//    Get Crnt_Description to Ret_String
    45//
    46//      Returns the code and description of the last valid record found
    47//      with the Next_Code_Record Message
    48//
    49//   Sample Usage:  This was created primarily to be used by the
    50//                  radio-entry-form classes. In particular those using
    51//                  the "code" look up file. Look at those packages if
    52//                  you wish to use them yourself.
    53//
    54//
    55//
    56//************************************************************************
    57
    58use Data_Set.pkg
    59
    60{ ClassLibrary=Common Visibility=Private }
    61Class Code_Loader_Data_Set is a DataSet
    62
    63  Procedure Construct_Object Integer Img#
    64      Forward Send Construct_Object Img#
    65      // These should be set by the Initialize_File message
    66      { Category=Data }
    67      Property String  Type_Value           '' // assume no defaults.
    68      { Category=Data }
    69      Property Integer Type_Field           0  // These values should be
    70      { Category=Data }
    71      Property Integer Code_Field           0  // set by initialize_file
    72      { Category=Data }
    73      Property Integer Description_Field    0  //
    74
    75      // These are SET by Next_Code_Record. You may GET their values
    76      Property String  Current_Code         ''
    77      Property String  Current_Description  ''
    78  End_Procedure // Construct_Object
    79
    80  // If a Type exists (not a '') and there is a type field and a
    81  // main_file constrain to the type. Else no constraints
    82  Begin_Constraints
    83     String sType
    84     Integer iFile iField
    85     Get Type_Value to sType
    86     Get Main_File  to iFile
    87     Get Type_Field to iField
    88     If (sType<>'' AND iFile<>0 AND iField<>0) ;
    89        VConstrain iFile iField eq sType
    90  End_Constraints
    91
    92  //  This initializes the data-set for finding. You MUST pass all five
    93  //  parameters here. They are:
    94  //     File#  -  main file to use
    95  //    Index#  - Index to use for finding
    96  //     Code#  - field number of the code
    97  //     Desc#  - field number of the code's description
    98  //     Type#  - field number of the constraining Type (0 if none)
    99  //      Type  - the constrain type value ('' = allow all records)
   100  //
   101  Procedure Initialize_File Integer File# Integer Index# Integer Code# ;
   102                            Integer Desc# Integer Type# String Type
   103     // note: all params are required!
   104     Set Main_File         to File#
   105     Set Ordering          to Index#
   106     Set Code_Field        to Code#
   107     Set Description_Field to Desc#
   108     Set Type_Field        to Type#
   109     Set Type_Value        to Type
   110     //
   111     Send Rebuild_Constraints // set up constraints
   112     Send Clear               // initialize the file
   113  End_Procedure
   114
   115  //  Find the next record: Return 0 if no record, 1 if record exists
   116  //   if record exists set Current_Code and Current_Description
   117  //
   118  Function Next_Code_Record Returns boolean
   119     integer iFile iField
   120     string sValue
   121     Send Request_Find GT (Main_File(self)) (Ordering(self))
   122     If not (Found) Function_Return false
   123     // Set properties Current_code and Current_Description
   124     Get Main_File to iFile
   125
   126     Get Code_Field to iField
   127     Get_Field_Value iFile iField to sValue
   128     Set Current_Code to sValue
   129
   130     Get Description_Field to iField
   131     Get_Field_Value iFile iField to sValue
   132     Set Current_Description to sValue
   133     Function_return True
   134  End_Function // Function
   135
   136End_Class
   137