ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

*LOVAL Sets Field to '?????????'

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

  • *LOVAL Sets Field to '?????????'

    Is this expected behaviour that *LOVAL sets FLD25 = '?????????????????????????'
    Before and after the SETLL ?
    File LOVALPF has 1 record and 1 field defined as key.

    Code:
    C                   MOVE      *BLANKS       FLD25            25      
    C                   MOVE      *LOVAL        FLD25                    
    C     *LOVAL        SETLL     LOVALPF                                
    C                   MOVE      *LOVAL        FLD25                    
    C                   SETON                                        LR  
    C                   RETURN                                            ​
    Last edited by MFisher; October 12, 2022, 01:26 PM.

  • #2
    *LOVAL puts the lowest possible value into a field. In your case, you have a CHAR(25) field, so the lowest possible value is to fill it with nothing but hexidecimal zeroes. (x'0000000000')

    Since hex zeroes are not printable characters, your 5250 emulator prints it as ?????

    Comment


    • #3
      If you want to position the file at the first record, use SETLL *START instead of SETLL *LOVAL.

      Comment


      • #4
        Originally posted by MFisher View Post
        Is this expected behaviour that *LOVAL sets FLD25 = '?????????????????????????'
        Before and after the SETLL ?
        File LOVALPF has 1 record and 1 field defined as key.

        Code:
        C MOVE *BLANKS FLD25 25
        C MOVE *LOVAL FLD25
        C *LOVAL SETLL LOVALPF
        C MOVE *LOVAL FLD25
        C SETON LR
        C RETURN ​
        As Barbara rightly said, *loval is the smallest possible value for a given type of variable. For char this will be x'00' - in strdbg you can see this (in hex) with

        Code:
        eval fld25:x 25
        By itself, your code does not make sense. setll does not read any record from the file, it only positions the cursor before the desired record (in this case, before the first record, with the minimum key value). To get a record, you need to do

        Code:
        read lovalpf
        after setll - after that the record fields will be filled with real values.​

        Comment


        • #5
          Thanks for the explanations.
          My code was just a junk program looking at LOVAL, not meant to do anything.
          A co-worker debugging another program noticed the '?????" so I was curious about it.

          Comment


          • #6
            Originally posted by MFisher View Post
            Thanks for the explanations.
            My code was just a junk program looking at LOVAL, not meant to do anything.
            A co-worker debugging another program noticed the '?????" so I was curious about it.
            Using ? the debugger displays any non-printable characters. To see the real content, you need to look in hex format, as I showed above.

            Comment

            Working...
            X