Hello Kevin,

if I anderstand you correctly, several your Cache systems (development, life, ...) will store their files on a third server (possibly on a file server) and you want to put the files from each (source) Cache (instance) into a different (target) folder, where the folder name being the "name" of the source Cache system - am I correct?

If yes, I think, your best choice ist:

...\hostNameOfCache\instanceNameofCache...

or, as John Murray suggested

...\GUIDofCacheInstance...

or just a fixed string like

...\kevinNotebook(development)...

You can put (John's) GUID or my "fixed string"
in a (possibly system) Global like ^%Zconfig("path")=...

Why?
Things like MAC- or IP-Addresses can change more often then you think. Especially IP-Addresses will change, hence are there DNS servers.

On the other hand, it's uncommon to change host- or instance names (of Cache or of whatever installation).

Your IP-Address preference has an other downside too. Many servers have more then one IP-Address (and if they do not have one today, maybe tomorrow!).

If you persist to take the systems IP-Address, here is, what you wanted:

set iplist = $system.INetInfo.GetListOfConfiguredInterfaces(0)
for i = 1:1:$listlength(iplist) zw $list(iplist,i)

Regards and
have a nice day
Julius

You are comparing apples wih oranges!

The line  (your case 1):

set dat=$lg(^TestD(id))    //dat=$lb("a","b","c","d","e")

sets dat to the FIRST list item (if present, or to "", if the list item is NOT present) of ^TestD(id)  but ONLY if ^TestD(id) is defined AND it is a Cache list.

In elsecase, you will get an <UNDEF> if ^TestD(id) does not exists or an <LIST> error, if ^TestD(id) exists but the content is not a list!

The line (your case 2):

 set dat=$g(^TEST2(id))   //dat = "a#b#c#d#e"

sets dat to the content of ^TEST2(id) , if  it exists or to "", if there is no ^TEST2(id)

Class your.class
{
Property Colors As list Of %String;


ClassMethod toJson(list) As %String [ SqlProc ]
{
    s json=""
    f i=1:1:$ll(list) {
        s:i>1 json=json_"," s item=$lg(list,i)
        if '$ld(list,i) { s json=json_"null" }
        elseif item="" { s json=json_"""""" }
        elseif $lv(item) { s json=json_..toJson(item) }
        elseif $num(item,".")=item { s json=json_$fn(item,"N") }
        else {
            f c="\","/","""",$c(8),$c(9),$c(10),$c(12),$c(13) s item=$replace(item,c,"\"_$tr(c,$c(8,9,10,12,13),"btnfr"))
            f  q:'$locate(item,"[:cntrl:]",0,j,v)  s $e(item,j-1)="\u"_$e($zh($a(v)+65536),2,5)
            s json=json_""""_item_""""
        }
    }
    
    q "["_json_"]"
}
}

select your.class_toJson(Colors) from your.class

gives you the expected result . If you prefer  a direct  use of globals, then use

write ##class(your.class).toJson($lg(^your.global(theOID),theSlotNumber))

my quick test says there are two chars, CR and LF, on an AIX and on Ubuntu

USER>s str=##class(%GlobalCharacterStream).%New()
USER>d str.WriteLine("Test")
USER>d str.Rewind()
USER>zzdump str.Read(100)
0000: 54 65 73 74 0D 0A                                       Test..
USER>
​USER>w $zv
Cache for UNIX (IBM AIX for System Power System-64) 2017.1 (Build 792U) Mon Mar 20 2017 19:19:37 EDT
USER>

-----------------

USER>s str=##class(%GlobalCharacterStream).%New()
USER>d str.WriteLine("Test")
USER>d str.Rewind()
USER>zzdump str.Read(100)
0000: 54 65 73 74 0D 0A                                       Test..
USER>
​USER>w $zv
Cache for UNIX (Ubuntu Server LTS for x86-64) 2017.1 (Build 792U) Mon Mar 20 2017 19:22:31 EDT
USER>

Maybe, your problem has nothing to do with Cache?

Regards,

Julius