There was this:

>>> Speaking of mis-used commands and side-stepping some of the given code
>>> craziness...
>>>
>>> It is better practice to atomize the code into discrete elements such
>>> as...

      Var1.F = oconv(Var1, 'MD0')
      Var2.F = oconv(Var2, 'MD2')
      Var3.F = oconv(Var3, 'MD4')

          Crt.Str  = Var1.F 'R#6
          Crt.Str := Var2.R 'R#12'
          Crt.Str := Var3.F 'R#14'
      crt Crt.Str


>>> rather than to try to kill two birds with one stone by including an
>>> oconv statement inside a crt statement such as...
>>>
>>>   crt oconv(Var1, 'MD0')
>>>
>>> --Bill>

And this:

> >>Womack, Adrian wrote:
> >>> IMO, the only thing wrong with your example is the use of the
trailing
> >>> format strings - everyone (and I mean everyone) should be using the
FMT
> >>> function, making your example:
> >>>
> >>> CRT FMT(OCONV(VAR1,"MD0"),"R#6 "):FMT(OCONV(VAR2,"MD2"),"R#10
> >>> "):FMT(OCONV(VAR3,"MD4"),"R#14")

Yikes!

As someone who has spent the last 25 years of my life looking
at/fixing/changing code that someone else wrote I have to say that I value
terseness over everything else.  Create a variable just to hold the
formatted version of some other variable to avoid embedding OCONV's in a
PRINT/CRT/DISPLAY statement?   Just looking at code like that would have me
drawing a warm bath and getting out the razor blades.  Never mind having to
write code like that.

Personally, I find the trailing "D2/" a little too subtle, and prefer the
use of OCONV statements just to make the conversion jump out a little more
when someone takes a quick glance at the code.  Justification and fill via
"R%6" and so on works just fine for me, and the extra space taken up with
FMT function calls only serves to make the code harder to read.

As to a "disaster waiting to happen".  I've never seen, never even heard of
it happening.  Doubt that I ever will.  Programmers make typos all the
time, keeping the code terse and clean is the absolute best way to make
them easier to spot, easier to avoid and easier to fix.

I don't like:

               PRINT ABC/100"L%6"

because I'm never quite trust the order of operations or my rememberance of
them.  I'd use:

              PRINT (ABC/100)"L%6"

I never saw a line of code that wouldn't be improved by adding some
parenthesis. :)

And I'd never use:

      X = (ABC/100)"L%6"

or

      X = OCONV(ABC,"MD2,")

Unless there was some extraordinary reason to have a variable floating
around with formatted data in it.  I consider it a best practice to keep
all variables as internal, unformatted data and apply the formats in the
output commands themselves.


Dave Barrett,
Lawyers' Professional Indemnity Company
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to