#ObjectScript

14 Followers · 1.6K Posts

InterSystems ObjectScript is a scripting language to operate with data using any data model of InterSystems Data Platform (Objects, Relational, Key-Value, Document, Globals) and to develop business logic for serverside applications on InterSystems Data Platform.

Documentation.

Question Stuart Byrne · Jun 4, 2020

Dear All, 

I am currently working on a project to record ORU^R01 into a global for a particular set of tests.

I have multiple OBX repeats that need to go into a specific fields withing one row/ record on the global.

I am having trouble finding a way to either count or loop though the OBX's correctly in ObjectScript often with the counter being undefined.

I have done this this way, as I am building upon an existing class to populate this global.

The latest iteration of my obx looping code is below:

8
0 1594
Article Bernd Mueller · Jan 30, 2018 13m read

Some time ago I got a WRC case transferred where a customer asks for the availability of a raw DEFLATE compression/decompression function built-in Caché.

When we talk about DEFLATE we need to talk about Zlib as well, since Zlib is the de-facto standard free compression/decompression library developed in the mid-90s.

Zlib works on particular DEFLATE compression/decompression algorithm and the idea of encapsulation within a wrapper (gzip, zlib, etc.).
https://en.wikipedia.org/wiki/Zlib

6
2 2827
Announcement Anastasia Dyubaylo · Jun 1, 2020

Hi Community!

This week is a voting week for the InterSystems IRIS Native API Programming Contest! We have 8 applications — so you have a set of applications to choose from!

 

How to vote? This is easy: you will have one vote, and your vote goes either in Experts Nomination or in Community Nomination.

5
1 418
Question Arto Alatalo · Apr 29, 2020

Hi Community! I need your advice.

The method below is 6 times slower on production server than on developing machine:

ClassMethod runme4()
{
    s cnt=615210
    s st=$zh
    for i=1:1:cnt {
        s p=##class(digi.packet).%OpenId("packet||5237")
        w:p="" "not found",!
        k p
    }
    w $zh-st,!
}

BUT the server is 6 times faster if OpenId replaced with simple read of a large global (s p=^someLargeGlobal). Any ideas what makes OpenId so slow only on the server?

27
0 1234
Article alex kosinets · Feb 24, 2020 2m read

In MX any global can be displayed on a sheet in the form of a table.

We will look at the simplest example (work only with  CACHE-2014+ or IRIS)

Upgrade or install  MX.

Start mx.xlsb  and connect to your namespase with vmx-routines.

After opening first sheet, click button  []   ##class(SYS.Stats.Dashboard).Sample()

Then press button [design-mode]   (top of screen ).

You will see something like this in the top four lines:

M-Formulas works in cells in the process of opening this sheet,  step by step :

5
0 650
Question Colin Parker · May 26, 2020

I am using the Java Binding to connect a Java Middleware Application to Cache.  Originally I was using a CacheListOfDataTypes (JAVATYPE = "java.lang.List") object to bring data back.  I was tasked with encrypting the data using AES and I was using the AESCBCEncrypt function on the List elements (up to 20k characters for each element) to bring it back before concatenating it on the middleware.  This almost worked.  Like 95% of the characters were being decrypted correctly but some text was coming back garbled.  I couldn't understand how this was happening. I tried to adjust things like the

3
1 594
Announcement Anastasia Dyubaylo · May 19, 2020

Hi Community!

We are glad to invite every developer who uses ObjectSript and VSCode plugin to the second webinar hold by the VSCode ObjectScript plugin developer on May 26  at 11:00 EDT. 

You will learn how to develop InterSystems IRIS solutions using GitHub Development Flow with VSCode ObjectScript and Docker.

Speaker: @Dmitry Maslennikov, InterSystems Developers Advocate, CTO at CaretDev.

6
1 782
Question Daniel Lee · May 26, 2020

I have a class method that accepts a global parameter but when I attempt to order this global, the global name is listed as undefined. I can execute $DATA(pGlobalName) successfully.

ClassMethod ExamineGlobal(pGlobalName As %Global)
 {
   set gStatus=$DATA(pGlobalName) ; returns 1 
    write "This is the global name: "_pGlobalName
   set gmin=$ORDER(pGlobalName("")) ; here pGlobalName is undefined
 }

In debug mode, data returns 1 for a valid global with no descendants. This is expected.

3
0 387
Article Evgeny Shvarov · May 25, 2020 2m read

Hi ObjectScript developers!

How to Protect Your Belongings from Pests While Moving - Delicate ...

InterSystems ObjectScript is perhaps the best language on the planet to deal with globals - and it is an interpretable language.

Yes, it has a compiler. But even the compiler can compile some lines in ObjectScript which will then fire as bugs during the runtime.

There are some technics on how to avoid that such as unit testing, coding guidelines and your coding experience, of course ;)

Here I want to present to you the yet another approach to how you can reduce the number of errors in your ObjectScript runtime and enforce coding guidelines - it's an ObjectScript Quality tool developed by Lite Solutions, InterSystems solution partner.

See the details below.

0
0 518
Question Yone Moreno · May 19, 2020

Hello,

We are trying to connect to a database through a JavaGateway.

We observe that the JavaGateway reports:

Failed to start the Java Gateway server: ERROR #5002: Error de cache: <UNDEFINED>zGetJavaVersion+22^%Net.Remote.Service.1 *versionWithPrefix

We have checked that we do have the Java Home set:

/usr/java/jdk1.8.0_65

And we have seen the java files in the server:

We have read the code where the exceptions being raised:

2
0 728
Question Laura Cavanaugh · May 11, 2020

Hello all, I have a question about constucting thousands of clones, and scope.

In my code, I'm looping through a database, say 200k+ objects, and creating a clone of each object (we need to evaluate a modified clone of the object, but not account for what's on disk).  

I see this a lot in the documentation:

7
0 845
Announcement Anastasia Dyubaylo · May 8, 2020

Hi Community,

We're pleased to invite you to join the upcoming InterSystems IRIS 2020.1 Tech Talk: Integrated Development Environments on May 19 at 10:00 AM EDT!

In this edition of InterSystems IRIS 2020.1 Tech Talks, we put the spotlight on Integrated Development Environments (IDEs). We'll talk about InterSystems latest initiative with the open source ObjectScript extension to Visual Studio Code, discussing what workflows are particularly suited to this IDE, how development, support, and enhancement requests will work in an open source ecosystem, and more. 

 

1
0 483
Discussion Murillo Braga · May 13, 2020

Hello guys, 

I have used the Studio SOAP wizard to generate some webservice client classes and amongst those classes:

Class RMH.SOAP.s0.Output Extends (%Persistent, %XML.Adaptor) [ ProcedureBlock, SqlTableName = _Output ] {
...
Property Value As %GlobalCharacterStream(XMLNAME = "Value");

And the caller looks like

Class RMH.SOAP.SoapTreeSoap Extends %SOAP.WebClient [ ProcedureBlock ] {
...
Method Run...(Tree As %String, Inputs As %String, Debug As %Integer) As RMH.SOAP.s0.Output 
3
1 621
Article Evgeny Shvarov · Nov 21, 2019 7m read

Hi Developers!

As discussed in previous parts of Package Manager stories to turn your IRIS application into a deployable package you just need to introduce the module.xml file into the root folder of the repository and describe all the resources.

I’m pleased to introduce you to a new project template on Open Exchange which contains examples of how to make different types of resources of your InterSystems IRIS application a part of the ObjectScript package and so make the deployable ObjectSctipt package.

Let's see how you can describe your application resources using this template project as an example.

See the details below.

2
7 671
Article Robert Cemper · May 14, 2020 3m read

Using the IRIS native API for Node.JS was the opportunity to present
a MicroService operating in a Docker container.
A demo video is now also available to watch the demo in operation.

Instead of a utility you call directly on your IRIS host you now send a work-packages
to the MicroService as would typically do with System Interoperability (aka.ENSEMBLE):
of course, you have the option of more than one WebSocket Server.
Once the WebSocket Client Service has done its job you get back the result from it.

0
1 1243
Question Jo Ellen Laansma · May 13, 2020

I have a class that writes to an external SQL Server database.  When the field is empty, it does not write the column and the column has the value NULL.  In some cases, I want the column to be the value of the empty stringinstead of NULL.

Class myRequestClass Extends Ens.Request
{

    Property MessageType As %String

}

The message that is passed to this class shows:

    <MessageType></MessageType>

Which writes the field as NULL with:

    tSQL = "insert into myTable (MessageType) values (?)"

    set tSC = ..Adapter.ExecuteUpdate(.tNumberOfRowsUpdated,tSQL,myRequestClass.MessageType)

5
0 16781
Question Arto Alatalo · Apr 15, 2020

If two globals have same structure, how to reuse one CacheSQLStorage-based class to read both locations?

Thanks!

Update:

Let's say we have two globals:

^a(1)="dataa1"
^a(2)="dataa2"

and

^b(1)="datab1"
^b(2)="datab2"

i.e. the structure difference is global name only.

I would like to have two classes TableA and TableB both are inherited from TableAB, and TableAB taking global name as a parameter.

14
0 772
Question Yone Moreno · May 11, 2020

Hello,

We would like to know if Ensemble could generate a CADES sign from a string and a certificate.

We have read:

https://cedocs.intersystems.com/latest/csp/docbook/Doc.View.cls?KEY=GXM…

So we have seen that we could create a class, to sign a document, and store the sign inside that new class. We have also seen that there are some different algorithms to choose from, like sha1.

In addition we have also consulted the CADES sign definition:

https://tools.ietf.org/html/rfc5126

The use case is to avoid being dependant of an external web service, and be able to generate it.

1
0 224
Question Paul Beckett · Jun 16, 2016

Hi,

I have a bit of code that does a find and replace on a "template" and inserts additional content. For example it replaces the @DATA@ with an html table:

<html>

   <body>

      <div id="data">@DATA@</div>

   </body>

</html>

Currently doing this with the $replace function:

Set text=$replace(text, "@DATA@", data)

The problem is the "data" is now too big for a %String (yes even with large strings) so will switch to use a stream instead. 

5
0 1832
Question Russell Carpio · May 7, 2020

We are getting CoClass not available [80040111] when using %Net.SSH.Session.  Does anyone know if there is a security setting that would disable this object?

Any help would be greatly appreciated.

3
0 368
Question Stuart Byrne · Mar 10, 2020

Dear All,

I'm looping through a list with characters (Parenthesis, square brackets etc) and I wish to remove these from the list.

The for loop and IF logic are effectively removing these items from a list.

However the variable I use for the maximum number of loops carries on beyond the number of items of the list after removal.

In the output value for these I get the integer of the for loop instead of a  null for the empty list fields.

I can see in the documentation that the end variable is not editable once the loop is started.

12
0 824
Article Evgeny Shvarov · May 11, 2016 1m read

Hi!

I believe the simplest is (to work with csv delimited by ";"):


set file = ##class(%File).%New( "data.csv" )
    set sc = file.Open( "R" ) 
    if $$$ISERR(sc) quit    ; or do smth

    while 'file.AtEnd {
        set str=file.ReadLine() 
        for i=1:1:$length( str, ";" ) {
            set id=$piece( str, ";" ,i ) 
            write !, id  // or do smth
        }
    }
    do file.Close()

Possible options:

different variants of error handling with sc code.

Embrace while loop into try/catch block.

And what's yours?

16
0 7270