× 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.



My ignorance is shining through again.

Isn't there a difference between "CLEAR" and "RESET" opcodes?

"The CLEAR operation sets all elements in a structure or variable to their default value depending on the field type (numeric, character, graphic, UCS-2, indicator, pointer, or date/time/timestamp).

The RESET operation sets all elements in a structure or variable to their initial values (the values they had at the end of the initialization step in the program cycle)."

I have always taken this to mean that if one defines a D spec as:

D wGuru s 20 inz('Simon Coulter')

and then later
wGuru = 'Coulter, Simon'
CLEAR wGuru // ( wGuru becomes blanks)
RESET wGuru // ( wGuru becomes "Simon Coulter")




Simon Coulter wrote:
On 21/10/2009, at 1:01 AM, Christen, Duane wrote:

Yes, CLEAR on a DS blanks numeric subfields.


:quote.
CLEAR (Clear)
Free-Form Syntax CLEAR {*NOKEY} {*ALL} name
Code Factor 1 Factor 2 Result Field Indicators
CLEAR *NOKEY *ALL name (variable or record format)

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 “Chapter 10. Data Types and Data Formats” on page 165.
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.
:equote.

Operative part of that quote is "elements in a structure" ... see the example code in the RPG Reference for clarification.

The only issue is where a character field and numeric field overlap in which case the order in which they appear in the structure determines the final initialised value.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.