Is there a way, in D3, to compare dict items without writing a new one?

146 views
Skip to first unread message

Bruce Ackman

unread,
Dec 27, 2021, 11:34:55 AM12/27/21
to Pick and MultiValue Databases
For instance is A > B without creating A-B and then selecting for A-B > 0

TOM MARRACCI

unread,
Dec 27, 2021, 12:14:15 PM12/27/21
to mvd...@googlegroups.com
Bruce,

try the “eval” modifier. From the 10.2 manual:

expressionSpecifies the arithmetic operation to perform on the specified Attribute-Defining-Items. 
  • The specified expression must be enclosed in double-quotes.

  • The oconvs() and trans() functions can be employed within the expression. See oconvs() and trans() Functions below.

  • Parentheses are allowed in the expression. For example:

    list inventory eval "(((PRICE - COST)/COST) * 100)"


There is much more regarding the icons and trans functions, but this is the basics.

Not sure when it was introduced.

Tom


On Dec 27, 2021, at 8:34 AM, Bruce Ackman <brac...@gmail.com> wrote:

For instance is A > B without creating A-B and then selecting for A-B > 0

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mvdbms/c5c88cd4-6b8b-4ffe-b34d-108dc0661fe4n%40googlegroups.com.

Bruce Ackman

unread,
Dec 27, 2021, 2:00:32 PM12/27/21
to Pick and MultiValue Databases
I'm on D3 9.2 and eval didn't work.  Guess it was added later

Neil Pratt

unread,
Dec 27, 2021, 3:19:44 PM12/27/21
to Pick and MultiValue Databases
Bruce,

Do you mean you want to compare two attributes in a record?

I work on a D3 system and this doesn't work.

:SELECT NPTEST WITH  ATT1 >  ATT2
[4] syntax error

but it would be quite simple to create a dictionary item that would compare 2 attributes as in the example below...

:CT DICT NPTEST CMPX

    CMPX
001 A
002 0
003 Compare
004
005
006
007 IF N(ATT1) > N(ATT2) THEN "YES" ELSE "NO" END
008
009 R
010 5

>LIST NPTEST ATT1 ATT2 CMPX
Page   1     NPTEST

NPTEST.... ATTR 1 ATTR 2 Compare

1               1      2      NO
2               3      2     YES
3               4      5      NO
4               6      3     YES
5              10      9     YES

Bruce Ackman

unread,
Dec 28, 2021, 1:40:41 PM12/28/21
to Pick and MultiValue Databases
Yeah, I've got a lot of dictionary items like that.  It would be very convenient if I could do it more on the fly.

Will Johnson

unread,
Dec 29, 2021, 2:00:50 PM12/29/21
to Pick and MultiValue Databases
Provided you are finding that you need to do this often enough
Write a subroutine that takes command line parameters as input

Wol

unread,
Dec 29, 2021, 2:10:39 PM12/29/21
to mvd...@googlegroups.com
But how does he then call that routine WITHOUT creating a dict item for it?

That's why EVAL would be perfect, if only it were available. That's the
requirement - to avoid cluttering the dict with query-specific items.

Cheers,
Wol
> --
> You received this message because you are subscribed to
> the "Pick and MultiValue Databases" group.
> To post, email to: mvd...@googlegroups.com
> To unsubscribe, email to: mvdbms+un...@googlegroups.com
> For more options, visit http://groups.google.com/group/mvdbms
> <http://groups.google.com/group/mvdbms>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mvdbms/f2efd9ee-423e-4b78-852f-50d9cbdd435fn%40googlegroups.com
> <https://groups.google.com/d/msgid/mvdbms/f2efd9ee-423e-4b78-852f-50d9cbdd435fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

B. Cameron

unread,
Dec 29, 2021, 4:35:45 PM12/29/21
to Pick and MultiValue Databases
I agree, write a function/subroutine passing the filename, and DICT items to compare.

Psuedo code...

Function XEVAL (Request)
Filename = field(Request," ",1)
DName1 = field(Request," ",2)
Oper      = field(Request," ",3)
DName2 = field (Request," ",4)
Opts       = field(Request," ",5)  ;* for printing, or sample set ??

Open Filename
Select
Loop
ReadNext
Read 
Compare DName1 Oper DName2
Output

Etc...

XEVAL CLIENTS FLD1 GT FLD2

Just a thought... part of the beauty of M/V?

Dick Thiot

unread,
Dec 29, 2021, 5:58:02 PM12/29/21
to mvd...@googlegroups.com
I think that creating the DICT item is preferred over EVAL because it is reusable and you don't have to write the EVAL code on every query that would use it.  If there are only one or two queries, eval is fine but over time the DICT item is better because of its reusability.  Clutter is when you have multiple dictionary records that do the same thing, or change the display length, etc.

Dick

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mvdbms/db7a17dc-ea15-4176-8be7-5aa1f165b8afn%40googlegroups.com.

Wols Lists

unread,
Dec 30, 2021, 3:51:49 AM12/30/21
to mvd...@googlegroups.com
On 29/12/2021 22:57, Dick Thiot wrote:
> I think that creating the DICT item is preferred over EVAL because it is
> reusable and you don't have to write the EVAL code on every query that
> would use it.  If there are only one or two queries, eval is fine but
> over time the DICT item is better because of its reusability.  Clutter
> is when you have multiple dictionary records that do the same thing, or
> change the display length, etc.

Horses for courses. Having worked with DICTs that might have maybe 10
D-types, but 100 EVAL I-types all of which seem to do the same thing,
I'd rather see the logic in the query, not in the dictionary.

These dictionaries pre-dated EVAL, and not having a clue where all these
queries were (or even whether they existed any more) cleaning up the
mess wasn't really an option.

Cheers,
Wol
> <mailto:mvd...@googlegroups.com>
> To unsubscribe, email to: mvdbms+un...@googlegroups.com
> <mailto:mvdbms%2Bunsu...@googlegroups.com>
> For more options, visit http://groups.google.com/group/mvdbms
> <http://groups.google.com/group/mvdbms>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> <https://groups.google.com/d/msgid/mvdbms/db7a17dc-ea15-4176-8be7-5aa1f165b8afn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to
> the "Pick and MultiValue Databases" group.
> To post, email to: mvd...@googlegroups.com
> To unsubscribe, email to: mvdbms+un...@googlegroups.com
> For more options, visit http://groups.google.com/group/mvdbms
> <http://groups.google.com/group/mvdbms>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mvdbms/CAAbj8ip%2B35iBisYfPYp0UT5ZALS_ci8108GYVU4Aj1UaOUBeaw%40mail.gmail.com
> <https://groups.google.com/d/msgid/mvdbms/CAAbj8ip%2B35iBisYfPYp0UT5ZALS_ci8108GYVU4Aj1UaOUBeaw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Bruce Ackman

unread,
Dec 30, 2021, 1:46:18 PM12/30/21
to Pick and MultiValue Databases
I think I could go with the program.  Usually I'm looking at creating a list of items to process in some way or generate a report on.  Every day involves different files and different comparisons in the same file. Beauty of MV.  Wouldn't want to try it in SQL.

Will Johnson

unread,
Dec 30, 2021, 3:12:46 PM12/30/21
to Pick and MultiValue Databases
You don't need a DICT item in order to call a routine from the command line.
For example

WLIST myfile mydict1 mydict2 COMPARE

You are comparing dict 1 to dict2 but you do NOT need a dict3 in order to do that

Martin Phillips

unread,
Dec 31, 2021, 4:17:03 AM12/31/21
to mvd...@googlegroups.com

I haven’t been watching this thread closely so this may already have been said…

 

In QM, a selection clause can directly compare two fields without needing any EVAL, subroutine, etc.

 

 

Martin

 

From: mvd...@googlegroups.com <mvd...@googlegroups.com> On Behalf Of Dick Thiot
Sent: 29 December 2021 22:58
To: mvd...@googlegroups.com
Subject: Re: [mvdbms] Re: Is there a way, in D3, to compare dict items without writing a new one?

 

EXTERNAL EMAIL




================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy
================================

This communication and any attachments may contain confidential information of Rocket Software, Inc. All unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify Rocket Software immediately and destroy all copies of this communication. Thank you.

Jorge Salvat

unread,
Dec 31, 2021, 5:49:05 AM12/31/21
to Pick and MultiValue Databases
Hi,

EVAL is not working for me on windows D3 10.3.3

Tried this on MVDEMO account:

:list inventory retail-price qty-on-hand eval "retail-price * qty-on-hand"
 Illegal Sym

What's wrong?

Happy new year to all
Jorge

jes

unread,
Jan 1, 2022, 10:39:29 AM1/1/22
to Pick and MultiValue Databases
I wonder what Dick Pick would have thought about all this dict-waving.

jes

Tony Gravagno

unread,
Jan 3, 2022, 9:50:55 PM1/3/22
to Pick and MultiValue Databases
On Monday, December 27, 2021 at 8:34:55 AM UTC-8 Bruce Ackman wrote:
> For instance is A > B without creating A-B and then selecting for A-B > 0


Many years ago I published ComparativeAQL, that does exactly what you want. Unfortunately through the miracle of modern computing the wiki (all documentation) for the code was deleted out of the repo site. You can probably figure out how it works from the code. I can probably dig it up from my own archives if required.

Problems with customers:
CSORT CUSTOMERS
   WITH LY.SALES > TY.SALES OR
   WITH AVERAGE.DELIVERY.TIME > PROMISED.DELIVERY.TIME

Problems with inventory:
CSELECT INVENTORY
    WITH AVAILABLE.QTY < ORDER.POINT OR
    WITH ON.HAND < CURRENT.ORDER.QTY

Consider using this with D3 shell variables for even more powerful reporting:

: BAD.WEATHER SNOW STATES
That's one of my utilities that queries national weather and saves shell variables including the following:
SET STATES.WITH.SNOW= "MN" "IL" "MI" "WI"

CSELECT INVENTORY
    WITH ON.HAND < ORDER.POINT AND
    WITH VENDOR.SHIP.STATE = @STATES.WITH.SNOW
Now, you not only know what inventory to get but you know which states may have delays shipping to you

Note that with D3v10, the comparison to states works even if (and it should) the vendor state is translated from the VENDORS file and there are multiple states from which the vendor ships. In the past we got back a single string for MVs which made comparisons like this (usually) prohibitively difficult.

Refs:

Reply all
Reply to author
Forward
0 new messages