Tuesday 15 July 2014

ibm midrange - Count occurrences of character in string variable without SQL -


I'm looking for a way to count the number of times in a string without using SQL I am

I am expecting that I am new to RPLL and I have created a test program that takes the user input into character, goes through verification, and the successful data is numerically Changes. One of these inputs can be positive or negative integer when going through verification, I do the test to be in the first position and use the% check to ensure that input 0-9 or ' -' is. (Eg, '-10' pass, '1-0' fail)

However, if there are several incidents of '-' symbol in the input, such as '-1-1-1-1', this Verification passes and crashes when the program tries to convert numerical.

I know that I can edit the code in my DDS so that the system can handle it, but I am trying to learn in different ways to recognize my programs. In my research, I have found that TestN and Module / Convert /% Error are methods which can be used to ensure the output is numeric, but I can not test this specific example, so I give meaningful feedback. Can i

Is there a way to count the events of '-' so I can test it?

Since there is some confusion as to my intentions, I will add another example. If I want to find out how many incidents of 'L' are the words 'Hello' in the word 'L', then what would be the best way to go about this.

% scan accepts bif 3 parameters - initial position so that you start with the location of the previous hit Having multiple scans can be done.

However, I am not interested in this type of manual verification. From the point of view, suppose most data is good, you are wasting the cycle. More importantly, the test you set, the requirement for '-' to be in the first position means that '-10' fails Will go;

I only need the transformation of catching the exception if need be.

  monitor; MyValue =% dec (myString); On-error; // know user endon;  

Finally, TESTN is obsolete and should be avoided. This probably does not work any way you want. For example, (IIRC), Teston Test '5A' Pass

This is to say about the tastes in the RPG manual:
Free- Form syntax - (Not allowed - instead of testing the variable before using it, use the code to handle any errors with variables and on-error in a monitor group. See error-handling operations.)


No comments:

Post a Comment