Not way too prolonged ago, a friend of mine was possessing a issue with a application that he experienced just completed. We were being utilizing the source debugger to discover out what was causing his challenge. We figured out the difficulty ultimately, but in the study course of our work, we arrived across some debugger commands and selections that I was formerly unaware of. Now I am not heading to say that I know almost everything about the IBM resource debugger but I have been using it for a very good prolonged even though. I was surprised to find one thing new, so I considered I'd share what I discovered with you.
% INDEX Designed-In Functionality
The% INDEX purpose is one of the features that up right up until a short while ago I was unaware of. It is truly handy when you are manipulating numerous-prevalence information buildings. It is even a lot more useful when employed in conjunction with the _QRNU_DSI_xxxx created-in worth (exactly where xxxx = the title of a multi-occurrence knowledge construction). The command EVAL _QRNU_DSI_xxxx will return the existing prevalence of a a number of-incidence info composition. This is typically a pretty valuable factor to know in the course of plan execution and as considerably as I know this is the only way to get it. By applying the% INDEX function you can also alter the current incidence of a a number of-prevalence knowledge composition. See beneath.
d WorkMultDS1 ds happens (30)
d StringA 10a
d StringB 25a
To discover the latest incidence of the info construction devoid of transforming it:
Command: EVAL _QRNU_DSI_WorkMultDS1
Final result: 1 (or whatsoever the present occurrence of WorkMultDS1 is)
To modify the latest event:
Command: WorkMultDS1 =% INDEX (12)
Outcome: WorkMultDS1 =% INDEX (12) = 12
Immediately after issuing the earlier mentioned command interrogated subfields will mirror the values of the twelfth event of the details structure.
% SUBSTR Developed-In Function
This perform is really effortless when you are operating with massive strings. Working with the EVAL function by alone will only display screen the 1st 500 people of a industry. As a facet note, the easy option to that difficulty is to append the style and duration to the EVAL purpose as proven below:
This command will display the first 2000 characters of the variable Long_String_Title in character structure:
Command: EVAL Very long_String_Title: C 2000
This command will exhibit the 1st 2000 figures of the variable Prolonged_String_Identify in hexadecimal format:
Command: EVAL Long_String_Name: X 2000
The hexadecimal display is significant when displaying details that contains packaged or binary decimal details. But we are not conversing about the EVAL perform. The SUBSTR function will do particularly what the name poses it will show a substring or a part of a string worth. See the illustrations underneath.
Assume that StringFldA = 'Now is the time for all great adult males …'
Command: EVAL% SUBSTR (StringFldA 12 4)
Outcome: % SUBSTR (StringFldA 12 4) = 'time'
Not unexpectedly, you can also use the% SUBSTR operate to set the worth of a unique portion of a string. In some cases this is a much additional valuable way to use this purpose. An illustration of this utilization is shown underneath.
Suppose that StringFldA = 'Now is the time for all superior adult males …'
Command: EVAL% SUBSTR (StringFldA 12 4) = 'blah'
Consequence: % SUBSTR (StringFldA 12 4) = 'blah'
To see the comprehensive string use the next command:
Command: EVAL StringFldA
End result: StringFldA = 'Now is the blah for all superior gentlemen …'
The% SUBSTR operate can also be utilized to set a conditional breakpoint or view ailment. As an illustration, the code demonstrated below will halt the execution only when positions 12 by 15 of StringFldA are 'blah':
Command: Crack 100 when% SUBSTR (StringFldA 12 4) = 'blah'
Or you could watch for individuals exact same positions to modify by applying this look at issue:
Command: Watch% SUBSTR (StringFldA 12 4)
Immediately after issuing the command higher than, anytime the contents of positions 12 via 15 change, software execution stops and you are notified.
Much more and far more generally I run into area names that are definitely prolonged. Now do not get me wrong here, I imagine this is good. But I do not kind so excellent so a 25 character discipline identify has a substantially better likelihood of currently being mis-keyed than an old 6 character a single (even if the 25 character just one is way extra understood). So if you do not form effectively (or just do not like to kind, like me), then use the EQUATE debug perform. This purpose enables you to outline an “alias” for a subject title, expression, or command. Get the example down below.
Command: EQUATE SmName This_is_a_actually_very long_discipline_title
You can then obtain the benefit of “This_is_a_actually_extended_subject_name” by keying the command shown beneath:
Command: EVAL SmName
The EQUATE command can also be used to build a macro … type of. This can be finished by assigning an “alias” to a comprehensive debug command.
Command: EQUATE SmCmd EVAL% substr (StringA, 5,5)
Now by just keying SmCmd and urgent Enter, you can exhibit the price of positions 5 via 9 of the StringA variable.
So the future time you start off screening a system or chasing a bug, keep in mind these, and you could possibly save your self some problems.