Storing Carriage Return $c(13) and Line Feed $c(10) in global.

729 views
Skip to first unread message

Melissa Laurel

unread,
Feb 29, 2016, 5:08:21 PM2/29/16
to Caché, Ensemble, DeepSee

I hope someone can help, because I am banging my head with this. I have looked into $ZF, LineTerminatorSet, and more, and I am thinking there must be some Cache Property or Method that I could call to do what I am trying to do.


The problem is I have to develop HL7 reports that require either carriage return or carriage return and line. It varies depending on which client it is. We decided we would make a global which is site specific and provides us flexibility. If the global isn't defined, we default to $c(13).


This is the global is set to 

 $g(^MEL("HEDIS",SITEID,"Out","Info","EOL"))="$c(13,10)"


This is the code.


 i $E(TBLTYP)="E" {
    eol=""
    eol=$g(^MEL("HEDIS",SITEID,"Out","Info","EOL"))
    if eol="" eol=$c(13) }
    SEGMENT=SEGMENT_eol
 }


Well what is happening is as follows:


|ORU^R01|20160225163327|P|2.3$c(13,10)


As you can see it didn't insert the CR/LF. It actually displayed $c(13,10). I am using Notepad ++ to open the file, and have it set to see all characters.


Went back to the drawing board and did this:

   $E(TBLTYP)="E" {
    set eol=$c(13)
    set override=$g(^MEL("HEDIS",SITEID,"Out","Info","EOL"))
    if override'="" xecute "set eol="_override }
    set SEGMENT=SEGMENT_eol
 }


I really don't think this is the best way of doing this Is there some Cache Function/Utility that can do this?

Thanks

Melissa

OldMster

unread,
Feb 29, 2016, 5:20:59 PM2/29/16
to Caché, Ensemble, DeepSee
^MEL("HEDIS",SITEID,"Out","Info","EOL") should be set to $c(13,10), not "$c(13,10)".  By putting the quotes around $c(13,10) you are telling it to store the literal string $c(13,10).  Leave the quotes off, and you are telling it to store a 2 character string whose first character is ascii decimal value 13, and the second character has the ascii decimal value of 10

Issue the following command string:

Set ^MEL("HEDIS",SITEID,"Out","Info","EOL")=$Character(13,10)

And your code should work fine.

Whoever set that global used this instead:

Set ^MEL("HEDIS",SITEID,"Out","Info","EOL")="$c(13,10)"

Mark

Melissa Laurel

unread,
Feb 29, 2016, 6:11:33 PM2/29/16
to Caché, Ensemble, DeepSee
Mark,
thank you so much. I actually had considered that, but the only issue with that is that when you want do display the globals, to see the Hierachy, etc...
you will have to $ASCII to see what it is.

Like if I do D ^%G to display the global tree, it will appear blank:
DEV5>Set ^MEL("HEDIS",SITEID,"Out","Info","EOL")=$c(13,10)
 
DEV5>W ^MEL("HEDIS",SITED, "Out","Info","EOL")
 
 
DEV5>W $ASCII(^MEL("HEDIS","Out","Info","EOL"))
13
DEV5>

My SITEID can vary.
so if I did the following to list the EOL of all sites, I couldn't distinguish them. I would have to do the $ASCII in front of each global. 
Right margin: 80 =>
Screen size for paging (0=nopaging)? 24 =>
For help on global specifications DO HELP^%G
Global ^MEL("HEDIS",,"OUT","Info","EOL"

Can I store the binary number or HEX number for Carriage Return and store that in the global and convert in CACHE?

OldMster

unread,
Feb 29, 2016, 9:09:02 PM2/29/16
to Caché, Ensemble, DeepSee
Melissa,
There is not automatic conversion in Cache, or any other database that I'm aware of.  Depending on your version, if you ZWrite ^MEL("HEDIS",SITEID,"Out","Info","EOL") it will display unprintable characters in $c().  In this case $c(13,10).  Examples of using ZWrite are below (it prints the selected node, and any lower nodes with the same subscripts)

USER>Set ^TEST("This","Level",1)=$c(13,10)

USER>zw ^TEST
^TEST("This","Level",1)=$c(13,10)

USER>Set ^TEST("This","Level",2)=$c(2,3)

USER>zw ^TEST
^TEST("This","Level",1)=$c(13,10)
^TEST("This","Level",2)=$c(2,3)

USER>zw ^Test("This","Level",1)

USER>zw ^TEST("This","Level",1)
^TEST("This","Level",1)=$c(13,10)

Michae...@kp.org

unread,
Mar 1, 2016, 8:37:25 AM3/1/16
to intersystems...@googlegroups.com
Melissa, if it's important enough for you to have the global be display-friendly that you don't mind a little less display-friendliness in the code, you could leave your global set to "$c(13,10)" and change your code to this:

>  i $E(TBLTYP)="E" {
>     s eol=""
>     s eol=$g(^MEL("HEDIS",SITEID,"Out","Info","EOL"))
>     if eol="" { s eol="$c(13)" }    <-- quote this one too
>     s @("SEGMENT=SEGMENT_"_eol)     <-- then use indirection to set SEGMENT
>  }


(As a side note, you really don't need the initial 's eol=""' since on the next line you set eol to $g(something), which will either set it to the value of that global reference or to null.  :-) )
> --
> --
> Caché, Ensemble, DeepSee
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Caché, Ensemble, DeepSee" group.
> To unsubscribe from this group and stop receiving emails from it, send anemail to
> intersystems-publi...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages