Kurro Lopez · Aug 23, 2017

$Order and $Next in Cache Basic script

Hi all,

I need to create a routine to modifiy some values in a global.

My first attempt was:

    // Search the first position of Messages
    set pos=$Order(^Ens.MessageBodyD(""))
    while(pos > 0){
        // Get the class name
        set clase = $Order(^Ens.MessageBodyD(pos,1))
        if (clase="MensajesRestResponse")
            // Do the convertion
        set pos = $Next(^Ens.MessageBodyD(pos))

but if I use a *.bas file (cache basic script), I'm not able to use these commands ($Order and $Next) and I don't know how to translate theses words.

please, could the comunity help me?

My goal is convert the content of the message (old mesages) from %String to %Stream.GlobalCharacter because now there are some values in string and other are on Stream.GloablCharacter and there is not match in ^Ens.MessageBodyS for these messages.

Best regards,

Francisco Lopez

0 423
Discussion (3)2
Log in or sign up to continue

Why do want to use basic for that?

Generally not good practice to mix $order and $next. $next uses -1 for "end of set", which of course is a valid global subscript. $order uses the null string, which on almost all Cache instances out there is not valid.

Also, this line:

        set clase = $Order(^Ens.MessageBodyD(pos,1))

Should probably be this although I doubt this actually works: you need to use $listget(clase,1) or something similar:

        set clase = $Get(^Ens.MessageBodyD(pos,1))

And test for the While loop exit should be:

       while (pos'="")

However, I would stay away from direct global access unless you really need it. Stick to SQL for querying/updating , or objects for updates.