I have one abstract class and several subclasses. All share one data/id global.

How can I get concrete class name from id (without opening the object)?

What I have so far:

write $p($lg(^DATAGLOBAL(<id>),1),"~",*-1)

It does the job, but is there a more official way?

0 3
0 259

I'm connecting to a remote device using TCP. It has a binary protocol.

set host = ""
set port = ""
set io = $io
set device = "|TCP|7000"

set timeout = 2
open device:(host:port:"M")
use device:(/IOT="RAW")
read string:timeout

use io
zzdump string

The problem is when reading from it, I get a 0A (also known as 10 or \n or linefeed) byte, which terminates the read.

Expected output:

0000: 42 00 7B 0A 11

But I get this output:

0000: 42 00 7B

How can I fix that?

0 1
0 245

Here's a simple indirection snippet. It fails with <UNDEFINED> error and I'm not sure why.

ClassMethod ind()
{
  kill info

  set active = 1
  set reactive = 2

  for i="active","reactive" {
    set info(i)= @i
  }

  zw info

  break
}

I'm getting this exception: <UNDEFINED>zind+5^test.Client.1 *active

0 6
0 481

I have a date in this format: "YYYY-MM-DD HH:MM:SS+HHMM" how can I convert it to UTC?

write $zdth("2018-02-01 00:00:00+0600",3,5)
>64680,0
write $zdt("64680,0",3,5)
>2018-02-01T00:00:00+03:00

As you see, timezone is lost. Docs for $zdth in timeopt (5) state: Specify time in the form "hh:mm:ss+/-hh:mm" (24-hour clock). The time is specified as local time. The following optional suffix may be supplied, but is ignored: a plus (+) or minus (–) suffix followed by the offset of local time from Coordinated Universal Time (UTC)

0 2
0 1.9K

SetIdentityInsert call controls the ability of the user to specify a value for the IDENTITY property when saving a new object, a value for the IDENTITY column or an explicit ROWID value in an SQL INSERT. If IDENTITY_INSERT is false and the user specifies an explicit IDENTITY or ROWID value when saving a new object or inserting a new ROW then an error condition is reported.

Setting takes effect immediately and lasts for the duration of the process or until SetIdentityInsert is called again.

My question is how can I change this setting system-wide?

0 2
0 284

I have a business process.

if it has an error it dies, or if a have a catch all/fault handler the execution flow goes there.

However, I want another behavior.

If any error occurs I want the process to "Pause" (and alert me), so I can figure out what went wrong and resume from the last request.

Here's an example of how it could work:

  1. If an error is caught, call BO
  2. BO defers response
  3. BO sends alert
  4. Fix BP
  5. Manually resolve deferred response

I'm not set on the exact pause/resume mechanic but I hope it makes the general idea of what I want clear enough. Ideas?

0 4
0 277

I want to consume external websocket api, URL looks like this:

wss://site.com/ws/v2/?&token=<token>

Checked with external tool (Simple WebSocket Client) that websocket works and I can consume the data.

In Cache the relevant functionality is offered by %IO.Socket class.

set sock = ##class(%IO.Socket).%New()
set sock.SSLConfig = "MyEmptySSLConfig"
set sock.TranslationTable="UTF8"
do sock.Open("site.com/ws/v2/?&token=<token>","443", 10,.sc)

However I get this error:

0 17
0 1.3K

Today in docs I found this example using NULL:

 WRITE $LISTVALID($LB(NULL)),!

simplified

zzdump $LB(NULL)

and NULL can be case-insensitive:

zzdump $LB(null)

seems the same as just:

zzdump $LB()

But if null variable is defined then list would contain value from variable. Case sensitive in that situation.

Does anyone have any Idea what is this? Is NULL used anywhere besides as a list element?

0 5
0 330

I have a persistent class.

I want to store one of the properties there as a stream or a string depending on a size.

99% of values would be strings (less than $$$MaxStringLength characters) so I don't want to store everything as streams.

What do you think of this approach?

What's the best architecture to implement in this situation?

0 4
0 533

I have an in-memory list of items and I want to check which items match my pattern string.

Pattern string is a comma-separated list of items and special symbols like '*' and maybe '?'.

There's something similar in $system.OBJ.Compile, it accepts patterns: "*.data.*,Sample.*" - and it would compile 'Sample' package and all 'data' packages.

For example:

set list=$lb("abc", "c", "aaa", "bbb")
set result = ..match(list, "a*,*b")
zw result
result=$lb("abc","aaa","bbb")
0 7
0 691

I have a simple callout library:

#define ZF_DLL
#include 
#include 
#undef ERROR

int GetRandom(double* random) {
   // Py_Initialize();
   // Py_Finalize();
   *random = 1.0;
   return ZF_SUCCESS;
}

int main(int argc, char **argv)
{
   printf("Random: ");
   double random=0;
   GetRandom(&random);
   printf("%lf", random);
   return 0;
}

ZFBEGIN
    ZFENTRY("GetRandom","D",GetRandom)
ZFEND

I compile this code as a shared library and it works fine with:

0 4
0 470

I have a list

set list=$lb(1,$c(0),2)

How do I replace $c(0) with an empty element?

My list should look like this:

set list=$lb(1,,2)

I tried using $list but it either replaces the element with an empty string:

set $list(list,2)=""
zw list

Resulting in:

list=$lb(1,"",2)

Or removes the element altogether:

set $list(list,2,2)=""
zw list

Resulting in:

list=$lb(1,2)
2 2
0 361