COBOL String modification idea using pointer statement

I am coming back after a little hectic work. Just sitting relaxed and reading┬áthe book “How the Rich think“. I just started writing my blog post, got an idea to write strings.

The fact is in COBOL, strings is an important concept. You may use it in many places viz: during dynamic SQL queries, concatenating names, error handling etc.

Usage 1:

01 Final_name            pic x(8)  value "testname".
String   "18"  Delimited by Size
    into   Final-name

In this case the initialized value will be modified . So the new name is “18stname”.

Usage 2:

String "My name is srinimf" Delimited by Size
      Into New-name

In this case, the complete string moved into a new variable

Usage 3:

01 City   pic   x(3)  value "New city"

String   City  Delimited by '  '
      Into New-city-name

In this case, only upto first space will be moved into new name.

Usage 4:

o1 ws-cnt    pic  99.
Move 1  to  ws-cnt.
String "My name is srinimf" Delimited by Size
      Into New-name
      with Pointer ws-cnt

In this case, the ws-cnt will have the number of chars (ws-cnt -1) that finally moved.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.