Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

MODULE 8: String handling


String Handling in COBOL

  • In this module we will cover string manipulating operations such as counting characters in a string, finding of a character/sub-string in a string, replacement of particular character/sub-string in a string, string concatenation and string segmentation(split one string to many string) etc.
  • All above specified string manipulating operations can be handled by three COBOL verbs:-
    • INSPECT
    • STRING
    • UNSTRING
  • EXAMINE is older version of INSPECT and it was used in COBOL 74. We will cover EXAMINE verb after INSPECT verb’s explanation
  • Below we have provided overview of each of these verbs and same is explained in detail in upcoming section

INSPECT

  • Used to count characters in a string
  • Used to replaces a group of characters in a sting with another group of characters
  • Permits several tallies (counts) and replacements with a single statement (instead of writing multiple statements)
  • Allows group of characters to be counted and replaced
  • Converts each of a set of character to its corresponding character in another set of characters
  • INSPECT is explained in detail here < LINK >

EXAMINE

  • INSPECT and EXAMINE are used to perform same operations
  • EXAMINE was present in the earlier version of COBOL and was replaced in ANSI 74 COBOL with more powerful verb INSPECT
  • However, many implementation still uses EXAMINE and thus we are covering it at high level
  • EXAMINE is explained in detail here < LINK >

STRING

  • STRING is used to join together one or more strings or partial source strings to form a single destination string
  • This is also used to transfer characters from a string to another string starting at some particular character position either in the receiving field or in the sending fields
  • STRING is explained in detail here < LINK >

UNSTRING

  • It is used to split a string into many sub-strings
  • UNSTRING is explained in detail here < LINK >






© copyright mainframebug.com
Privacy Policy