Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Variable-Length Fields

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

  • Variable-Length Fields

    ** This thread discusses the article: Variable-Length Fields **
    ** This thread discusses the Content article: Variable-Length Fields **
    0

  • #2
    Variable-Length Fields

    ** This thread discusses the article: Variable-Length Fields **
    Overall, I'd like to echo Bob's encouragement to use varying length character variables whenever possible. I'd just like to offer some clarifications to a couple of points: First, be careful using varying length variables in the traditional fixed form opcodes like MOVE, MOVEL, SUBST, etc. A subtle issue of varying length semantics is that a character varying variable used in a fixed-format calc behaves exactly like a fixed length variable declared with the current length. For example, if you move a string to a character varying variable using MOVE, and the target has a current length of say 10, the operation will move the source right-adjusted into those 10 characters, with the left-most characters unchanged if the source is shorter. That is, the length of a character varying variable does not change when coded as the result field in a fixed-form, non-expression calc. On the other hand, varying length variables within expressions behave pretty much as you'd expect. Second, under the section "How Long Is It?", note that comparing %LEN(STR) to 0 is not the same as comparing STR to '' (the null string). In character comparisons in RPG, the shorter operand is padded with blanks. And so the null string compares equal to a variable holding a string of blanks. Cheers! Hans

    Comment


    • #3
      Variable-Length Fields

      ** This thread discusses the article: Variable-Length Fields **
      Thank you for the the illuminating article! Are there any "gotchas" when using variable length fields in a database file? For example, saving and restoring? And once a variable length database field has been read in by an RPG program, does it behave in the same way as a "varying" field? Regards, Chris

      Comment


      • #4
        Variable-Length Fields

        ** This thread discusses the article: Variable-Length Fields **
        Be aware also of passing VARYING vars to CLP or CLLE pgm. You will get the length word (2 bytes) into the string parm. Maybe I did something wrong but thats I got.

        Comment


        • #5
          Variable-Length Fields

          ** This thread discusses the article: Variable-Length Fields **
          Perhaps the reason that varying length fields are used with infreaquency, is that there are also reasons for not using them! Dave

          Comment


          • #6
            Variable-Length Fields

            ** This thread discusses the article: Variable-Length Fields **
            If I have a subprocedure (function) that needs to process a varying length field and return a varying length field of the same size. Basically just manipulate the value without changing the length. How do I describe the prototype parameter, with Varying or with Options(*Varsize)? Likewise, would the procedure interface be exactly the same? Thanks, Erick

            Comment

            Working...
            X