Instead of having the setup in the main portion of the code it should be
done once only at the initialization of the program.  It's always a good
idea to put as much "one time only" code in a place where it will only get
executed as little as possible.

Then instead of using @AM for the separator, just use CHANGE to change the
/'s to @AM's.  I prefer commas myself because it's faster to type IMO.  And
put a comment above the LOCATE telling the next guy to come along that it
has to be sorted, and that it's in the INIT section of the program.

Making code as fast as possible isn't always necessary, but it sure is fun
:)

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Keith Johnson
(DSLWN)
Sent: Sunday, November 25, 2007 16:51
To: [email protected]
Subject: [U2] Good Practice?


Neil suggested using LOCATE rather than INDEX in my example.

I'm not sure I agree that would be any less complex as far as the code
is concerned.  INDEX and LOCATE are both 'complex' compared with the IF
statement, and since LOCATE needs its SETTING variable, it's arguably
the more complex statement.  There are three different forms of LOCATE,
so that can cause problems. Lastly, the variable TEST has to be set up
with attribute marks either by multiple lines or by the very long line
below; which, I have to say, I don't find very readable at all.

TEST =
'AF1':@AM:'CK1':@AM:'CK2':@AM:'GS1':@AM:'H':@AM:'JM':@AM:'LHC':@AM:'MP':
@AM:'MP3':@AM:'NU1':@AM:'NU2':@AM:'TK1':@AM:'TK2'

There may be a slight speed benefit in restricting the scan by using
'AL'; but this is not material (or possibly even detectable?) in strings
of this length.  There is also an ongoing  maintenance risk because the
next programmer might not notice the codes were sorted, and may just add
a new one to the end of the string.
Regards, Keith.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to