Question Eduard Lebedyuk · Apr 4, 2019 Remove last element from $lb property How can I remove elements from $lb property? Specifically last element?$list does not work with $lb properties.$listupdate can't remove elementsThe only solution I found is a temp variable and $list, but isn't there something better? #Beginner #Code Snippet #ObjectScript #Caché #InterSystems IRIS 1 6 3 683
Question Eduard Lebedyuk · Apr 2, 2019 OPC Unified Architecture Has anyone worked with OPC Unified Architecture protocol (iot/machine to machine communication protocol for industrial automation)?If so, how did you communicate with it? #IoT #Caché 0 6 0 465
Question Eduard Lebedyuk · Mar 2, 2019 Get concrete class from id 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? #Beginner #Caché 0 3 0 259
Question Eduard Lebedyuk · Feb 28, 2019 How to ignore terminators on read from TCP device 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? #Interoperability #Caché 0 1 0 245
Question Eduard Lebedyuk · Feb 28, 2019 Indirection example does not work 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 #Beginner #Caché 0 6 0 481
Question Eduard Lebedyuk · Feb 21, 2019 How do I convert timestamp to utc? 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) #Beginner #Caché 0 2 0 1.9K
Question Eduard Lebedyuk · Feb 21, 2019 SetIdentityInsert system-wide? 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? #SQL #Caché 0 2 0 284
Question Eduard Lebedyuk · Feb 18, 2019 "Pause" BPL business process on error 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:If an error is caught, call BOBO defers responseBO sends alertFix BPManually resolve deferred responseI'm not set on the exact pause/resume mechanic but I hope it makes the general idea of what I want clear enough. Ideas? #Business Process (BPL) #System Administration #Ensemble 0 4 0 277
Question Eduard Lebedyuk · Feb 6, 2019 Populating test/initial data How do you populate and update test/initial data for you classes?CSV tables? Globals export? And how do you update test data?Here's one way I found useful for small projects. #Continuous Delivery #Deployment #System Administration #Caché 1 3 0 471
Question Eduard Lebedyuk · Feb 4, 2019 Consume data from websocket 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: #Frontend #SOAP #Caché 0 17 0 1.3K
Question Eduard Lebedyuk · Jan 26, 2019 NULL placeholder in $List functions? 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? #Beginner #ObjectScript #Caché #InterSystems IRIS 0 5 0 330
Question Eduard Lebedyuk · Jan 24, 2019 Should a property be quoted in object context or not Let's say I have a property as a variable value: set propName="Country" Is there a method to determine, should I quote it to access the object, so would the correct code be: write obj."Country" or just simple write obj.Country is enough? #Beginner #Data Model #Caché #InterSystems IRIS 0 4 0 296
Question Eduard Lebedyuk · Jan 17, 2019 String or Stream in the same persistent property? 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? #Beginner #SQL #Caché 0 4 0 533
Question Eduard Lebedyuk · Jan 9, 2019 Work with devices connected via RS422/RS485 I connected from InterSystems Cache to devices connected via RS232 (commonly known as COM-port).Can the same be done with devices connected via RS422/RS485 interfaces? #Interoperability #Caché 0 2 0 209
Question Eduard Lebedyuk · Dec 27, 2018 Pattern matching with '*' and '?' 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") #Beginner #Caché 0 7 0 691
Question Eduard Lebedyuk · Dec 16, 2018 Debugging callout library <DYNAMIC LIBRARY LOAD> 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: #Caché #Callout 0 4 0 470
Question Eduard Lebedyuk · Dec 5, 2018 How do I specify System Default Setting for Production setting Added new System Default Setting for Production (not Host) setting.However, Production setting is still the same. I have tried restarting Production and instance, to no avail.How do I specify System Default Setting correctly?Production: #Beginner #Ensemble #Interoperability 0 3 0 489
Question Eduard Lebedyuk · Dec 2, 2018 Read command to get a line longer than 32767 symbols I'm using this code to read a file, line by line.Most lines are shorter than 32767 symbols, but some are longer. No line is longer than $$$MaxStringLength and long strings are enabled.Is there a param to Open/Read command I can pass to increase Read limit?My code: #Beginner #Caché 0 3 0 253
Question Eduard Lebedyuk · Nov 16, 2018 Update existing objects from XML I have a XML enabled persistent class and a XML representation of some object of this class (object ID is available).How can I use XML Reader (or some other mechanism) to automatically update this object? #Beginner #Object Data Model #ObjectScript #XML #Caché 0 4 0 526
Question Eduard Lebedyuk · Aug 29, 2018 How to replace $lb elements with empty elements 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) #Beginner #Caché 2 2 0 361