ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

When is clear not clear?

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

  • When is clear not clear?

    Just found a good one today. Apparently the clear opcode won't clear a record format if the file is defined as an input file. This in itself is fine but the compiler only issues you a severity 00 warning that it won't really clear the fields.

    Foolishly I assumed that it would do as it's told if it compiled.

    Wonders never cease!
    Ben

  • #2
    Re: When is clear not clear?

    Only Update or Output file formats can be cleared directly. Input files are assumed to be unchangable. (This worked in this way as long as I remember even in RPGIII).

    If you need to clear an input file's record format, just define an unqualified external data structure for the input file and clear this external data structure ... and voila your input record is cleared.

    Birgitta

    Comment


    • #3
      Re: When is clear not clear?

      Hi

      If record is not defined for update/output use:
      C CLEAR *ALL RecName
      LP Zdenko

      Comment


      • #4
        Re: When is clear not clear?

        This opcode should be used with care when clearing non-databa file type records. When clearing a display or printfile record, the indicators, and not only the fields, are also cleared.
        Regards

        Kit
        http://www.ecofitonline.com
        DeskfIT - ChangefIT - XrefIT
        ___________________________________
        There are only 3 kinds of people -
        Those that can count and those that can't.

        Comment


        • #5
          Re: When is clear not clear?

          We've already fixed it with Birgitta's solution. I got one of my bosses to take a look and he spotted my mistake. It just surprised me that the compiler let's you get away with writing rubbish so I thought I would share it.

          I don't know where you're supposed to acquire information like this? I haven't come from an RPG III background. I started straight on ILE free format subprocedures. I learnt a bit on a course I took in the first month of joining and the rest I've picked up from colleagues, Cozzi's book or pressing F1 in WSDC. If I do that now to look at the clear opcode this is what I get:

          The CLEAR operation sets elements in a structure (record format, data structure, array, or table) or a variable (field, subfield, array element or indicator), to their default initialization value depending on field type (numeric, character, graphic, UCS-2, indicator, pointer, or date/time/timestamp). For the default initialization value for a data type, see Data Types and Data Formats.

          Fully qualified names may be specified as the Result-Field operand for CLEAR when coded in free-form calculation specifications. If the structure or variable being cleared is variable-length, its length changes to 0. The CLEAR operation allows you to clear structures on a global basis, as well as element by element, during run time.
          The manual always seems to follow this format of telling you the basics but missing out the crucial gotcha's. It's only by speaking to my colleagues that I learn these side notes. The only other language I've come across like this is C which should tell you everything...
          Ben

          Comment


          • #6
            Re: When is clear not clear?

            Originally posted by kitvb1 View Post
            This opcode should be used with care when clearing non-databa file type records. When clearing a display or printfile record, the indicators, and not only the fields, are also cleared.
            What's a "non-databa" file type record?

            Comment


            • #7
              Re: When is clear not clear?

              Originally posted by FaStOnE View Post
              What's a "non-databa" file type record?

              What about Display File or Printer File Format ?

              Birgitta

              Comment


              • #8
                Re: When is clear not clear?

                typo ---> ... non-database file type records...

                and if you misbehave any further... I'm gonna go there and open up a can of whoop-@#%@#%@#% on ya!!

                Don' ya go messin' wit me now, ya hear...
                I'm still one bad-@#%@#%@#% mofo... tomorrow is 2 months!!
                Last edited by kitvb1; May 11, 2010, 08:28 AM.
                Regards

                Kit
                http://www.ecofitonline.com
                DeskfIT - ChangefIT - XrefIT
                ___________________________________
                There are only 3 kinds of people -
                Those that can count and those that can't.

                Comment


                • #9
                  Re: When is clear not clear?

                  Dang kit you need to calm yourself down there........go have a smoke or something
                  GLS
                  The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                  Comment


                  • #10
                    Re: When is clear not clear?

                    Ya know .. for someone that spent only a few days in Texas, you sure are becoming a Red Neck! LOLOL

                    Comment


                    • #11
                      Re: When is clear not clear?

                      I've been nailed on this one also and have learned to code according. But I agree: it should clear the fields even if it's input only -- that's what your quoted definition of the operation says it does.
                      http://www.linkedin.com/in/chippermiller

                      Comment

                      Working...
                      X