× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



James:

I invested 5 minutes to write that code - not a second more.  I didn't try
to compile it and I didn't have to support it.  I like your variable names
better than mine.  I don't have to keep comparing at &fld3 with &fld1 and
&fld2, I checked to see if &qryslt was blank - it is easier and faster to
write in my example.  I don't know if the string is valid without the left
and right parenthesis.  I didn't try to compile it or run it.  It was an
example.  I never use OPNQRYF anymore, I only use SQL or Query Manager.  I
have become a complete dunderhead about query/400.

The technical differences between our code is trivial compared to how alike
they are in concept.  Do not confuse this with pride in my example code.  My
example code is crap but the idea is right.

We are in violent agreement.

Richard Jackson
mailto:richardjackson@richardjackson.net
http://www.richardjacksonltd.com
Voice: 1 303 808 8058

> -----Original Message-----
> From: owner-midrange-l@midrange.com
> [mailto:owner-midrange-l@midrange.com]On Behalf Of James W. Kilgore
> Sent: Monday, July 24, 2000 9:59 PM
> To: MIDRANGE-L@midrange.com
> Subject: Re: Opnqryf with Many Selections
>
>
> Richard,
>
> It can be, I did say -can be-, messy keeping track of all of the quote
> marks.
>
> And it really does look ugly.  Am I quoting the value or am I quoting
> the string?  How many quotes do I -REALLY- need?
>
> IMHO, building the string can and should be black boxed so a particular
> CL program (and the programmer) does not need to go through the "count
> the quotes" exercise.
>
> If the purpose of a program is to provide a list/display with selection
> capability, the -raw how- to build the selection string should not be in
> the picture.  If it is, the -raw how- must be replicated in each and
> every program that provides selection capability.  Now in our shop
> that's just about every one of them.
>
> Since you are going to do the same thing in every one of them how about
> we make the exercise a clean function to reduce programmer effort?  All
> it amounts to is a simplification of the -how-.
>
> Let's compare your case to the one that our shop uses:
>
> Here's yours:
>
> if (&fld1 *ne ' ') do
> chgvar &qryslt ('fld1 = ')
> chgvar &qryslt (&qryslt || &q || &fld1 || &q)
> enddo
>
> if (&fld2 *ne ' ') do
> if (&qryslt = ' ') chgvar &qryslt ('fld2 = ')
> else chgvar &qryslt (&qryslt |> '*and fld2 = ')
> chgvar &qryslt (&qryslt || &q || &fld2 || &q || ' ')
> enddo
>
> Here's ours:
>
> if (&fld1 *ne ' ') do
> chgvar &value (&dblquote *cat &fld1 *tcat &dblquote)
> call $qryslt2 parm(&andor 'fld1' 'eq' &value &qryslt)
> chgvar &andor ('and')
> enddo
>
> if (&fld2 *ne ' ') do
> chgvar &value (&dblquote *cat &fld2 *tcat &dblquote)
> call $qryslt2 parm(&andor 'fld2' 'eq' &value &qryslt)
> chgvar &andor ('and')
> enddo
>
> Now there isn't a whole lot of difference, except that in your case for
> &fld3 to determine if you should place the *and, you must test &fld1 and
> &fld2 and as you add more fields to must add more compares.
>
> In my case, each test does not need to know the existence or absence of
> any other value.  New selection criteria can be added without having to
> retrofit any other blocks of code.
>
> There is a trivial program called ($qryslt2) that builds the string.
> BTW, I couldn't figure out from your code where you put the '(' ')' from
> your code, if both values are entered you would result in the following
> string:
> fld1 *eq 'whatever' *and fld2 *eq 'somethingelse'
>
> In my case I have the following string:
> (fld1 *eq 'whatever') *and (fld2 *eq 'somethingelse')
>
> I've never used a string of your construct and I'm sure that it is
> valid, since you said so, but IMHO, the second is easier to debug.
> Especially if the string is constructing many more variables.
>
> It's not that I disagree with you in concept, building a string is a
> minor exercise.  I would just like to add that it can be made easier and
> cleaner for the programmer that must do the job.
>
> There was a thread on this list some time ago where I vehemently stated
> that if a programmer doesn't know how to do the job they can either keep
> up or eat dust.  Since then I've made it easier to keep up.  I'm getting
> lazier in my old age :-)
>
> > Richard Jackson wrote:
> > >
> > > Buck:
> > >
> > > Why is writing a CL program messy?
> > >
> +---
> | This is the Midrange System Mailing List!
> | To submit a new message, send your mail to MIDRANGE-L@midrange.com.
> | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> MIDRANGE-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator:
> david@midrange.com
> +---

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.