×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




You have to be careful with Reset if you are writing modern ILE RPG. (Local
variables, subprocedures, etc) unless you don't care about static storage.

I had a program that was using a bunch of static storage but I had nothing
declared in static. I talked to IBM and it turns out all the values for the
Reset are stored in static storage even though the reset is to a variable in
local storage. Why I have no idea.

On Tue, Oct 20, 2009 at 9:11 AM, Booth Martin <booth@xxxxxxxxxxxx> wrote:

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 / \
--------------------------------------------------------------------




--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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