#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 Zach McKinney · Sep 30, 2022

Issue

Breakpoints do not work when using VS Code Debug this method feature on a ClassMethod. Debug runs like normal and I can sometimes see 'running' on the CALL STACK menu. In the BREAKPOINTS menu, the breakpoints will start red, like normal, but eventually turn gray. On-hover for a grey breakpoint is the message "Breakpoint Cannot Be Mapped". After the method finishes, the breakpoint turns red again. No error messages appear. This is an intermittent issue, as sometimes it runs fine. So far, I have not been able to figure out the conditions to re-create this issue.

Any suggestions?

Edit: 

6
0 596
Question Dominic Chui · Oct 4, 2022

When using VS Code for Objectscript, is there a way to directly open % classes, like %Library.String, without needing to search for a property of that type and right clicking->"Go to Definition"?

I know it is possible to use "system=1" in the workspace uri definition to see all the % classes, but that tends to clog up the left side viewer with many extra directories. There is also the option in the settings to selectively hide some by defining files.exclude, but it seems fairly complicated to set up a filter for exactly the relevant directories.

So does anyone know the best workaround?

4
1 553
Discussion Evgeny Shvarov · Sep 25, 2022

Hi folks!

We have a bunch of templates on OEX that provide a handy foundation for building a particular application with IRIS.  And the basic principle of each and every template is that we take vanilla IRIS images, load code, and files into the image using Dockerfile, and create a new docker image as a solution. And then we develop running this image and rebuilding it when returning to development.

Some developers ask me why we need to build the docker image to work with the code. Indeed, if at the end of the day I need to develop a ZPM package and not a docker image why don't run the vanilla image and load the code and everything in it? 

The problem I have with the building image approach is that often I can wait a lot to build an image and it fails on some Objectscript problem in the source that I cannot fix as the image is not building. and 

Any thoughts? How do you develop with docker?

4
1 517
Announcement Michelle Spisak · Sep 20, 2022

If you’re on the fence about learning InterSystems ObjectScript, we’re making the decision a whole lot easier.

We just updated the “Getting Started with InterSystems ObjectScript” learning path with 3 new 5-minute videos — and a capstone exercise to help you pull together everything you’ll learn.

🤝 Get an introduction to InterSystems ObjectScript

🤿 Dive deeper into commands and functions

🤔 Understand data types and variables

👨‍💻 Create a class definition

Do it all in our updated learning path, Getting Started with InterSystems ObjectScript.

0
0 350
Question Nicola Sartore · Sep 16, 2022

Let's consider these two ways of passing an obj to a function:

//var is a structured obj
(1) do ..methodX(var)
(2) do ..methodX(.var)

In c++ if we pass an obj by reference like in (2) we save a lot in computation because we are not copying the whole object, and when the object is modified within the function it is modified also for everyone.

In this case does (2) achieve any better performance than (1)? Is passing with the "." save any computation? the object is copied anyway?

Is there a simple way of passing obj to a function?

3
0 331
Article Sarah Schlegel · Sep 7, 2022 7m read

 Hello Community!

This article gives an overview of the REST JSON webservices developed for TrakCare.

These webservices allow users to access TrakCare data from outside of the software, mainly through external apps.

They are developed in REST with ObjectScript, and they allow data access in four modes:

0
1 621
Question Michael Hellemans · Aug 31, 2022

Hello,

I need to run some clean up routine in the background so loss of my terminal session won't stop the process.

I found the JOB command in the documentation.
JOB | ObjectScript Reference | InterSystems IRIS Data Platform 2022.1
When I try it, it doesn't seem to be doing much. I also expected this to become visible in the Background Tasks but that doesn't happen either.

Probably I am missing something.

This is the command I am running:
JOB ##class(HIHLib.Support.GetHL7MessageStat).ISBListingQuery("2017-01-01","2017-02-01",0,"WAHISCL",-1,0)::10

The same command without the ::10 has the same effect.

5
1 601
Question Nils Dittberner · Aug 26, 2022

Is it possible to use integer with a higher precision so that something like this works:

ClassMethod BigNumbers()
{
    Set bigInt1 = 9223372036854775807Set bigInt2 = 9223372036854775808W !,bigInt1
    W !,bigInt2

    Set bigInt3 = 9223372036854775807123456789W !,(bigInt3 # 2)
}
9223372036854775807
9223372036854775810   // should be 9223372036854775808
0                     // should be 1
3
0 327
Question Michael McGrann · Aug 15, 2022

We are looking for a 3rd party application that can scan our IRIS based Cache Object Script code for vulnerabilities or coding weaknesses.  There are many, many applications/vendors out there that do code scanning but none seem to support Cache Object Script or scanning the IRIS environment.   If anyone is aware of a company/product that can scan our code / IRIS environment, I would love to hear about it.

Thanks in advance for the help.

Mike

3
0 580
Article Evgeny Shvarov · May 30, 2020 2m read

Hi Developers!

Sometimes we need to import CSV data programmatically to InterSystems IRIS either from CSV or from URL. And we expect the class with proper datatypes to be created and the data to be imported.

I published a module csvgen on Open Exchange which does exactly that.

If you just need the CSV file be imported into IRIS you can do the following:

USER>do ##class(community.csvgen).Generate("/usr/data/titanic.csv",,"Data.Titanic")

Class name: Data.Titanic
Header: PassengerId INTEGER,Survived INTEGER,Pclass INTEGER,Name VARCHAR(250),Sex VARCHAR(250),Age INTEGER,SibSp INTEGER,Parch INTEGER,Ticket VARCHAR(250),Fare MONEY,Cabin VARCHAR(250),Embarked VARCHAR(250)
Records imported: 891
USER>

Or if you have the CSV on the internet, e.g. COVID-19 Data on Github you can get the data in the following way:

USER>d ##class(community.csvgen).GenerateFromURL("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/05-29-2020.csv",",","Data.Covid19")

Class name: Data.Covid19
Header: FIPS INTEGER,Admin2 VARCHAR(250),Province_State VARCHAR(250),Country_Region VARCHAR(250),Last_Update DATE,Lat MONEY,Long_ DOUBLE,Confirmed INTEGER,Deaths INTEGER,Recovered INTEGER,Active INTEGER,Combined_Key VARCHAR(250),Incidence_Rate DOUBLE,Case-Fatality_Ratio DOUBLE
Records imported: 3522
USER>
16
1 1474
Article Yuri Marx · Aug 8, 2022 24m read

In this article you will have access to the curated base of articles from the InterSystems Developer Community of the most relevant topics to learning InterSystems IRIS. Find top published articles ranked by Machine Learning, Embedded Python, JSON, API and REST Applications, Manage and Configure InterSystems Environments, Docker and Cloud, VSCode, SQL, Analytics/BI, Globals, Security, DevOps, Interoperability, Native API. Learn and Enjoy!

Machine Learning

6
7 1159
Question Smythe Smythee · Aug 10, 2022

Hi,

I am receiving a JSON File as Stream container Using  pRequest As Ens.StreamContainer and output as  Output pResponse As %Persistent in a Custom Business Operation 

Please find the code below

Method OnMessage(pRequest As Ens.StreamContainer, Output pResponse As %Persistent) As %Status
{
    Set tFilename=..Adapter.CreateFilename(##class(%File).GetFilename(pRequest.OriginalFilename),..Filename)
    Set tSC=..Adapter.PutStream(tFilename, pRequest.Stream)
    Quit tSC
}

Question:How can i extract name,DOB,SSN from the pRequest and save the same values in SQL persistant table?

5
0 1002
Question Suzy Green · Aug 10, 2022

I am trying to use the IRIS connection to connect from our LIS to Health Connect (ENSEMBLE) directly.  You can do this in the same namespace using this:

##class(Ens.Director).CreateBusinessService(Ensemble Service Name,.theService)
theService.ProcessInput(TRAN,.response)

I would like to be able to do the same thing across servers using IRIS connection.  I have the following connection:

3
0 374
Question Jordan Everett · Aug 1, 2022

Does anyone have any pointers or maybe familiarity of making Email templates in Objectscript?

I'm currently trying to implement Televisits with our system and am needing to send an email to the patient. I'd like to make it a nicer looking email which will require a good amount of inline CSS. I currently have a method, but is very much a sore sight for the eyes.

I was wondering if there was a way I could use Embedded HTML and pass that into the DO msg.TextData.Write command with the ##class(%Net.MailMessage)? 

2
0 506
Question Tom Cross · Jul 20, 2022

I am reaching out to find out if anyone has come across a similar dilemma. 

In my current role, I have been asked around the best way to design some patient labels for a client.

 I primarily would stick to what I know and veered towards designing the label in ZPL and then creating a Abstract Class to call the ZPL code, however I have been asked why not to design via JReport. The patient labels will be processed via thermal ink printers primarily Zebras, I am wondering if anyone out there has come across this or  would recommend to stick to what you know. 

4
0 385
Article Danny Wijnschenk · Jul 19, 2022 4m read

Mixing Object syntax with SQL is one of the nice features in Object Script. But in one case, it gave strange results, so I decided to isolate the case and describe it here.

Let's say you need to write a classmethod that updates a single property on disk. Usually, i would write that using SQL like this :

ClassMethod ActivateSQL(customerId) as %Status
{
   &sql(Update Test.Customer Set Active=1 Where ID=:customerId)
   If SQLCODE'=0 {
      Set exception = ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, $Get(%msg))
      Quit exception.AsStatus()
   } Else {
      Quit $$$OK
   }
}
 
5
0 424