cobol inspect

Cobol inspect

Using Inspect in cobol. Quick References. View previous topic :: View next topic. Posted: Sat Sep 26, pm.

Below are the different examples on different cases and syntax which are very useful while coding a cobol program. Given the result for each case for better understanding. Example 1: Capturing the count of any character in a string. It gives count of a specific character in a string. Example 2: Replacing one character with another one. Example Counting the exact length of a string using inspect.

Cobol inspect

The match values may be single characters or strings, or a mix of both. The match values are searched for, in order of appearance in the code, at each position in the source string. Inspection starts at the leftmost character of the source data item and proceeds, character by character, to the rightmost character. The first value in the match set is "cd". The first element, "c", is compared to the value "a" for a match. No match. The second value in the match set is "e". The third value in the match set is "f". There are no untested values remaining in the match set. The current position in the source data item is advanced one position to the right. The sequential testing of the members of the match set to the value of the current position in the source data item is repeated. None matches. The first match value is "cd".

The data referred to by these items is treated as a character string.

.

Below are the different examples on different cases and syntax which are very useful while coding a cobol program. Given the result for each case for better understanding. Example 1: Capturing the count of any character in a string. It gives count of a specific character in a string. Example 2: Replacing one character with another one.

Cobol inspect

This restriction does not apply to literal-2 or identifier-4,. The position of this first occurrence is determined before the first cycle of the comparison operation described in General Rule 12 is begun. General Formats for Format 1. General Formats for Format 2. General Formats for Format 3.

Ikea trofast

There are no more characters in the match value "cd". Counting for a specific character after any other letter. If the rightmost character is not comp-value , then counter is not incremented. October 27, Reply. Don't forget me. General Rules Inspection starts at the leftmost character of source and proceeds character by character until it reaches the rightmost character. Once you get the position it should be easier. The current position in the source data item is advanced the length of the match value "cd" , two places to the right. This could happen when reference modification is used, because in that case the length of a data item is not known at compile time. How good is your data? The AFTER phrase modifies the character position to use as the leftmost position in source for the corresponding comparison operation. This character position is the one immediately to the right of the rightmost character of the delimiter found.

.

Skip to content. Example 1: Capturing the count of any character in a string It gives count of a specific character in a string. If no match occurs, successive comp-val or targ items are checked at the current character position until a match occurs or the list of items is exhausted. For a more concise description of the matching process, see General Rule 5 above. If you have any suggestions or concerns on this post, please feel to to post it via the comments below this post. Inspection starts at the leftmost character of the source data item and proceeds, character by character, to the rightmost character. The source data item may not change in size. When the ALL phrase is present, each occurrence of targ matched in source is replaced by repl. The third value in the match set is "f". Save my name, email, and website in this browser for the next time I comment. Notice that, if we had replaced "cd" with "ef" instead of "QP", the "e" and "f" would not be subsequently replaced with "T and "V".

2 thoughts on “Cobol inspect

  1. Willingly I accept. An interesting theme, I will take part. Together we can come to a right answer. I am assured.

Leave a Reply

Your email address will not be published. Required fields are marked *