× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Clear Cmd.
  • From: Dave Mahadevan <mahadevan@xxxxxxxx>
  • Date: Fri, 03 Sep 1999 22:29:52 -0400
  • Organization: Stoner and Associates

Tim:

This is very easy to do.  Use *ALL on factor2.   For example if your record
format name is RFILE  then    CLEAR *ALL RFILE will do the trick.  I do this all
the time.  But of course may take it away like they did the OVERLAY fields 
option
for arrays.   Here is the section from the ILE RPG reference.

4.4.17 CLEAR (Clear)

+------------------------------------------------------------------------------+
¦   Code   ¦     Factor 1    ¦      Factor 2      ¦   Result  ¦   Indicators   ¦
¦          ¦                 ¦                    ¦   Field   ¦                ¦
+----------+-----------------+--------------------+-----------+----------------¦
¦ CLEAR    ¦ *NOKEY          ¦ *ALL               ¦ Structure ¦     ¦     ¦    ¦
¦          ¦                 ¦                    ¦ or        ¦     ¦     ¦    ¦
¦          ¦                 ¦                    ¦ Variable  ¦     ¦     ¦    ¦
+------------------------------------------------------------------------------+


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 value depending on field type (numeric, character, graphic,
indicator, pointer, or date/time/timestamp).  It allows you to clear structures
on a global basis, as well as element by element, during run time.

Factor 1 must be blank unless the result field contains a record format name 
from
a DISK file, in which case it can contain *NOKEY to indicate that key fields are
not to be cleared.

The Result Field contains the structure or variable that is to be cleared. It 
can
contain: a record-format name, data-structure name, array name, table name, 
field
name, subfield, array element, or indicator name.  If you specify a
record-format name or data structure, all fields are cleared in the order they
are defined within the structure.  Fields in a data structure will be cleared
according to their data types.  If you have partially overlapping fields of
different
definitions, data that is not valid could exist in non-character fields.  With a
multiple-occurrence data structure, only those fields in the current occurrence
are cleared. If you specify a table name, the current table element is cleared;
if an
array name, the entire array is cleared.  If you specify an array element
(including indicators) in the result field using an array index, only the 
element
specified is cleared.

Factor 2 may be blank or can contain *ALL.  If *ALL is specified, and the result
field contains a multiple occurrence data structure or a table name, all
occurrences or table elements will be cleared and the occurrence level will be
set to 1.

When the CLEAR operation is applied to a record format name, and factor 2
contains *ALL and factor 1 is blank, all fields in the record format are
cleared.  If factor 1 contains *NOKEY, all fields for the record format except
the key fields
are cleared.  Note that a CLEAR operation of a record format with a factor 2 of
*ALL is not valid when:

   A field is defined externally as input-only, and the record was not used for
input.
   A field is defined externally as output-only, and the record was not used 
for
output.
   A field is defined externally as both input and output capable, and the
record was not used for either input or output.

When the CLEAR operation is applied to a record-format name for a WORKSTN file,
and factor 2 is blank, all fields listed on the output specifications are
affected.

When the CLEAR operation is applied to a record-format name for a DISK, SEQ, or
PRINTER file, and factor 2 is blank, all fields listed on the output
specifications for that record format on the compiler listing will be cleared.

Note:  Input-only fields in logical files will appear in the output
specifications, although they are not actually written to the file. When a CLEAR
or RESET without factor 1 is done to a record containing these fields, then 
these
fields will be
       cleared or reset because they appear in the output specifications.

All field-conditioning indicators are affected by this operation.

Please see Chapter 10, "Data Types and Data Formats" for their default values.

Figure 149 shows an example of the CLEAR operation.

--------------------------------------------------------------------------

  *...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
   *
  D
  D DS1             DS
  D  Num                      2    5  0
  D  Char                    20   30A
  D
  D MODS            DS                  OCCURS(2)
  D  Fld1                     1    5
  D  Fld2                     6   10  0
  D
  CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
   *
   *  In the following example, CLEAR sets all subfields in the data
   *  structure DS1 to their defaults, CHAR to blank, NUM to zero.
  C
  C                   CLEAR                   DS1
  C
   *
   *  In the following example, CLEAR sets all occurrences for the
   *  multiple occurrence data structure MODS to their default values
   *  Fld1 to blank, Fld2 to zero.
  C
  C                   CLEAR     *ALL          MODS
  C


--------------------------------------------------------------------------
Figure 149. CLEAR Operation

Figure 150 shows an example of the field initialization for the CLEAR record
format.  For an example of using CLEAR with RESET, see Figure 191 in topic
4.4.74.4.

--------------------------------------------------------------------------

  *...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
  A* Field2 and Field3 are defined as output capable fields and can be
  A* affected by the CLEAR operation.  Indicator 10 can also be
  A* changed by the CLEAR operation even though it conditions an
  A* input only field because field indicators are all treated
  A* as output fields. The reason for this is that *ALL was not specified
  A* on the CLEAR operation
  A*
  AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++++*
  A          R FMT01
  A  10        Field1        10A  I  2 30
  A            Field2        10A  O  3 30
  A            Field3        10A  B  4 30
  A*
  A*  End of DDS source
  A*


  FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords++++++++++++++++++++++++++++
  F
  FWORKSTN   CF   E             WORKSTN INCLUDE(FMT01)
  F
  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
  D
  D IN              C                   'INPUT DATA'
  D
  *...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
  CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
  C
  C                   CLEAR                   FMT01
  C                   WRITE     FMT01
  C
   *
   * The program will loop until PF03 is pressed.
   *
  C     *IN03         DOWEQ     '0'
  C                   READ      FMT01                                LR
   *
   * PF04 will transfer input fields to output fields.
  C
  C     *IN04         IFEQ      '1'
  C                   MOVEL     Field3        Field2
  C                   MOVEL     Field1        Field3
  C                   CLEAR                   *IN04
  C                   ENDIF
  C                   MOVEL     IN            Field1
  C
   * When PF11 is pressed, all the fields in the record format
   * defined as output or both will be reset to the values they
   * held after the initialization step.
   *
  C     *IN11         IFEQ      '1'
  C                   RESET     FMT01
  C                   CLEAR                   *IN11
  C                   ENDIF
   * When PF12 is pressed, all the fields in the record
   * format defined as output or both will be cleared.
  C
  C     *IN12         IFEQ      '1'
  C                   CLEAR                   FMT01
  C                   CLEAR                   *IN12
  C                   ENDIF
  C  N03              WRITE     FMT01
  C                   ENDDO
  C                   SETON                                        LR
  C


--------------------------------------------------------------------------
Figure 150. Field Initialization for the CLEAR Record Format


"Hatzenbeler, Tim" wrote:

> I have used the clear command to clear all the fields in a record format
> before a chain, and it works the way I would expect.  But If my file is
> Input only, the clear command is basically ignored.  Is there a quick work
> around for this problem without clearing each field individually???
>
> Thanks, tim
>
> +---
> | This is the RPG/400 Mailing List!
> | To submit a new message, send your mail to RPG400-L@midrange.com.
> | To subscribe to this list send email to RPG400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: david@midrange.com
> +---

--
Thank You.

Regards

Dave Mahadevan.. mailto:mahadevan@fuse.net


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.