#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 Ben Webb · Dec 2, 2021

Hi all, 
I'm trying to output a XML file, mapped from a ORU_R01 2.3 HL7 message, with a file name based of fields in the source HL7 message in the following format, 
source.{PIDgrpgrp(1).PIDgrp.PID:PatientIDInternalID(1).ID}_"-"_
source.{PIDgrpgrp(1).PIDgrp.PV1grp.PV1:VisitNumber.ID}_"-"_
source.{PIDgrpgrp(1).ORCgrp(1).OBR:ObservationDateTime.timeofanevent}
To give something like RXR0000000-000000123-20211125105415.xml as the output filename,
I initially tried to extend the EnsLib.XML.Object.Operation.FileOperation class and overwrite the OnMessage() method to allow me to specify the filename but I



1
0 442
Announcement Bob Kuszewski · Oct 28, 2021

Welcome to day 3 of Virtual Summit 2021!  We have incredible content available to you this year and I'd just like to bring your attention to the 4(!) sessions that we have on Embedded Python.

14
3 1034
Question Jimmy Christian · Nov 17, 2021

Hello,

I am trying to pass a pattern in the Ensemble function Matches(val,pat) in Business Rule as below.

Eg. 

Matches(tSite,"1(.E1"SITE A",.E1"SITE B")")

tSite is a variable containing the site name

Want to check if the variable contains any of the site name.

But i receive a parsing error when compiling.

Is there another way to pass the pattern in the Matches function or any other similar function which i can use in the business rule or DTL without multiple sentences with Contains.

Thanks,

Jimmy Christian.

2
0 309
Question Ben Webb · Nov 29, 2021

Hi all, 
I'm using a snippet I found from Scott Roth to extract, decode, and save a PDF from a HL7 message and save it to a specified file path, but I'm running issues with the following error:
My approach was to a create a utility function accessible from a DTL like this:

Class ELHTPRODPKG.Functions.Utility.ExtractPDF Extends Ens.Rule.FunctionSet
{

     ClassMethod DecodeBase64HL7(base64 As %Stream.GlobalBinary, Path As %String, FileName As %String) As %String [ Final ]
     {
          //Debug
          WRITE $LENGTH(base64)
          // Decode
          set Oref = ##class(%FileBinar



7
0 937
Discussion Evgeny Shvarov · Nov 29, 2021

Hi, Community!

Open Exchange (OEX) is getting more and more popular and more and more developers consider publishing their apps in the public package managerregistry.

This is really great!

So the topic of thoughtful naming convention is getting more important and even critical.  Let's discuss?

6
1 605
Question Andy Stobirski · Nov 23, 2021

Hi all

I'm new to ObjectScript and I've been experimenting the correlate method of %XML.Reader to convert an XML file I've loaded into its corresponding class. But, I have found that I am not getting all the child items of an element in a List contained within the converted class, only the last item.

The XML file content is as follows:

<Results>
  <PersonIDs>
    <PersonID>1000000</PersonID>
    <PersonID>1000001</PersonID>
    <PersonID>1000005</PersonID>
  </PersonIDs> 
</Results>

I have two classes: the parent SearchResultsMessage contains a List Of the child class PersonID, as sh

6
0 598
Question Andrea Schecker-Krauss · Nov 23, 2021

I programmed some server command by my own. That server commands worked fine for a long time.

Suddonly I received 

Studio Action "Attempted Edit" not supported on 127.0.0.1:57772[CTAE01]

by using one of my server commands.

There is an explanation:

Error running command vscode-objectscript.serverCommands.contextOther: Running the contributed command: 'vscode-objectscript.serverCommands.contextOther' failed.. This is likely caused by the extension that contributes vscode-objectscript.serverCommands.contextOther.

Can you help me to solve that issue?

2
0 385
Article Laurel James (GJS) · Oct 25, 2021 2m read

InterSystems technologies are renowned for their high performing databases, which support the systems and operations of many organisations. However a key ingredient to this success is the quality and maintainability of their code. 

The quality of code can impact everything from speed and ease of fixing bugs and making enhancements, to the overall performance of your organization and your ability to get ahead in the marketplace. 

By ensuring your code is maintainable, you can reduce approximately 75% of the systems life cycle costs*. This is why, at George James Software, the solutions we build are always straightforward and written in high quality code - because we know that this solid foundation can positively impact the rest of your organization. 

With a maintainable system you're able to reduce your overall maintenance as any issues that occur are significantly faster to identify and fix. This means you're free to allocate that time and budget to enhancements, enabling you to get the most value out of your applications and ultimately better support your organization. 

Keep an eye out for our next few posts about what a maintainable system looks like and the tools that can help you keep your code maintainable, in order to help you to reduce those maintenance costs.  

1
1 483
Article Joel Solon · Dec 23, 2015 1m read

In the Caché Foundations course, students are learning about Caché Development and ObjectScript syntax at the same time. To help students complete the exercises, we provide an ObjectScript Quick Reference (aka "the Cheat Sheet").

It is not a reference for all of ObjectScript! It is a list of the ObjectScript commands and functions that students use during the course, along with common syntax for objects, collections, etc. It also contains some useful macros.

We are providing a pdf version to the Developer Community.

6
0 1801
Article Nigel Salm · Aug 18, 2021 15m read

Why I love ObjectScript and why I think I might love Python More

I was looking at the thread of messages on the topic of "Performance when constructing a comma-separated string", and I started writing a response but got distracted, the page refreshed, and I lost my text. I couldn't spend the time rewriting my response, so I started writing this document instead.

I started writing MUMPS at the beginning of my career. I wrote very tight and dense code blocks where exercises such as the string example were authentic challenges. We squeezed every last bit of performance out of the Di

17
5 1744
Question Arturo Masero · Nov 3, 2021

Hello,

I don't know if the title is accurate enough. I have a legacy code that I need to optimize. It's a routine written in objectscript. It accepts 4 parameters and runs 6 nested FOR...$ORDER reading a big global.

The thing is when I run the routine the first time it takes around 60 seconds to run. If I run it again it takes 5 seconds. If I wait around 6 to 10 minutes to run it again, it takes 60 seconds again, but if I run it every 1, 2, 3... minutes it still takes only 5 seconds to run.

I can guess there's some cached memory stuff somewhere making this happen. I've tried purging SQL que

9
0 677
Question Evgenii Ermolaev · Nov 2, 2021

I am receiving the following error in my buisness operation:

ERROR <Ens>ErrException: <UNDEFINED>zGo2+181^mb.MbMainOperation.1 *tSC -- - registered as '-' number - @' set pResponse = ##class(mb.MbMessageResponse).%New()'

From what I understand, the problem occurs in the generated int file mb.MbMainOperation.1 in the method zGo2, with the offset of 181 lines, and the variable in question is a local variable tSC.

However, the line where the error occurs does not refer to tSC in any way

set pResponse = ##class(mb.MbMessageResponse).%New()

I even went as far as to set the variable at the v

3
0 287
Question Martin Weber · Apr 2, 2019

At the moment I am trying to write a documentation file for a project and intend to use LaTeX for it.
Has anyone already had experience with this? I haven't found syntax highlighting with the LaTeX packages I know yet.
I found a request on Pygment but it was from 2016 and there was no reply on it since then.

Does anyone know a simple way for syntax highlighting COS in LaTeX?
Thanks for your input!
 

Martin

10
0 591
Question David Hockenbroch · Oct 14, 2021

If I open a terminal and type the following commands, sc is an error:

set validator = "sc = ##class(%Library.Numeric).IsValid(""BLAH"")"
set @validator
write sc

At the end, when I write sc I get:

0 L'BLAH9
             DOCXT010,#e^zIsValid+1^%Library.Numeric.1^1e^^^1

However, if I call the following class method using the arguments "%Library.Numeric" and "BLAH", sc is undefined

ClassMethod testvalidator(class As %String, value As %String) As %Status{set validator = "sc = ##class("_class_").IsValid("""_value_""")"write validator,!set @validatorwrite sc,!quit sc}

When it

12
0 586
Question Anna Golitsyna · Oct 8, 2021

I am trying to figure out the best ObjectScript analog to mimic, more or less, the %RCOPY functionality. What would be ObjectScript  method(s) if any to copy a routine from the current namespace to another one and compile it there?

12
0 425
Question Muhammad Waseem · Sep 24, 2021

Hi

Following API:
http://api.aladhan.com/v1/gToH?date=24-09-2021
is returning following JSON response:
{"code":200,"status":"OK","data":{"hijri":{"date":"16-02-1443","format":"DD-MM-YYYY","day":"16","weekday":{"en":"Al Juma'a","ar":"\u0627\u0644\u062c\u0645\u0639\u0629"},"month":{"number":2,"en":"\u1e62afar","ar":"\u0635\u064e\u0641\u064e\u0631"},"year":"1443","designation":{"abbreviated":"AH","expanded":"Anno Hegirae"},"holidays":[]},"gregorian":{"date":"24-09-2021","format":"DD-MM-YYYY","day":"24","weekday":{"en":"Friday"},"month":{"number":9,"en":"September"},"year":"2021","designation":{"abb

8
1 545
Question Marlin Mixon · Sep 26, 2021

I have a %Stream that I want to insert some text into the middle of.  I create a new stream called pNewContentStream from the original stream, then I do a MoveTo in pNewContentStream to get to the byte position I want to insert into but when I do my Write, my pNewContentStream gets obliterated with only the text that I wrote, the original content goes away and all I'm left with is my Write text.

Method AddContentTypeCode4(pContentStream As %Stream.GlobalCharacter, Output pNewContentStream As %Stream.GlobalCharacter) As %Status{Set tStatus = $$$OKtry {Set tTemp = pContentStream.Read
17
0 811
Question Michel Bruyère · Sep 30, 2021

Hello,


I’m looking for a way to find out which category of portal a connector belongs to.
I looked at the class ‘Ens.Config.Production’ and ‘Ens.Config.Item’ but without success.


An idea about the ‘ObjectScript’ code to design?

Best Regards.

11
0 376
Question David.Satorres6134 · Sep 21, 2021

Hello,

I'm experiencing a recurrent problem that I haven't found the way to solve, so I'm coming here with the hope somebody can give me a new approach.

To make it short: we are creating categories on-demand to be able to place the maximum numbers of workers in memory, avoiding the limits established by system categories. But from time to time, one of this creation fails and system is no able to start the queue. The error we are getting is:

ERREUR #7823: Invalid work queue manager category supplied 'User.65733'.1<INVALID OREF> 

The code is very simple:

s ^%SYS("WQM","MaxActiveWorkers","Us
1
0 323
Question Kevin McGinn · Sep 28, 2021

I am executing the command:

      set fileComp = ##Class(SYS.Database).FileCompact(obj.Directory, freeSpace, .actualFree)

      where obj.Directory contains the location of the current database

This executes correctly. However, the resultant OREF object does not contain any displayable properties but rather is of the value:

       "0 "_$lb($lb(380,,,,,,,,,$lb(,"%SYS",$lb("e^zFileCompact+38^SYS.Database.1^1","e^^^0"))))/* ERROR #380: Completed but skipped some blocks, details recorded in the console log. */

Which is what I expected. But I would like to extract the piece of the OREF object

2
0 277
Question Kevin McGinn · Sep 24, 2021

I have a terminal script that queries sys.process' and then parses the results writing to a logfile. As part of the processing of the results, each row of the result set includes an element from the static string.  But I am not clear on the scoping of the static string. The write statement sees the static string as undefined. What I want is something to the affect:

     set statStr = "aa|bb|.."

   set sqlStatement = xxx

   set tState  = ##class(%SQL.Statement).%New()

   set qStat   = tState.%Prepare(< sql statement> )

   set rset    = tState.%Execute()

  WHILE rset.%Next() { w ....., $PI

2
0 283
Discussion Mathew Lambert · Sep 22, 2021

When overwriting the Read method (that has a %CacheString return type) on a new class that inherits %Stream.FileCharacter class, returns an error about incorrect return type, must be Binary, even if it matched the real signature.

Looking at the compile global information we can see:

^oddCOM("%Stream.FileBinary","m","Read",42)="%Library.Binary"

After further investigation we realise that there is a generator method looking at the OdbcType class definition.

Setting LONGVARCHAR results in:

^oddCOM("User.CStream","m","Read",42)="%Library.String"

0
0 257
Article Jack Huser · Sep 13, 2021 6m read

Since I saw many posts on Developer Community related to Python, and the very good articles and application written by @Eduard Lebedyuk I was wondering: "As a Object Script developer, why would I want to use an other  language in Object Script? If I ever need to execute something in Object Script, I would do it in Object Script!".

I thought those functionalities to use other languages in Object Script were made only for other languages developers who have to write Object Script code.

Recently I had to parse a huge CSV file : 1.7Gb and more than 5 millions lines.

I did it in Object Script:







16
0 782