#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 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
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 604
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>
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 384
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 482
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 1800
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.

17
5 1741
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.

9
0 676
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()

3
0 286
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}
12
0 585
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 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.

17
0 810
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:

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. */

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()

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 781
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=","}
9
1 559