PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Join the forum, it's quick and easy

PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).
PMS Information Systems
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Little or unknown "Debugger" functions

Go down

Little or unknown "Debugger" functions Empty Little or unknown "Debugger" functions

Post  maran Thu Jul 28, 2011 12:03 pm

%SUBSTR Built-In Function

This function is great when you're working with large strings.

- You can view a segment of a string as shown below (assume that StringFldA = 'abcdefghijklmnopqrstuvwxyz'):

Debug command: EVAL %SUBSTR(StringFldA 12 5)
Displayed result: %SUBSTR(StringFldA 12 5) = 'lmnop'

- You can also use the %SUBSTR function to set the value of a specific portion of a string. For me, this is the more useful of these two functions.

Debug command: EVAL %SUBSTR(StringFldA 12 5) = 'xxxxx'
Displayed result: %SUBSTR(StringFldA 12 5) = 'xxxxx'

Debug command: EVAL StringFldA
Displayed result: StringFldA = 'abcdefghijkxxxxxqrstuvwxyz'

- You can also use %SUBSTR to set a conditional breakpoint or watch condition.

For example, the following code would stop execution only when positions 12 thru 16 of StringFldA are 'xxxxx':

Debug command: BREAK 100 when %SUBSTR(StringFldA 12 5) = 'xxxxx'

- Or you could watch for those same positions to change by using this watch condition:

Debug command: WATCH %SUBSTR(StringFldA 12 5)

This way, anytime the contents of positions 12 thru 16 change, program execution stops and you are notified.

________________________________________________________________________________________________________


%INDEX Built-In Function


The %INDEX function is handy when you're using multiple-occurrence data structures.

It's also useful in combination with _QRNU_DSI_xxxx (where xxxx = the name of a multi-occurrence data structure).


- The command EVAL _QRNU_DSI_xxxx returns the current occurrence of a multiple-occurrence data structure.

- Using the %INDEX function will change the current occurrence. See the example below:

d WorkDS1 ds occurs(3)
d StringA 10a
d StringB 25a

Debug command: EVAL _QRNU_DSI_WorkDS1
Displayed result: 1 (or whatever the current occurrence of WorkDS1 is)

Debug command: WorkDS1 = %INDEX(3)
Displayed result: WorkDS1 = %INDEX(3) = 3
(Interrogated subfields will now reflect the values the of third occurrence of the data structure.)
maran
maran
Admin

Posts : 442
Join date : 2009-07-24

https://pmsinformationsystem.forumotion.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum