Skip to content

Add INSPECT verb example (character counting/replacement)#66

Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1772140801-inspect-verb
Open

Add INSPECT verb example (character counting/replacement)#66
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1772140801-inspect-verb

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Feb 26, 2026

Summary

Adds a new inspect/ example directory demonstrating the COBOL INSPECT verb for character counting (tallying) and replacement. Includes 10 examples covering:

  • TALLYING: all occurrences, leading characters, characters before initial, multiple conditions (with two tally counters)
  • REPLACING: all occurrences, leading characters, first occurrence, before initial
  • CONVERTING: character set translation (lowercase → uppercase)
  • Combined TALLYING and REPLACING in a single statement

Two files added:

  • inspect/inspect.cbl — the example program
  • inspect/README.md — documentation with syntax reference and expected output

No existing files were modified.

Updates since last revision

  • Removed unused variable ws-after-str; replaced with ws-tally-count-2 for Example 4
  • Improved Example 4 to genuinely demonstrate multiple tallying conditions by using two separate tally counters (ws-tally-count for "A", ws-tally-count-2 for "B") in a single INSPECT statement
  • Fixed Example 8 to use BEFORE INITIAL with a comma delimiter (avoids replacing trailing padding spaces)
  • Updated README output to match actual compiled program output

Review & Testing Checklist for Human

  • Compile and run with cobc -x inspect/inspect.cbl -o /tmp/inspect && /tmp/inspect and verify output matches inspect/README.md — the README output was hand-written to match and may have subtle trailing-space discrepancies
  • Verify examples are pedagogically distinct — Examples 1 and 4 both tally "A" occurrences, but Example 4 additionally tallies "B" with a second counter; confirm this is clear enough as a differentiated example
  • Spot-check COBOL conventions — confirm header block, indentation, and folder structure match existing examples (e.g., trim/, unstring/)

Notes

  • Program was compiled and tested with GnuCOBOL (cobc) during development; all 10 examples produce correct output
  • Follows existing repo conventions (header comment block, folder structure with README + .cbl file)
  • Link to Devin run
  • Requested by @shayanshafii

Co-Authored-By: shayan <shayan@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

…conditions

Co-Authored-By: shayan <shayan@cognition.ai>
Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant