JamesBowen
19+ years progress programming and still learning.
When I started to learn progress 4GL in 1998 I was trained to write code like this:
But, in the last 10 years I have now simplified the code to look like this:
It produces the same result and coding style looks prettier ( i think it does ). I was inspired by some PHP code.
However, I've had some backlash that it's inefficient and it's harder to read. What do you think?
if chStringValue <> "" and chStringValue <> ? then ...
But, in the last 10 years I have now simplified the code to look like this:
if logical( length( chStringValue ) ) then ...
It produces the same result and coding style looks prettier ( i think it does ). I was inspired by some PHP code.
However, I've had some backlash that it's inefficient and it's harder to read. What do you think?
Code:
def var chStringValue as character no-undo.
assign
chStringValue = ?. // For this test, set character variable to a null/unknown value.
// Fails on a null values.
if chStringValue ne "" then
message "Test 1: chStringValue is not blank".
// Handles null values but requires an extra 'and' condition.
if (chStringValue ne "" and chStringValue ne ?) then
message "Test 2: chStringValue is not blank".
// Handles null value and non-empty string values
if logical( length( chStringValue ) ) then
message "Test 3: chStringValue is not blank".