re; DCOUNT

17 views
Skip to first unread message

ChrisB

unread,
Nov 1, 2012, 10:30:46 AM11/1/12
to InterSy...@googlegroups.com
Hi, Can anyone tell me what is the equivalent command for DCOUNT in COS. I have dynamic array returned from a PICK subroutine and need to know the equivalent command for;
 
        NO.ENT = DCOUNT(OUTDATA,@FM)
 
Thanks Chris 

Bill Farrell

unread,
Nov 1, 2012, 10:42:03 AM11/1/12
to InterSy...@googlegroups.com
Hi,
You could use:

s NoEnt = $l(OUTDATA,$c(254))

In COS, the $Length function will give you something like a DCount if
you supply a second argument.

Best of luck!
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "InterSystems: MV Community" group.
> To post to this group, send email to Cac...@googlegroups.com
> To unsubscribe from this group, send email to
> CacheMV-u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/CacheMV?hl=en


Ed Clark

unread,
Nov 1, 2012, 10:42:52 AM11/1/12
to InterSy...@googlegroups.com
You can use the form of $LENGTH with 2 arguments, for example:
w $LENGTH(s,$MVAM)

However, depending on what you are going to do with the dynamic array, you might want to convert it to a $list with the $LISTFROMSTRING function--or even have the mv subroutine return a $list in the first place. You can count it with $LISTLENGTH, or loop through the list elements with $LISTNEXT (which is very efficient because it doesn't require you to pre-count the list, and know when it gets to the end)

Ed Clark

unread,
Nov 1, 2012, 10:53:34 AM11/1/12
to InterSy...@googlegroups.com
I would *strongly* recommend that you never, ever, use $c(254) or char(254) to represent system delimiters. Use @AM in mvbasic and $MVAM in cos. Same for @vm, @svm, @™, and @IM.
These characters are valid data in many european languages. At some future time you may want to internationalize your application, which would require using different characters as system delimiters. You actually can change these delimiters in Cache, though currently there isn't complete support for it.

Chris B

unread,
Nov 1, 2012, 11:59:42 AM11/1/12
to InterSy...@googlegroups.com
Hi Ed, Yes that all worked OK and have now finally managed to populate my
grid with data received from PICK, many thanks Chris
checked for viruses and spam by CanIt.
http://www.canit.3d.net.uk/

Bill Farrell

unread,
Nov 1, 2012, 2:59:13 PM11/1/12
to InterSy...@googlegroups.com
Good catch, Ed. I had been dealing in the Dark Ages with Cache 5 for
months and it slipped my mind that modern COS has MV functions and
delimiters nicely and neatly exposed.

I'm in a new job now, a little closer to home with a good bit more
money. Sadly, no Cache', but I can deal with PHP and MySQL easily
enough. Perhaps some day I'll find that CacheMV shop in central NC
(hint, hint InterSystems salesfolks!). There's MV around just dyin' to
come into the modern (Cache') world. We just have to find 'em and fix
'em. (I know of a couple.)

Best!
Bill
Reply all
Reply to author
Forward
0 new messages