ObjectScript

Syndicate content 30 

I have a class that has a property calledTags (like DescriptiveWords, but tags), where multiple tags are possible.  I am trying to decide on list of Objects vs. array of Objects.

Based on this post: https://community.intersystems.com/post/querying-list-property-sql, sounds like using an array of Objects is the better way to go. Indeed, I already noticed that it's not possible to have duplicates when using an array of Objects.

However, I am unable to make my queries on the array of Object use an index.  

Here is a code example, with queries and the cost of the query (see the comments for each Index)I have found when running the query in Mgmt POrtal

Last answer 13 July 2018 Last comment 12 July 2018
0   0 3
178

views

0

rating

I am trying to write a generic process that will take any incoming message but would like to know where it came from so in my code I would like to do something like this

If (Document.Source="some serviceorProcess").

Just to be clear in the route you get these features is there a way of accessing them in code

Last answer 5 July 2018
0   0 2
0

comments

120

views

0

rating

Hi everyone,

I am still learning the platform for a student project and have to do some streaming and data analysis next. Since for my case I have no "live api" I wanted to just stream json files and output the data as it comes in from the files. (basically to emulate a incoming data scenario)

So thanks to the documentation and community posts I have figured how to create a stream and read data from a JSON but since I'm also new to JSON I have some parsing problems. I don't know how to access subarrays/sub-objects via objectscript.

The structure of the JSON File, I will omit some data because its large and the "rowset" has much more data

Last answer 3 July 2018 Last comment 4 July 2018
0   0 2
350

views

0

rating


Hello!

This article is a small overview of a tool that helps to understand classes and their structure inside the InterSystems products: from IRIS to Caché, Ensemble, HealthShare.

In short, it visualizes a class or an entire package, shows the relations between classes and provides all the possible information to developers and team leads without making them go to Studio and examine the code there.

If you are learning InterSystems products, reviewing projects a lot or just interested in something new in InterSystems Technology solutions — you are more than welcome to read the overview of ObjectScript Class Explorer!

Last comment 3 July 2018
+ 17   1 11
3073

views

+ 17

rating

I am working on a TrakCare JIRA issue that requires accessing class properties in a different installation of TrakCare on another machine. For instance, I need to compare the deprecated items in the current version of TrakCare to the deprecated items in a previous release. Is there anything in the built in classes that will allow me to do this, or  is it something I'll need to do with a SQL stored procedure or something else I haven't thought of?

Last answer 2 July 2018 Last comment 2 July 2018
0   0 2
112

views

0

rating

I am trying to read some binary data from a local file or through socket.

The binary data is like H.264 codec, I need to read data BYTE by BYTE (even BIT by BIT) and decide the next step based on the data read so far.

I check the documentation and it seems like most of the sample focus on human readable IO, ie: LINE by LINE.

Could I achieve my goal through COS?

Thanks. 

Last answer 27 June 2018
0   0 3
0

comments

247

views

0

rating

Typically, I have time to review the documentation, which I'm sure is here. However, I have a workaround (TEST1) but I was wondering if anyone could assist me in advising how I would need to adapt the curly brace snippet (TEST2) to provide the same result.

Thanks for any help you can provide

Last answer 26 June 2018 Last comment 25 June 2018
0   0 2
127

views

0

rating

I have a serial object:

Class EmbedObj Extends %SerialObject

which is stored as a  property of another object

Class ContainerObj Extends %Persistent

Property InnerObj As EmbedObj;

Property Foobar As %String;

Question:

From within the context of an instance of EmbedObj, how can I navigate to the containing instance of "ContainterObj" and find that value of its Foobar property?

Harder Question:  Is there a way I can do this as part of SQLComputeCode? (my EmbedObj has a Calculated property which now needs to depend on the value of property Foobar of the containing object).

Thanks in advance for any help on how to walk this relationship via Object or SQL access.

Last answer 13 June 2018 Last comment 17 June 2018
0   0 4
260

views

0

rating

Hello,

If this question is in the wrong section, I apologise.

Has anyone ever used Cache Object Script to connect to any hardware such as a sensor?

What I mean is this :-

Lets assume that code has been written in Cache Object Script where it can detect breaks in electrical connections.

There is some sort of wire/cable that is plugged into the PC and then this wire/cable runs to say a house window or door and is connected to some sort of sensor, when the window/door is closed then the circuit is complete, when the window/door is open the circuit is broken and somehow Cache Object Script knows this and then records say $H in a global.

Does that make sense and could it be possible?

Jason

Last answer 17 June 2018
0   0 2
0

comments

113

views

0

rating

Hi,

I was wondering if there is any way to count elements from an array. I guess not as an array could be multi-dimensional and that would be a problem to return the number of elements inside the array.

As an example:

S a(1) = "blue"
S a(2) = "red"
S a(3) = "yellow"
w a.count() ==> 3

Information about arrays: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

Thanks

Last answer 9 June 2018 Last comment 11 June 2018
+ 1   0 4
273

views

+ 1

rating

Hi, Community!

$CASE is a fine syntax sugar for "Ifs" with one-line/one-word expressions, like in docs:

SET daynum=$ZDATE($HOROLOG,10)
  WRITE $CASE(daynum,
              1:"Monday",2:"Tuesday",3:"Wednesday",
              4:"Thursday",5:"Friday",
              6:"Saturday",0:"Sunday",:"entry error")

But if my expression for a current case is a multi-line business logic? Can I use "{}" somehow or better go with "IF" instead?

Last answer 6 June 2018 Last comment 6 June 2018
0   1 4
325

views

0

rating

Currently, we are receiving an alert that states, "Write Daemon still on pass 31". It's been that way for a few hours.

I was wondering if it is possible to identify what the WD has left to work on so that we can see how we can reduce this and possibly identify if there are issues with the way something is written.

Thanks in advance for any insight.

Last answer 2 May 2018 Last comment 3 May 2018
0   0 4
149

views

0

rating

Sometimes, we need to copy part of the properties of an object into a different one. 
The simplest thing would be to do the following:

Set obj1.FirstName = obj2.FirstName

Set obj1.SecondName = obj2.SecondName

What happens if the object contains a large number of properties? or we just want to extract an important group of data, and complement the information in another object?

Having the following classes

Last comment 2 May 2018
+ 4   0 4
407

views

+ 4

rating

A function iterates global ^data(a,b,c) with $order using 3 nested for-loops. At certain point, for example with a=10, b=20, c=30, the function exits and later has to resume the iteration from the same point. What could be easiest way for it? My solution looks too ugly.

Last answer 16 April 2018 Last comment 30 April 2018
0   0 6
448

views

0

rating

Hi, Community!

Coding guidelines discussion. Consider you have For with one command in the cycle. Here are the options:

One

For i=1:1:1000 set ^Test(i)=""

Two

For i=1:1:1000 {

 set ^Test(i)=""

}

Same for the "If":

if a set b=a

or

if a {

 set b=a

}

Your choice? Or maybe even other options? 

Last comment 27 April 2018
0   1 14
858

views

0

rating

Hi,

I need to read a UTF8 encoded text file and translate the content to 8-bit.

Using %File class and $ZCVT(TXT,"I","UTF8") works , but I see that if the content is larger than max string  (32000) and we cut the content

To max string chunks, we can get a <translate> error if we cut it in the "wrong" point..

Is there a better way to do this task?

My code looks like this:

    S file=##class(%File).%New(..LocalFileName)
    D file.Open("R")
    While 'file.AtEnd {    
        S Line=$ZCVT(Line,"I","UTF8")
    }
    D file.Close()

and an example of such an error:

USER>s str=$C(215)
USER>w $ZCVT(str,"I","UTF8")
W $ZCVT(str,"I","UTF8")
^
<TRANSLATE>

Regards,

Nael

Last answer 16 April 2018 Last comment 16 April 2018
0   0 2
350

views

0

rating

Morning guys  I have a SQL operation that I use to read data and results to a record map. But seems to have trouble saving the objects to a record map as I get this message

ERROR ErrException: zInsertObject+2^%Library.RelationshipObject.1 -- logged as '-' number - @''

please help  here is my code let me know if I missing anything thank you in advanc

Last answer 5 April 2018
0   0 2
0

comments

152

views

0

rating

I've been writing ObjectScript for a long time and was a little surprised by this behavior so I'd like to understand what is going on.

I was doing a peer review on some source which had roughly the equivalent of the following line:

Set myRecord = ##class(MyObj.Record).%OpenId(id)
Set emailList = previousEmails_","_myRecord.RecordGroup.EmailList

I flagged it for further testing because the code didn't check if RecordGroup was set and I knew that not all records were part of a Group so I was expecting that in cases where it wasn't set this line should throw an <INVALID OREF>

However, it turns out that I had forgotten that in the MyObj.Record class, RecordGroup is actually a one:many relationship:

Last answer 23 March 2018 Last comment 23 March 2018
0   0 3
134

views

0

rating

Hello community,

I need to perform some processing-heavy operations on a set of input objects and I would like to utilize more than a single processor core to do the heavy lifting.

Is there any way to call methods in parallel and wait for the results in a blocking way?

Basically, I am looking for an equivalent of the pythonese

with Pool(n) as p:
    results = p.map(function, data)

Thanks

Jiri

EDIT: Correct English :)

Last answer 9 March 2018 Last comment 9 March 2018
+ 1   0 2
223

views

+ 1

rating

This series of articles aims to address the following topics:

  • Creation of a web application based on REST pages;
  • Overview of some tools for tracing (debugging) HTTP requests;
  • Switching from hyperevents to... hyperevents;
  • Integration with jQuery File Upload;
  • Conversion of JSON from the {id:1,parentId:1} format to the {id:1,children:[{}]} format for tree visualization;
  • Integration with jQuery EasyUI (using datagrid and tree as examples);
  • Other topics.

Last comment 8 March 2018
+ 4   0 3
514

views

+ 4

rating