![]() |
|
#1
|
|||
|
|||
|
I have a mainframe script that checks the level of nesting in cobol programs (so people get a slap on the wrist for coding something like if else if else if else if else if else etc etc)
Code:
Code:
I could easily change the Code:
|
|
#2
|
||||
|
||||
|
part of the FIND command syntax is FIRST and WORD
__________________
Dick Brenholtz American in Varel, Germany |
|
#3
|
|||
|
|||
|
But FIRST refers to the first OCCURRENCE on a line, not the first word so the 'IF' could be the last word on the line and still be in the result set. WORD just makes sure that only the WORD 'IF' is included in the result set and not words such as 'dIFficult'.
You may have to check the POS of any ' and see if the IF comes after it and before a second '. Or, find the position of the first non-blank character and see if it is IF.
__________________
Everything I say is a lie - believe me! |
|
#4
|
|||
|
|||
|
that's about what I'd figured - have to perform a loop.
Just wanted to check that there wasn't some finesse I didn't know about |
|
#5
|
||||
|
||||
|
I stand corrected, FIND parms do not fit as I suggested.
I don't use FIND that often basically due to this problem. have to check the columns, etc... normally for this kind of task, I use a combination of LINE to populate a stem, and PARSE to detemine if the 'IF' is really an IF.
__________________
Dick Brenholtz American in Varel, Germany |
|
#6
|
||||
|
||||
|
enforcing standards is always alot of fun.
when the site could not afford (or would not buy) standards enforcing software (it is expensive) I would write a COBOL program that would insert a non astriked '*' comment in the source explaining the offense. This program was part of the compile proc, that everyone had to use, and of course the un-astriked comment(s) would cause a compile failure. this allowed for consequences - can't compile the program and avoided such issues as:
__________________
Dick Brenholtz American in Varel, Germany |
|
#7
|
|||
|
|||
|
Quote:
Code:
__________________
Ron |
|
#8
|
|||
|
|||
|
Quote:
The above is a good example of why the commercial software products that enforce standards are so expensive. To do this rigourously requires you to re-engineer the Cobol language parser used by the compiler and then apply your local standards. A challenging undertaking, so say the least.
__________________
"Don't tell me how it works, tell me how it fails." |
|
#9
|
||||
|
||||
|
I would bounce the code because it violated standards.
I work with a lot of doctorates (physics) and they also have no sensitivity to readability. THEN, ELSE also alone on a separate line Code:
__________________
Dick Brenholtz American in Varel, Germany |
|
#10
|
|||
|
|||
|
FWIW, I, myself, would NEVER write COBOL code in the manner that I posted as an "example" of the kind of code that "might" be encountered in someone else's source code. I merely posted it as an example of another kind of code that Michael "might" encounter that may cause his filter to hiccup or misfire.
In his preamble he, himself, used the phrase "coding something like if else if else if else if else if else etc etc" - a phrase in which there are multiple IF's following the word ELSE on the same line.
__________________
Ron |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|