Question
· Feb 23, 2020

$list returning symbols along with results...

First,

Forgive me if this is a rather low-level question - I am a physician informaticist who is learning cache/mumps for the first time. I am sure this probably relates to some setting but I can't find a similar issue anywhere.

 

When I create a list, and then try and return that list - I get a bunch of symbols back along with my results, or sometimes I just get symbols. 

I pasted a screenshot below.  Thank is advance for the help!

 

Anthony

Discussion (6)1
Log in or sign up to continue

$lb is a binary format, when you try to write it you just outputs everything including special symbols.

zwrite command, can do it respectively to format.

zzdump can show how it looks in real, it's byte sequence.

USER>zw $lb("words","more","words")
$lb("words","more","words") 

USER>zzdump $lb("words","more","words") 

0000: 07 01 77 6F 72 64 73 06 01 6D 6F 72 65 07 01 77         ..words..more..w
0010: 6F 72 64 73                                             ords

USER>zzdump $lb(1,2,3,4,5)              
0000: 03 04 01 03 04 02 03 04 03 03 04 04 03 04 05            ...............

But it is not so important how it looks low-level, as we mostly don't care about it.  Developers work with $ListBuild mostly through a bunch of functions, such as $list, $listget, $listnext and so on. You can find more information about $listbuild in the documentation, as well as many examples, and all functions which can be used to work with it.

Dmitriy,

Thank you for this. It was confusing because the tutorials for this, nor any of the books I have (I am using the Paul Kadow text) mention that I will have random symbols put in the middle of my list elements. So the book says entering "write [listname]" should return "dogcatfish" but in reality you are telling me that command doesn't do that, and that these symbols will always be there? I guess its frustrating that the Kadow book doesn't warn of this, since I spent hours trying to figure out what was wrong with my system/set up.

 How would one return multiple elements of a list then without having the symbols? Perhaps I am not really asking a great question - but I'd have to wonder what the point is of having a command that prints "garbage" symbols between list items.

To Dmitry's words I will add a few links from the documentation:

In your case, be the $LISTTOSTRING function is useful, for example:

USER>set first=$lb("words","more","words")
USER>write first
words-morewords
USER>write $listtostring(first)
words,more,words
USER>write $listtostring(first,"^")
words^more^words
USER>write $listtostring(first,"")
wordsmorewords

I think that the result of "dogcatfish" in the book was due to copying/pasting, which caused the service characters to be lost.

By the way, here on the forum it’s also not so easy to insert this gibberish ;)

Thanks to everyone for the great responses. Forgive me, but it doesn't let me pick multiple "accept as answer". :) Also, I don't mean to sound so naive as to imply "but the book", just trying to understand the underlying thinking, etc.

It sounds like $LISTTOSTRING is exactly what I am interested in. 

Thanks again, for the responses and for tolerating my rather noob question :). 

Anthony