replacing ZWR and ZW

64 views
Skip to first unread message

George Lilly

unread,
Feb 21, 2012, 5:42:14 PM2/21/12
to Fileman Triple Store
I have a routine SHOW^C0XF2N which will print to the screen part of the MXML dom like this:

GTM>S C0XJOB=14496

GTM>D SHOW^C0XF2N(2)
^TMP("MXMLDOM",14496,1,2)="owl:Ontology"
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=""
^TMP("MXMLDOM",14496,1,2,"P")=1

Here's the code:

SHOW(ZN) ;
 I '$D(C0XJOB) S C0XJOB=$J
 ZWR ^TMP("MXMLDOM",C0XJOB,1,ZN,*)
 Q
 ;

I also use ZWR in error conditions when using Fileman:

BLKERR ;
 W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI)
 B
 Q
 ;

 D WP^DIE(C0XSFN,ZIEN_",",1,,ZTXT,"ZERR")
 I $D(ZERR) D  ;
 . ZWR ZERR
 Q
 ;

**************************

David said:

The simplest thing to do is to replace ZWR with ZWRITE 
the full spelling of the command works on both Cache and GT.M 
the other thing to be aware of is that ZWRITE on Cache only works 
with local variables, whereas ZWRITE on GT.M also works with global 
variables. 

Perhaps you could show us the code that is using ZWRITE ? 

George Lilly

unread,
Feb 21, 2012, 5:50:12 PM2/21/12
to Fileman Triple Store
I tried to write a routine to use instead of ZWR that used $query, but I guess I don't know how $query works...

GTM>s g=$na(^TMP("MXMLDOM",C0XJOB,1,2))

GTM>W g
^TMP("MXMLDOM",14496,1,2)
GTM>w $q(g)

GTM>>w $q(^TMP("MXMLDOM",14496,1,2))
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")
GTM>

Here's the code I was hoping to use: (it doesn't work)

CARP(ZTXT) ; write an array to the screen. use instead of ZW or ZWR
 ; ZTXT is passed by name
 n zi s zi=ZTXT
 f  s zi=$q(zi) q:zi'[ZTXT  w !,zi,"=",@zi
 q
 ;

K.S. Bhaskar

unread,
Feb 21, 2012, 6:04:29 PM2/21/12
to fileman-tr...@googlegroups.com
George --

Hope this helps:

GTM>set a(2)=3,a("four","five")="six"    

GTM>zwrite a
a(2)=3
a("four","five")="six"

GTM>set tmp="a" for  set tmp=$query(@tmp) quit:""=tmp  write tmp,"=",@tmp,! 
a(2)=3
a("four","five")=six

GTM>

Notice the difference in the output, though: "six" vs. six.

Using ZWRITE (if it works on the other MUMPS implementation the way you need it to work) will be more efficient on GT.M.

Regards
-- Bhaskar
--
Windows does to computers what smoking does to humans

LD 'Gus' Landis

unread,
Feb 21, 2012, 6:15:45 PM2/21/12
to fileman-tr...@googlegroups.com
On Tue, Feb 21, 2012 at 3:50 PM, George Lilly <gli...@glilly.net> wrote:
I tried to write a routine to use instead of ZWR that used $query, but I guess I don't know how $query works...

GTM>s g=$na(^TMP("MXMLDOM",C0XJOB,1,2))

GTM>W g
^TMP("MXMLDOM",14496,1,2)
GTM>w $q(g)


Dear George,

With $Q().... indirection @ is your friend...  w $q(@g)

Also.. we need to stump for a ZW or ZWR entry point in some language dependant
kernel routine so that we can hide that difference... Grr...

Cheers,
  --ldl 
--
---
NOTE: If it is important CALL ME - I may miss email,
which I do NOT normally check on weekends nor on
a regular basis during any other day.
---
LD Landis - N0YRQ - de la tierra del encanto
3960 Schooner Loop, Las Cruces, NM 88012
651-340-4007  N32 21'48.28" W106 46'5.80"

John McCormack

unread,
Feb 21, 2012, 7:02:26 PM2/21/12
to fileman-tr...@googlegroups.com
zwrite works on globals on Cache.

WVDEV>ZWRITE ^DPT(1)
^DPT(1,0)="ZZ PATIENT,TEST ONE^F^2450124^^2^^NOE^^000003322^^LAS VEGAS^32^^^68^3060511^^^^1"
^DPT(1,.02,0)="^2.02P^13^1"
^DPT(1,.02,13,0)="13^1"
^DPT(1,.02,"B",13,13)=""
^DPT(1,.06,0)="^2.06PA^2^1"
^DPT(1,.06,2,0)="2^1"
^DPT(1,.06,"B",2,2)=""

WVDEV>w $zv
Cache for Windows (x86-32) 2008.2.5 (Build 951_0_8654U) Thu Nov 5 2009 22:05:01EST



Example of using $Q that I've used in the Lab package. In this case it was to load variables into an array.

         F J="FDA","FDAIEN","LR68","LRAA","LRAD","LRAN","LRDFN","LRDIE","LRSS","LRTSTS","LRUNQ","LRWLC","XQY","XQY0" D
         . S X=$G(@J)
         . I X'="" S LRCNT=LRCNT+1,LRMTXT(LRCNT)=J_"="_X
         . F  S J=$Q(@J) Q:J=""  S LRCNT=LRCNT+1,LRMTXT(LRCNT)=J_"="_@J

George Lilly

unread,
Feb 21, 2012, 8:00:23 PM2/21/12
to fileman-tr...@googlegroups.com
Thanks John!.

That makes things much easier.. I'm going to change all the ZWRs to ZWRITEs ..

Thanks David, Bhaskar, and Larry. I know a little more about $query now.. Maybe someday I'll find a chance to use it...

gpl

LD 'Gus' Landis

unread,
Feb 21, 2012, 8:24:58 PM2/21/12
to fileman-tr...@googlegroups.com
On Tue, Feb 21, 2012 at 6:00 PM, George Lilly <gli...@glilly.net> wrote:
Thanks John!.

That makes things much easier.. I'm going to change all the ZWRs to ZWRITEs ..

Thanks David, Bhaskar, and Larry. I know a little more about $query now.. Maybe someday I'll find a chance to use it...

gpl


Dear George,

Spelling the full name helps make ZWRITE less implementation specific,
but only somewhat.

Cheers,
  --ldl
===============================
USER>zwrite

USER>s a(1)=1

USER>s a(1,"a")="a"

USER>s a(2)=2

USER>zwrite

a(1)=1
a(1,"a")="a"
a(2)=2

USER>zwrite a(1,*)

ZWRITE a(1,*)
^
<SYNTAX>
USER>zwrite a(1)
a(1)=1
a(1,"a")="a"
===============================
GTM>zwrite

GTM>s a(1)=1

GTM>s a(1,"a")="a"

GTM>s a(2)=2

GTM>zwrite a(1,*)
a(1)=1
a(1,"a")="a"

GTM>zwrite a(1)
a(1)=1
===============================


John McCormack

unread,
Feb 21, 2012, 8:44:27 PM2/21/12
to fileman-tr...@googlegroups.com
It's still a SACC violation if you submit to the VA unless it's made part of Kernel.
And as ldl mentioned the argument syntax is different.

Might want to use or look at XMPG which is the code to load a global into a mail message. If you enter from the top it' s like a %G lister

George Lilly

unread,
Feb 21, 2012, 11:32:55 PM2/21/12
to fileman-tr...@googlegroups.com
I guess I'm just going to have to avoid ZWRITE altogether. 

^XMPG works strangly:

GTM>D ^XMPG

DEVICE: HOME//   TELNET

Global: TMP("MXMLDOM",14496,1,2
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=
^TMP("MXMLDOM",14496,1,2,"P")=1
Global:
GTM>ZWR ^TMP("MXMLDOM",14496,1,2,*)
^TMP("MXMLDOM",14496,1,2)="owl:Ontology"
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=""
^TMP("MXMLDOM",14496,1,2,"P")=1

thanks John.

gpl

glilly

unread,
Feb 22, 2012, 12:14:14 AM2/22/12
to Fileman Triple Store
Here's what I came up with to replace ZWR in the SHOW^C0XF2N case of
showing part of the MXML DOM:

SHOW(ZN) ;
I '$D(C0XJOB) S C0XJOB=$J
N ZD
S ZD=$NA(^TMP("MXMLDOM",C0XJOB,1,ZN))
W ZD,"=",@ZD
F S ZD=$Q(@ZD) Q:$QS(ZD,4)'=ZN W !,ZD,"=",@ZD
;ZWR ^TMP("MXMLDOM",C0XJOB,1,ZN,*)
Q
;

GTM>S C0XJOB=14496

GTM>D SHOW^C0XF2N(2)
^TMP("MXMLDOM",14496,1,2)=owl:Ontology
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=
^TMP("MXMLDOM",14496,1,2,"P")=1

... it almost works like ZWR
GTM>ZWR ^TMP("MXMLDOM",14496,1,2,*)
^TMP("MXMLDOM",14496,1,2)="owl:Ontology"
^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=""
^TMP("MXMLDOM",14496,1,2,"P")=1

... and I got to use $Query

... i'm not sure what to do with the error reporting uses of zwr...
probably just call ^%XTR...

gpl


On Feb 21, 11:32 pm, George Lilly <gli...@glilly.net> wrote:
> I guess I'm just going to have to avoid ZWRITE altogether.
>
> ^XMPG works strangly:
>
> GTM>D ^XMPG
>
> DEVICE: HOME//   TELNET
>
> Global: TMP("MXMLDOM",14496,1,2
> ^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=
> ^TMP("MXMLDOM",14496,1,2,"P")=1
> Global:
> GTM>ZWR ^TMP("MXMLDOM",14496,1,2,*)
> ^TMP("MXMLDOM",14496,1,2)="owl:Ontology"
> ^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=""
> ^TMP("MXMLDOM",14496,1,2,"P")=1
>
> thanks John.
>
> gpl
>

LD 'Gus' Landis

unread,
Feb 22, 2012, 9:08:18 AM2/22/12
to fileman-tr...@googlegroups.com
On Tue, Feb 21, 2012 at 10:14 PM, glilly <tango...@gmail.com> wrote:
Here's what I came up with to replace ZWR in the SHOW^C0XF2N case of
showing part of the MXML DOM:
<snip>
... and I got to use $Query


@ is your friend!! Good job!
 
... i'm not sure what to do with the error reporting uses of zwr...
probably just call ^%XTR...

gpl



Dear George,

I suppose that the data is safe... and I don't know an easy way, but it would
be good to have the mechanism wrap non-safe characters in $C() so that you
don't get squirrely results in your output... non-safe in this context means non-
printing ASCII, especially control characters.  Perhaps you could consider 
lifting the code from ZWR/ZWR1 (in WVEHR Cache version for exporting data
in ZWR format). 
 
On Feb 21, 11:32 pm, George Lilly <gli...@glilly.net> wrote:
> I guess I'm just going to have to avoid ZWRITE altogether.
>
> ^XMPG works strangly:
>
> GTM>D ^XMPG
>
> DEVICE: HOME//   TELNET
>
> Global: TMP("MXMLDOM",14496,1,2
> ^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=
> ^TMP("MXMLDOM",14496,1,2,"P")=1
> Global:
> GTM>ZWR ^TMP("MXMLDOM",14496,1,2,*)
> ^TMP("MXMLDOM",14496,1,2)="owl:Ontology"
> ^TMP("MXMLDOM",14496,1,2,"A","rdf:about")=""
> ^TMP("MXMLDOM",14496,1,2,"P")=1
>
> thanks John.
>
> gpl
>

Yikes! How is the "starting point" documented to work?  From the looks of
things, that behavior is somewhat of a surprise (to my "uneducated in VISTA"
eye). Is there a better API... I don't like to be asked questions if all I am doing
is wanting to write things out!!!
 

K.S. Bhaskar

unread,
Feb 22, 2012, 12:20:34 PM2/22/12
to fileman-tr...@googlegroups.com
http://sourceforge.net/tracker/?func=detail&aid=534145&group_id=11026&atid=311026 has code to export from the other MUMPS in the safe ZWR format.

-- Bhaskar

LD 'Gus' Landis

unread,
Feb 22, 2012, 12:25:03 PM2/22/12
to fileman-tr...@googlegroups.com, Habiel, Sam
On Wed, Feb 22, 2012 at 10:20 AM, K.S. Bhaskar <bha...@bhaskars.com> wrote:
http://sourceforge.net/tracker/?func=detail&aid=534145&group_id=11026&atid=311026 has code to export from the other MUMPS in the safe ZWR format.

-- Bhaskar


Dear Sam ... if you are lurking about...

I am *sure* that Bhaskar means MUMPS V1 here...
If you have time... that would be a very nice addition!!

Cheers,
  --ldl

K.S. Bhaskar

unread,
Feb 22, 2012, 12:25:57 PM2/22/12
to fileman-tr...@googlegroups.com
No, Gus, I did not.  Check the link out to see which MUMPS Maury wrote that code for!

LD 'Gus' Landis

unread,
Feb 22, 2012, 12:31:45 PM2/22/12
to fileman-tr...@googlegroups.com, Habiel, Sam
On Wed, Feb 22, 2012 at 10:25 AM, K.S. Bhaskar <bha...@bhaskars.com> wrote:
No, Gus, I did not.  Check the link out to see which MUMPS Maury wrote that code for!


Dear Bhaskar,

I'm *sure* it was intended as a joke ;-), or so the emphasis was intending it that way!

FWIW, Sam has fix a few bugs and has VISTA mostly running on MUMPS V1.
Terry Wiechmann is whacking at EsiObjects on it as well...

So we'll (MUMPS V1 MDC-Crew) be happy to take any "hits" as "the other MUMPS"...
since like GT.M, MUMPS V1 tries to honor the standard!

Cheers,
  --ldl

George Lilly

unread,
Feb 22, 2012, 12:39:09 PM2/22/12
to Fileman Triple Store
ok. here's how I'm handling the errors instead of using zwrite:

D CLEAN^DILF
 K ZERR
 D WP^DIE(C0XSFN,ZIEN_",",1,,ZTXT,"ZERR")
 I $D(ZERR) D  Q  ;
 . W !,"ERROR CREATING WORD PROCESSING FIELD"
 . S C0XERR="ERROR CREATING WORD PROCESSING FIELD"
 . D ^%ZTER ; error trap


BLKERR ;
 W !,"ERROR IN BULK LOAD"
 S C0XERR="ERROR IN BULK LOAD"
 S C0XLOC=ZBFDA(ZI)
 D ^%ZTER ; report the error
 B
 Q
Reply all
Reply to author
Forward
0 new messages