Hi developers!

Just want to share an old but always relevant best practice on namespaces changing @Dmitry Maslennikov shared with me (again).

Consider method:

classmethod DoSomethingInSYS() as %Status

{

set sc=$$$OK

set ns=$namespace

zn "%SYS"

// try-catch in case there will be an error

try {

// do something, e.g. config change

}

catch {}

 zn ns    ; returning back to the namespace we came in the routine

return sc

}

And with new $namespace the method could be rewritten as:

classmethod DoSomethingInSYS() as %Status

{

set sc=$$$OK

new $namespace

set $namespace="%SYS"

// do something

return sc

}

So! The difference is that we don't need to change the namespace manually as it will be back automatically once we return the method.

and we don't need try-catch (at least for this purpose) too.

4 5
0 538

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?

1 0
0 448
Article
· Apr 20, 2021 3m read
Why gj :: locate?

You may think it isn’t too difficult to get from label+offset^routine to the actual source line responsible for the error. For an expert it isn't that hard... most of the time. But there are enough oddities and special rules that even an expert can get it wrong, whilst spending a lot of time trying to get there.

gj :: locate is the latest tool from George James Software – it debugs any error, class or routine by converting the location of an error in compiled .int code to the corresponding location in your source, and then taking you right there.

Image this scenario…

4 0
1 191
Article
· Mar 17, 2021 3m read
Making the most of $Query

I ran into an interesting ObjectScript use case today with a general solution that I wanted to share.

Use case:

I have a JSON array (specifically, in my case, an array of issues from Jira) that I want to aggregate over a few fields - say, category, priority, and issue type. I then want to flatten the aggregates into a simple list with the total for each of the groups. Of course, for the aggregation, it makes sense to use a local array in the form:

agg(category, priority, type) = total

Such that for each record in the input array I can just:

14 10
4 896
Article
· Feb 18, 2021 2m read
Basic JSON Compare

Hi Dev Community

I thought i would share a little method I knocked together to traverse and compare 2 JSON objects for basic equivilance. I'm currently working on some data migration, and wanted a basic sanity check to validate that the JSON output is basically equivliant between the old and new, excluding a few things like timestamps.

It's a basic little recurvsive method, that will bubble up any differences over a nested structure. It's very low tech, as that's all I need it to do, but I thought it might be useful for others?

1 5
0 709
Article
· Jan 16, 2021 3m read
Creating and listing XData definitions

Hi InterSystems Community!

The ObjectScript language of InterSystems IRIS has the ability to extend classes using a very interesting feature called XData.

It is a section in your class that can be used to create custom definitions to be used within the class itself and also externally.

To create one or more XData definitions for your class is very easy, see the example:

2 2
0 351

Tiny web application that allows you to anonymize CSV files. Based on InterSystems IRIS®

Version: store/intersystems/iris-community:2020.3.0.221.0

Application

Sample CSV where Date of Birth and Sex will remain untouched, while the rest should be anonymized.

before

The application recognizes the header columns and allows the user to chose which ones to ignore.

2 0
0 267

Moving over from Studio To VSCode like many other will do now the ObjectScript plugin reached version 1.0, I noticed I was missing some items in the objectscript explorer. For example when creating a Rest API using the spec first approach, 3 classes are generated, an application.impl, application.disp and application.spec class, but the disp class was missing in the Object Explorer.

As the application.disp is a generated class, for showing these classes you need to turn this on by hitting the switch on the object explorer:

8 1
1 381
Article
· Oct 6, 2020 2m read
An overview of npm-iris

What is npm-iris?

N.P.M stands for "No Project Mess."

N.P.M. is a Project & Task Management app that uses InterSystems IRIS and Bootstrap 4.

No Project Mess is created to help developers and small business companies to reduce complexity in their daily problems, with a simple and intuitive projects and tasks management software.

It offers different views for your tasks, from a spreadsheet, kanban, calendar, or even Gantt!

3 0
0 287
Article
· Sep 10, 2020 3m read
How To Create "Write-Only" Code

One of the leading benefits of ObjectScript is the speed and efficiency it allows for an experienced developer. Let's look at an example of how you can benefit from ObjectScript today.

Suppose you have a class that stores the names of your users. We'll call the class Data.User, and give it a string property Name. Next, we will need a method to create a new user or update an existing one. A naive, simplistic approach might look like this example:

6 10
0 614
Article
· Aug 2, 2020 1m read
Application Errors Analytics

Hi Developers!

As you know the application errors live in ^ERRORS global. They appear there if you call:

d e.Log() 

in a Catch section of Try-Catch.

With @Robert Cemper's approach, you can now use SQL to examine it.

Inspired by Robert's module I introduced a simple IRIS Analytics module which shows these errors in a dashboard:

3 5
1 297
Article
· Jul 27, 2020 2m read
ZPMshow, a helper for tired fingers

The offer of ZPM is growing daily and the short names and
acronyms of the offer are sometimes hard to understand and
also hard to type with my lazy fingers.

So I decided to have

  • a listing with the descriptions from the repository,
  • split in short junks to avoid backscroll,
  • controlled forward / backward scrolling,
  • the option to select my packages by number,
  • to install or uninstall with limited typing.

It runs with do ^zpmshow

A snapshot from the screen:

12 0
0 354
Article
· Jul 21, 2020 1m read
Snapshot to JSON

This is a sample to use %JSON.Adaptor class available in IRIS to produce a snapshot of your object.

The sample consists of 2 classes that are variations of what was known in Caché/SAMPLES as Sample.Person.
Be aware that the possibilities are limited by %JSON.Adapter and how you make use of it.

Once in place, you create some test data by Populate().
You select an object and take a snapshot.
You apply changes to your object and take another snapshot.
And see the difference.

BINGO!

10 0
0 633