#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.

Discussion Jack Huser · Jul 23, 2021

The goal is to construct a comma separated string, using a loop but the same way $listtostring(var,",") would do (i.e. "a,b,c,d,e,f,g,h" without starting or ending comma).

What is the best way to do it, concerning the readability of the code and its performances?

To do so, there are more than 5 methods, but in this example we will test 4 :

1) using a "if" in the loop

set str=""for ... {    if str'="" set str = str_"," }    set str=str_myval}

2) using a set

set (str,sep)=""for ... {    set str=str_sep_myval    set sep=","}

3) using a $list construction and transform to







9
1 560
Question Davidson Espindola · Sep 15, 2021

Hello everyone
I use cache script, I would like to know from you if there is any function or class in the cache where I can get the start and end date of a given month:
Example: What is the first and last day of the month of February 2015.

Grateful.
Davidson

9
1 661
Question Jordan Simpson · Aug 19, 2021

Hello,

When using GetFieldStreamRaw(), by passing in a variable instead of using an output for the Remainder, will this affect how it is stored into a segment in a cloned message? I know it would usually output the remaining fields of the segment but in order to conform to a supplier's spec, they'd require "^^PDF" rather than the rest of the segment. Because the segment becomes immutable, the code below seems to be the way to do it. This code is working, but I'm curious if by passing in a variable rather than referencing the Remainder output, it will somehow truncate the embedded PDF when I s

1
0 893
Question Anthony Breen · Nov 19, 2020

Hi,

I'm processing POP3 emails using the standard EnsLib.EMail.InboundAdapter adapter and %Net.MailMessage. I'm basically processing documents that are attached to received emails. This works fine if the document is simply attached to the email itself. But some systems are sending documents that are attached to an attached email which has content-type = message/rfc822.

How do I get the attached file from the attached email?

I'm using the following code to iterate through the email parts.. I can get as far as processing a MailMessagePart which has content-type = message/rfc822 but how do I p

3
0 878
Question Virat Sharma · Sep 5, 2021

Hello Everyone

I am new to cache. I know there are 2 types of methods in cache. One is Instance method (Which can be call through object creation of particular class) and other is Class methods (which can be call through ##Class(MyPackage.Car).CarModels()). 

I want to know the difference when to create a instance method vs when to create a class methods.

Thanks in advance!!.

3
0 310
Job Leanne Taylor · Aug 26, 2021

Our client is a UK-based company with subsidiary operations in the USA, France, Germany and China. The Company supplies materials which are used for research, development, and specialised manufacturing applications worldwide. The Business Intelligence department is a small but integral part of the company. The department provides support to the wider business through information systems. We are currently seeking a Business Intelligence Caché Specialist that will be responsible for supporting and developing the existing Caché system, which is used widely within the business. We are based in Hun

4
0 722
Question James Casazza · Aug 23, 2021

After linking in Oracle Table with Field Column's Data Types of NUMBER, my updates into these table fields are resulting in data that is being rounded to 2 decimal places. I insert a record with 1234.1234 and 1234.12 is stored.

It appears Cache xDBC might be manipulating my values prior to sending to Oracle. Is there a setting or system parameter that is controlling this? If so, is there a way to relax this from occurring so the values I send are being stored in Oracle with the same values?

10
0 816
Question Sehinde Raji · Aug 21, 2021

Hey everyone as you may know I am a beginner and I am kindly asking for some assistance in a problem I have been solving. The problem is that I am calling a user defined function within a procedure called occupiedseatsAdj and the compiler comes up with this error. 

<NOLINE> There has been an attempt to refer to a nonexistent routine line.

From what I understand I can call a user defined function from within a procedure (correct me if I am wrong) as shown below. Is this the correct way or should I create a .Mac file and include it somewhere within the above mentioned cls file ? I u

2
0 281
Announcement Laurel James (GJS) · Aug 19, 2021

Hi developers, 

We have just published an update to the Deltanji version control extension for Visual Studio Code.

When used in certain Deltanji workflows, triggering an automatic checkout on first keystroke could result in the developer working on an outdated copy of the code and only being notified of this later when saving their changes. In order to prevent this from happening checkout now reloads the document immediately. 

Error messaging has been improved in two areas - when attempting to cancel code that is not checked out, and when trying to register new code onto a withdraw system. 

We have also improved interoperability between the Deltanji extension and the InterSystems ObjectScript one, as well as its handling of multi-component objects.

If you're already a user of Deltanji then your extension with automatically update. You can find out more information on Deltanji and the latest release here

0
0 209
Question Sehinde Raji · Aug 13, 2021

Hi All I am a beginner and I am learning Objectscript and I would appreciate a steer regarding a problem I am solving.

The issue I have spent some time on resolving without success is that I have the stream listed below and as you can see it has some gaps in it.

Stream



das
is
wp

dsa
nmk

Here is the import method

IF ##class(%File).Exists(dir) '=1 {
    write !, "Unable to Open: "_dir
    QUIT
} ELSE {
    write "File: "_dir_" is open"
}
// instantiate a new class called file
set file = ##class(%Stream.FileCharacter).%New()
// create a new variable called sc
set sc = file
6
0 629
Question Sehinde Raji · Aug 5, 2021

I have been working within Objectscript for a few months and I am seeking assistance today because all of the help files within the docs.intersystems.com domain are currently down and they wont be back up until next week. (I raised a special ticket for this) 

I have been trying to figure out how to  convert a binary number 0101001 in to a decimal number using a variable called CNumber and I have tried using the method below and it hasnt worked. I think it may be due to the fact that this assumes an array or some sort. I tried using online hexadecimal calculators and the resulting output is in

6
0 559
Question Muhammad Waseem · Aug 5, 2021

Hi,

I am getting following error while compiling a routine :

Compilation started on 08/05/2021 12:58:31 with qualifiers 'cku /checkuptodate=expandedonly'
Compiling routine : demoroutine.mac
ERROR: demoroutine.int(1) #1026: Invalid command : 'write "Use one of the following options"' : Offset:6 [write^demoroutine]
 TEXT: write "Use one of the following options"
Detected 1 errors during compilation in 0.022s.

Please note that Routine contains just a below simple write command :
write "Use one of the following options"

Thanks

2
0 331
Article Evgeny Shvarov · Aug 5, 2021 1m read

Hi folks!

Want to share a lifehack with you on ObjectScript highlighiting withing VSCode for script files.

Script files are just files with lines of ObjectScript that we feed anywhere, e.g. into IRIS during Docker baking procedure.

Typical usecase - here is the Scriptfile

here is the Dockerfile where we feed it.

And here is how it looks like usually in VSCode:

Screenshot 2021-08-05 at 09 51 06

Coudl be more beautiful, right?

0
0 568
Question Robert Shoults · Jul 27, 2021

I have a routine tag that takes an argument and I want this argument to be an array reference.  So I try something like:

do mytag(.myarr)

The mytag tag, adds subscripts to myarr.

When I evaluate myarr after the tag call, only the subscripts passed in are retained in myarr.  The subscripts added by mytag are missing.  Is there a way to pass an array so it will behave the way I want it to?

6
0 706
Question Neil Thaiss · Jul 28, 2021

Hi all,

Are there limitations to the size of a file or stream that %XML.Reader will parse?

I am trying to parse a large, 573MB, XML file using either the 'OpenFile' or 'OpenStream' methods, but both return errors.

When I try to use the 'OpenStream' method I get a 'ERROR #6301: SAX XML Parser Error: input ended before all started tags were ended' error',

and when I try the 'OpenFile' method I get a 'ERROR #6301: SAX XML Parser Error: <STORE>'.

'%XML.TextReader' appears to parse the file OK, so I may be able to get use that as a workaround, but ideally I would like to get '%XML.Reader' work

2
0 610
Question David.Satorres6134 · Jul 20, 2021

Hi,

When for any particular reason I need to update a record and don't want to pull the triggers, the keyword %NOTRIGGER can be used. But I've been trying to do the same when I change the row using the object approach, but I can't find it. Anyone knows if it's possible to avoid pulling triggers when working with objects?

Sadly, the utility "DISABLE^%NOTRIGGER" doesn't seem to exist ;-)

Thank you,
David

2
0 352
Question Jordan Simpson · Jul 20, 2021

Hi!

Does anyone have a cleaner approach than this for looping through grouped NTE segments in order to set the segment ID in an ORM? I am aiming to avoid the NTE segments that may follow the PID segment and find the NTE's that follow the OBR segment. By using the below If statement in the While loop, I'm finding NTE's that have comments in the fourth field (PID NTE's tend not to have these in the messaging I'm seeing, I'm awaiting confirmation on this), as well as finding my newly inserted NTE segment using $FIND to locate the colon (I've concatenated some values).

Although this code is work

3
0 588
Question Daniel Aguilar · Jul 13, 2021

Good afternoon I am making a method of a class that I want to return a list of objects of another class that I have defined, example:

ClassMethod myMethod() As list of MyPackage.MyClass
{
}

But it gives me a syntax error, I try this and it works:

ClassMethod myMethod() As %ListOfObjects
{
}

But I would like to keep the typing.

Is there a way?

5
0 687
Question Daniel Aguilar · Jul 13, 2021

How do you initialise a list of objects of a particular type?

I have tried the following code and I get an undefined when I try to insert.

I can do this and it works but I don't know if it is correct.

Is there any way to do something like this?

Set a= New list of Accciones()

Thank you.

3
1 423
Question Jonathan Anglin · Jun 29, 2021

Hello All

I'm running into an issue performing UPDATES that I'm not getting on INSERTS. It's probably obvious, but I'm just not seeing it and could use a little help.

I'm going over an HL7 message and depending upon varying criteria, the relevent variables will get items added to them like the following:

Set patientId = pRequest.GetValueAt("PID:3")
Set sqlColumns = sqlColumns_",patient_id"
Set sqlValues = sqlValues_",?"
Set par($i(p)) = patientId

After compiling the variables, I check to see if accession number is found in the table.

set performInsert = 1
set performUpdate = 0
...
s
14
0 778