Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Variable Length Fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variable Length Fields

    Have you tried the DSPFD command? Dave

  • #2
    Variable Length Fields

    When I use this command, I usually look at the bottom for total of member sizes. However, with this file, the total member sizes is much greater than the data space in bytes total. Am I to assume that the data space total is the actual amount of disk space being used by this file, and to ignore the total member sizes? Also, other than within a program, is there any method to determine the exact length of a variable length field? When I use DBU or an SQL command to display the records, I get the maximum field size displayed for these fields. Thanks!

    Comment


    • #3
      Variable Length Fields

      Lee, There is probably a better and more "flexible" way to do it, but this is the code I have in programs that use VARLEN text fields. In the DDS for the file, the field should show a max field length. Then, you define a data structure for the field that splits the length portion from the data portion. See the example below: IATEXT is the varlen field. Make the length on the first line 2 greater than the length in the DDS or SQL description. Write or read the text data to the IATEXTtxt field. Set the length on write, or check the length on read using the IATEXTlen field. You also need the CvtOpt(*VARCHAR) clause on your h-spec line. I thought at some point that the compiler was going to have code to make this definition more automated, but this will work for now. As for the actual size of the record, I can't figure why that would be necessary, unless you were trying to "internally" describe it, which probably wouldn't be a good idea. Other variables get thrown to the mix with varlen fields, such as what your default length is. To get the length of each varlen field, in SQL use "SELECT length(IATEXT) FROM lpdrcdlib/incnaapf" Hope this helps. Thanks, Art
      Code

      Comment


      • #4
        Variable Length Fields

        When using a file with variable length fields, how do you determine the actual length of the record and the actual size of the file? Thanks.

        Comment

        Working...
        X