Eduard Lebedyuk · Apr 21, 2019 go to post

Add this line:

ENV PIP_DEFAULT_TIMEOUT 600

to the beginning of Dockerfile (after FROM of course) and try to build again.

Eduard Lebedyuk · Apr 19, 2019 go to post

You can store list properties same as array properties:

Property Collection As list Of ICT.Experiments.B(SQLPROJECTION = "table/column", STORAGEDEFAULT = "list");

Note that you need first to delete class storage if any exists and either recreate or move the data to comply with the new storage.

Eduard Lebedyuk · Apr 18, 2019 go to post

Working code:

int GetGlobalOrder(char *global, int start, int end, CACHE_EXSTRP result)
{
    if (isInitialized == false) {
        Initialize(NULL);
    }

    // narg Number of subscript expressions pushed onto the argument stack.
    int narg = 1;

    // Direction for the $Order is 1 for forward, -1 for reverse.
    int dir = 1;
    // Indicates whether the data value, if there is one, should be returned.
    int valueflag = 1;

    // Has argument flag
    int flag = 0;

    // key - current subscript
    int key = start - 1;
    
    // row count
    int c=0;

    while (key<end) {
        CACHEPUSHGLOBAL(strlen(global), global);
        CACHEPUSHINT(key);
        CACHEGLOBALORDER(narg,  dir, valueflag);

        CACHEPOPINT(&flag);
        if (flag) {
          //use CACHETYPE() to get the value type, then the appropriate CACHEPOP for the subscript
          CACHEEXSTRKILL(result);
          CACHEPOPEXSTR(result);
          // do stuff with result
        }
        //use CACHETYPE() to get the subscript type, then the appropriate CACHEPOP for the subscript
        int type = CACHETYPE();

        CACHEPOPINT(&key);

        if (key==NULL) {
            break;
        }

        c++;
    }
    return ZF_SUCCESS;
}

Thanks to  @Charles.SorensonIIfor help!

Eduard Lebedyuk · Apr 18, 2019 go to post

What does this code print?

set ^dbg = $lb(pRequest.FileStatus, pRequest.Path, pRequest.InterchangeOID)

zw ^dbg
Eduard Lebedyuk · Apr 18, 2019 go to post

Here's a sample C code to iterate over $lb structure.

#include <math.h>

/// Convert unsigned integer bytes to integer
int64_t makeint(const char *buff, size_t offset, size_t offsetinint, size_t len)
{
    union
    {
        int64_t i64;
        uint8_t u8[8];
    }d64;

    offsetinint = offsetinint & 7;
    memset(&d64, 0, sizeof(d64));

    memcpy(&d64.u8[offsetinint], buff + offset, len > (8 - offsetinint) ? (8 - offsetinint) : len);
    return d64.i64;
}

/// get next power of 2 greater than v
int64_t next2(int64_t v)
{
    v--;
    v |= v >> 1;
    v |= v >> 2;
    v |= v >> 4;
    v |= v >> 8;
    v |= v >> 16;
    v |= v >> 32;
    v++;
    return v;
}

/// List types. NONE and NONE2 are placeholders
/// See %CACHE_HOME%\dev\Cache\callout\demo\czf.pdf (Section "Lists")
enum ListTypes {NONE, STRING, USTRING, NONE2, INTP, INTN, DOUBLEP, DOUBLEN, FLOAT};

/// This function iterates over all elements in a list
void ListToTuple(CACHE_EXSTRP result)
{
    // $lb structure
    char* list = result->str.ch;
    int listLength = result->len;

    // current element
    int num = 0;

    // current byte position
    int i=0;

    // length of current element
    int l = 0;

    // datatype
    int type = 0;

    while (i<listLength) {

        // Calculate length of current element - START
        if (0 == (l = (list[i]&255))) {

            // First BYTE is 0, length is in following 2 BYTEs
            size_t t_n = ((list[i+1]&255)|((list[i+2]&255)<<8));
            if (t_n != 0) {
                  l = t_n + 3;
            } else {
                // 4 Byte length
                l = ((list[i+3]&255) | ((list[i+4]&255) << 8) | ((list[i+5]&255) << 16) | ((list[i+6]&255) << 24)) + 7;
            }
        }
        // Calculate length of current element - END

        // Calculate data position - START
        int dataStart = 0;
        int dataLength = 0;

        if (l < 255) {
            type = list[i+1];
            dataStart = i + 2;
            dataLength = l - 2;
        } else if (l < 65536) {
            type = list[i+3];
            dataStart = i + 4;
            dataLength = l - 4;
        } else {
            type = list[i+7];
            dataStart = i + 8;
            dataLength = l - 8;
        }
        // Calculate data position - END
        
        if (type==STRING) {
            char* value;
            memcpy(value, list+dataStart, dataLength);
        } else if (type==USTRING) {
            char* value;
            memcpy(value, list+dataStart, dataLength/2);
        } else if (type == INTP) {
            int64_t value = makeint(list, dataStart, 0, dataLength);
        } else if (type==INTN) {
            int64_t value = 0;
            if (l==2) {
                value = -1;
            } else {
                memcpy(&value, list+dataStart, dataLength);
                if (value == 0) {
                    value = - (1 << (dataLength * 8));
                } else {
                    int64_t pow2 = next2(value);
                    value = value - pow2;
                }
            }
        } else if (type==DOUBLEP) {
            int64_t temp = makeint(list, dataStart+1, 0, dataLength-1);
            signed char exp = list[dataStart];
            double value = temp*pow(10, exp);
        } else if (type==DOUBLEN) {
            int64_t temp = 0;
            memcpy(&temp, list+dataStart+1, dataLength-1);
            if (temp == 0) {
                temp = - (1 << (dataLength * 8));
            } else {
                int64_t pow2 = next2(temp);
                temp = temp - pow2;
            }
            signed char exp = list[dataStart];
            double value = temp*pow(10, exp);
        } else if (type==FLOAT) {
            double value;
            memcpy(&value, list+dataStart, 8);
        }
        
        i += l;
        num++;
    }
}

Eduard Lebedyuk · Apr 16, 2019 go to post

You have ASYNC calls to MS SQL operation in your Business process, right?

Add sync elements immediately after them.

Eduard Lebedyuk · Apr 15, 2019 go to post

Serenji connects you directly to the code in your namespaces, resulting in an experience more familiar to existing Studio users. No need to export and import classes and routines.

Nice!

Eduard Lebedyuk · Apr 15, 2019 go to post

Sure, there's a prebuilt docker container for that:

docker run -d -p 52773:52773 --name irispy intersystemscommunity/irispy-community:latest
Eduard Lebedyuk · Apr 15, 2019 go to post

Callin is stack-based. You push function arguments to a stack, call function, read result from stack.

These two functions are used to push and pop $lb to stack, not to get individual $lb elements.

Eduard Lebedyuk · Apr 13, 2019 go to post

After you sent ASYNC call in BP add sync activity next. Process would wait for ASYNC call to complete before going further.

Eduard Lebedyuk · Apr 12, 2019 go to post

4.4-4.6 Images do not load.

Consider using "Highlight ObjectScript" button to highlight code

Eduard Lebedyuk · Apr 11, 2019 go to post

Here's one idea (no idea if it would work though):

  1. Extract query into a new csp page.
  2. Make it auto-refresh with META TAGS
  3. Embed it into a root page using INCLUDE.

Long-term I recommend using REST API for that.

Eduard Lebedyuk · Apr 11, 2019 go to post

Please provide a minimal example if possible.

request and response objects should be available anywhere in the process job.

Eduard Lebedyuk · Apr 10, 2019 go to post

What do you mean by "After that you need to create an instance of this class and add it to HeaderOut property of your WS client."

I mean you create an object from the class using %New method.

What is HeadersOut and where do I set it?

HeadersOut is a property of your WebClient object.

Eduard Lebedyuk · Apr 10, 2019 go to post

Your error looks like it's cause because there's no HeaderOut property defined in current class.

Anyway, you need to create a custom class which would be your header:

Class custom.Header Extends %SOAP.Header
{

Parameter XMLFORMAT = "literal";

Parameter XMLIGNORENULL = "RUNTIME";

Parameter NAMESPACE = "urn:epic-com.2013.Interconnect.Headers";

/// The XMLPREFIX parameter controls the prefix to be used for the XML namespace that
/// is given by the NAMESPACE parameter.
///Parameter XMLPREFIX As STRING = "";

Parameter XMLTYPE = "Epic-Client-ID";

Property Value As %String(XMLPROJECTION = "CONTENT", MAXLEN = 36) [ InitialExpression = "12349fe5-2ff8-4b79-b723-e69efbabcdef" ];

}

After that you need to create an instance of this class and add it to HeaderOut property of your WS client.

Eduard Lebedyuk · Apr 10, 2019 go to post

That's because first code generation is run during Test.String compilation, which does not have Test method.

Add something like this at the beginning:

#; don't generate any code if it not for a property
quit:%mode="method" $$$OK
Eduard Lebedyuk · Apr 10, 2019 go to post

Thank you!

NoContext helped. What does it mean?

This works too btw:

d %code.WriteLine("  q ..Test()")
Eduard Lebedyuk · Apr 9, 2019 go to post

Okay, how do I make this work with methods?

On property get/set I need to call instance method.

I've tried this:

Class Test.String Extends %String
{

Method Get() As %String [ CodeMode = objectgenerator ]
{
    do %code.WriteLine($c(9) _ "Quit ..Test()")
    quit $$$OK
}

}

And class:

/// set obj = ##class(Test.Obj).%New()
/// w obj.prop
Class Test.Obj Extends %RegisteredObject
{

Property prop As Test.String;

Method Test()
{
    quit $random(100)
}

}

But it fails to compile.

Eduard Lebedyuk · Apr 9, 2019 go to post

Yeah, apparently only DeepSee and Ens packages/globals can be mapped successfully.

Tried random package and it didn't show up even after mapping to %ALL.

Eduard Lebedyuk · Apr 9, 2019 go to post

I created these mappings (no restarts):

  • Ens* global mapping for ENSLIB -> USER
  • DeepSee* global mapping for ENSLIB -> %ALL
  • Ens* package mapping for ENSLIB -> USER

Here's the result:

Eduard Lebedyuk · Apr 9, 2019 go to post

Turns out it's much easier than I thought:

Class Test.String Extends %String
{

ClassMethod Get() As %String [ CodeMode = objectgenerator ]
{
    do %code.WriteLine($c(9) _ "Quit $g(^Test.String, 0)")
    quit $$$OK
}

ClassMethod Set(%val As %String) As %String [ CodeMode = objectgenerator ]
{
    do %code.WriteLine($c(9) _ "Set ^Test.String = %val")
    quit $$$OK
}

}

Example:

set obj = ##class(Test.Obj).%New()
write obj.prop
>0
set obj.prop=1
write obj.prop
>1
Eduard Lebedyuk · Apr 9, 2019 go to post

I downloaded IRIS Community edition (store/intersystems/iris:2019.1.0.510.0-community) and was able to create package and global mappings without any issues.