#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 Scott Roth · Apr 19, 2023

I wrote a function awhile back to take Encoded Base 64 and write the PDF out to a file that could be sent to a faxing system to fax out. We are trying to test this code out in IRIS and I am seeing an error that I have not seen before... ERROR #5034: Invalid status code structure

Here is the code...

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String

{

  set ArchDir = "/ensemble/data/transfer/AncillaryPDF/"

  set ArchAncDir = ArchDir_Ancillary_"/"

7
0 589
Article Alex Woodhead · Apr 16, 2023 4m read

Overview

Cross-Skilling from IRIS objectScript to Python it becomes clear there are some fascinating differences in syntax.

One of these areas was how Python returns Tuples from a method with automatic unpacking.

Effectively this presents as a method that returns multiple values. What an awesome invention :)

out1, out2 = some_function(in1, in2)

ObjectScript has an alternative approach with ByRef and Output parameters.

Do ##class(some_class).SomeMethod(.inAndOut1, in2, .out2)

Where:

  • inAndOut1 is ByRef
  • out2 is Output

The leading dot (".") in front of the variable name passes ByRef and for Output.

0
0 591
Article Mihoko Iijima · Apr 13, 2023 6m read

InterSystems FAQ rubric

In this article, we will introduce how to deal with the situation: "I accidentally deleted a global!"

Backup files and journals are used to recover specific globals that have been accidentally deleted. Restoration is performed by specifying conditions and restoring journal records using the ^ZJRNFILT utility. In this way, you can apply a point-in-time backup of the database up to and including deleting a specific global for journal records that contain deletions. For more information on the ^ZJRNFILT utility, please refer to the document below:

2
1 761
Question Scott Roth · Apr 6, 2023

We have a function that was written for us that allows us to create text files for logging certain aspects to the OS using %Stream.FileCharacter. We had no issues with this until we moved from AIX to Red Hat.

Now it seems the 1st time the function is called, and the file is created the permissions seem to be correct on the file. But as soon as we attempt to write another line to the file using MoveToEnd() it seems the permissions are changed on the file. I have been able to narrow the issue down to the MoveToEnd() by calling the function from different users. 

9
0 993
Question Joao Palma · Feb 18, 2019

Hi

I've got a string variable which I need to convert into a XML one.

My main goal here is to use the XML bit I've extracted from a HTML file in a message I need to pass over to an operation.

I'm doing the following which always errors

classMethod WriteNodes(myfile As %String)
{
    Set status=##class(%XML.TextReader).ParseString(myfile,.reader)

....

Any easy way of making this happen?

Kind regards

18
1 2309
Question Timothy Leavitt · Mar 10, 2023

I'm trying to read the response to a long (indefinitely) running HTTP response with Transfer-Encoding: chunked. Ideally I'd be able to read the individual chunks from the response and do something with them as they arrive rather than needing to wait for the response to finish (because it never will) - ultimately I'm thinking to wrap these back up over a WebSocket connection which seems cleaner from an API perspective.

So far it looks like my options are:

3
0 1240
Question Marcelo Witt · Mar 29, 2023

Looking at the documentation, I see that the global ^ROUTINE brings the information and code of the .INT version of the routines. However, I would like to know where the equivalent information of the .MAC version is, as I did not find any reference to this in the documentation.
Some information in the .MAC version are hidden or already converted into the .INT version, and I would like to have access to this information through the system, and not just opening the routine in the studio.

2
0 392
Question Jordan Everett · Mar 30, 2023

Hey all,

I have been creating a class to handle file encryption by using GPG keys. I pushed my code out today and my encrypt and decrypt methods weren't working. About a half an hour later in troubleshooting I found out that it needed to be a syntax change. My method has three parameters to it. Examples below:

This is how I was calling it in the test system with no issues:

do gpg.Encrypt()

This is how I was having to call it in my production system to work with no issues:

do gpg.Encrypt("","","")

6
0 369
Article 姚 鑫 · Mar 22, 2023 25m read

Brief

What is Query

Query is a method for finding data that meets the conditions and presenting the results as a data set.

Type of Query

  • SQL Query,Using %SQLQuery and SQL SELECT.
  • Custom Query,Using Class %Query and custom logic to generate result.

Note: Before we talk about the general Query solution, let's first understand the basics of Query to help understand the implementation principles. If you already know the basic use of Query, please skip this section and go straight to "Challenges".

Query Basics

SQL Query Basics

1
3 768
Question Smythe Smythee · Mar 23, 2023

Hi Community,

I am trying to save data into SQL table but each entry  getting saved twice in the SQL table. Is there any reason data is saving Twice in the SQL table 

I have created a %Persistent class for the fields

Please find the business operation below

Class Patient.DBOperation Extends Ens.BusinessOperation

{

Parameter ADAPTER = "EnsLib.SQL.OutboundAdapter";

Property Adapter As EnsLib.SQL.OutboundAdapter;

Parameter INVOCATION = "Queue";

6
0 393
Question Andy Stobirski · Mar 17, 2023

I'm using %XML.Reader  to open an XML file and use it's correlate method to try and convert it to a class.

The conversion fails with an error of:

ERROR #6277: Type attribute, LimitedFreeTextFieldInstance, does not specify valid type for XML input tag: Field (ending at line 3 character 118).

This is the XML

<Fieldsxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><Fieldxsi:type="UDFLookupFieldInstance"ID="2925"Description="FIRE ALARM ACTIVE"Suffix="FDT_ACTIVATE"/></Fields>
7
0 576
Question Jordan Everett · Mar 13, 2023

Hey all!

I was wondering if anyone had any input on how to troubleshoot classes in a terminal session? I'm currently writing an "adapter" so that way we can encrypt and decrypt files through GNUPG (PGP keys).

I currently have a %RegisteredObject class for this and am running into the excruciating pain of testing this. Every time I make a change on the RegisteredObject I have to renew the class and all of its properties in order to test the newly compiled code that I have written. I know that this doesn't seem like too much of a hassle, but after doing it multiple times it becomes tiring.

3
0 471
Question Scott Roth · Mar 10, 2023

I am looking into creating a ZSTOP as you probably have seen from my previous posts, is there a way to capture the type of shutdown that occurred? So say if there was an unknown hardware failure (forced), vs a user shutdown? Mainly looking for user or system shutdown when we force another destination to become the primary in the mirror. So if a user shutdown the production to do.,... Task A, Task B etc..

Thanks

Scott 

3
0 482
Article Heloisa Paiva · Mar 10, 2023 3m read

Introduction

This article is intended to be a simple tutorial on how to create ODBC connections and working with them, since I found starting with them a little bit confused, but I had amazing people to take my hand and walk me through it, and I think everyone deserves that kind of help too.
I'm going to divide each little part in sections, so feel free to jump to the one you feel the need to, although I recommend reading everything.
I'm going to use the sample data created in a previous article, Quick sample database tutorial: Samples.PersistentData, with the properties Name and Age.

0
2 1089
Question Scott Roth · Mar 7, 2023

I am working on setting up our Failover techniques as we move to a Mirror Environment with a Arbiter, 2 Failover Nodes, and a Async (DR) Node. There are some system commands that I would like to call when the Mirror moves, and I am working on a ZMIRROR routine for that, but I also wanted to create an additional step if we wanted to manually shutdown and for the Mirror to move. So I was looking at using ZSTOP to call a couple of different items while shutting down, while the documentation has an example a couple of questions come to mind about using ZSTOP.

3
0 391
Question Leon Armstrong · Mar 3, 2023

I'm wondering how I would go about adding headers to a csv file which has already been created. I am unfamiliar with ObjectScript. 

For example if I were to use R, I would simply write..

test <- read.csv("file/path/example/Extract.csv", header=FALSE)
colnames(test) <- c("A","B","C","D","E")

I do not have embedded Python installed either as I would know how to do it in that also.

How could I mirror this in ObjectScript please?

My current create file method:

3
0 389
Article Neerav Verma · Sep 27, 2019 2m read

At least three different ways to process errors (status codes, exceptions, SQLCODE etc is given in ObjectScript. Most systems have status, but for a range of reasons exceptions are more convenient to manage. You spend some time translating between the various techniques dealing with legacy code. For reference, I use several of these excerpts. It is hoped that they will also support others.

2
5 2629
Article Julian Matthews · Jul 21, 2021 4m read

Over the years, I have found myself needing to create multiple HL7 messages based on a single inbound message. Usually these take the form of an order or result from a lab. Each time I have approached it, I have tried to start from scratch under the belief that the previous attempt could have been done better.

Recently, the need arose again and I was able to create a solution that I wasn't ashamed of. My main concern was that I would always either find myself getting buried in a BPL, or use ObjectScript and attempt to edit messages using the SetValueAt Method for the HL7 Message Class.

Problem

1
2 1463
Question Stefan Cronje · Feb 23, 2023

Hi all,

I might be losing my mind or do not understand how ObjectScript does string comparisons, but the following does not look right to me.

Is it really possible that you can't compare non-numerical strings other than with an equals or not equals?

USER>w ("45" < "46")
1
USER>w ("45" > "46")
0
USER>w ("V45" < "V46")
0
USER>w ("V45" > "V46")
0
USER>w ("V45" <= "V46")
1
USER>w ("V45" >= "V46")
1

In Python:

4
0 373
Question Dmitry Maslennikov · Feb 22, 2023

Any ideas on how this can be solved?

I need to use it with some Unicode text, in Docker image. And get this error. And documentation says nothing about it.

USER>do$zf(-100, "/SHELL", "echo", "test")
test

USER>do$zf(-100, "/SHELL", "echo", "test тест")

DO$ZF(-100, "/SHELL", "echo", "test тест")
^
<TRANSLATE>

I know that it works in some Linux environments without Docker, but no idea where is the difference. 

2
0 233
Question Mark OReilly · Feb 3, 2023

Hi:

I don't understand how to use this open exchange item for auto creating deleting items. I think it assumes knowledge in the steps of how to use it which i don't get. 

Added the code into dev on  SRFT.Utility.DeleteHelper.OnDeleteSuper and SRFT.Utility.DeleteHelper.AddHelper  

current class is 

Class Messages.XML.GenericWif.fileparameters Extends (%Persistent, %XML.Adaptor)
{

Property revisionnumber As %String;

Property primarylink As Messages.XML.GenericWif.primarylink;

Property additionalindexes As Messages.XML.GenericWif.additionalindexes;

2
0 344