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

Article Robert Cemper · Oct 9, 2018 3m read

The question has come up several times and I saw mixed answers and no quick example

My personal preference is using CPIPE device as you get back exactly the output you will get at the command line interface of your OS .
The tricky thing is to stop reading in time.
The example just displays what you normally see in your console.
it becomes useful if you look for things that you can't get from any $system.whatever()

e.g.
- your servers IP address or addresses depending on your configuration.  
- pinging any other server to see if it is still visible on the network
- running nslookup 

GitHub

 Zpip



5
4 2620
Announcement Anastasia Dyubaylo · Dec 25, 2020

Hey Developers,

Advent of Code 2020 is over! Thanks for participating in InterSystems ObjectScript marathon!

And now we're pleased to introduce the winners and distribute all the prizes! 

Big applause goes to these winners: 

     @Kevin An (w/ repo)

     @Fabian Haupt  (w/ repo )

      @Yuval Golan (w/ repo )

And here's the final InterSystems leaderboard:

3
1 421
Question Ahmad Bukhtiar · Nov 22, 2020

If I have table of 60 fields is there a way to add values to columns dynamically ?

Fields are like this Field1, Field2, Field3...Field60 and I am reading data from flat files. I tried below code but it didn’t work

For i=2:1:$LENGTH(line) {

set SourceTable.Field_i = $PIECE(line, "|", i)
 

3
0 707
Question Scott Roth · Dec 7, 2020

I have a case where I need to look up the NPI provider against an External MS SQL database to retrieve our Provider Identifier to send to a downstream system. In the past I would use a Business Process (BPL) to connect to the outside MS SQL via JDBC and get that information for me. But I was thinking instead of creating a BPL process to do this, would it be better just to link to the outside MS SQL database table to retrieve the information in a SQL statement within a DTL?

So it is better to link to an outside database via a Linked Table wizard? or Use a BPL to retrieve the necessary data req

3
0 389
Question Yuri Marx · Dec 5, 2020

Languages like Java and C++ allows to develop a multi-threaded program with two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs. Is it possible In ObjectScript? If yes, Where I can get a good sample or application?

5
0 1021
Question Scott Roth · Oct 19, 2017

We are trying to convert some of our SQL Service Integration Service jobs from Visual Studio to Ensemble. If we execute a Stored Procedure within SQL Server Management Studio it is returning approx 12,000 rows. However when Ensemble executes the same Stored Procedure it is only returning 250 rows.

Is there a limitation to EnsLib.SQL.Snapshot?

This is how we are calling the Stored procedure

Method uspInterfaceEnsSelectPER355MC(pRequest As osuwmc.SSIS.DataStructures.InputPER355MC, Output pResponse As EnsLib.SQL.Snapshot) As %Status
{
Set SPQuery = "{ ?= call dbo.usp_Interface_Ens_Select_PER355MC()}"

4
0 1000
Question Scott Roth · Dec 9, 2020

I am fairly new to using VSCode. I have used VSCode to create some files on our Test Server, now I need to move them to Production.

Looking through the VSCode extension documentation, maybe I missed it but how to I migrate code from one workspace to another. In Studio I was use to exporting the code into an XML and just being able to import it on the Production server version of Studio.

Thanks

Scott

9
0 972
Question Florian Hansmann · Dec 4, 2020

Hey Intersystems Community-Member,

Following Issue: When I update a SQL table like (update OnlineV3Admin.ParameterApp set popuptext = '' where ID = '1') and then read it for my Json WebService there is a /"x00" in my Json.

What is the best option to disable that? I need here  a empty String and not /x00.

Any ideas?

Best regards,

Florian Hansmann

1
0 338
Question Devin Gilmore · Dec 3, 2020

Hello,

I need to create a util function that loops thru every character in the data, execute a $ASCII() against it. If it falls outside the realm of extended ASCII we toss it.

the function should receive a string, execute a for...loop across it's length and use $ASCII to evaluate the character. Also the function should return an output argument that indicates if the string is UTF8 valid or not.

could anyone help me with this?

1
0 355
Announcement Rob Tweed · Nov 25, 2020

Those of you who run and support older-style legacy systems on IRIS may be interested in learning about and trying out a new framework I've built on top of my colleague Chris Munt's mg_web technology (details at https://github.com/chrisemunt/mg_web).

There are quite a few older-style and legacy applications out there whose useful life can be extended by making their functionality available as REST APIs.  To make this something that can be done quickly and easily, using modern, industrial-strength web servers, I've created what I'm calling mgweb-server:

https://github.com/robtweed/mgweb-serve

3
0 594
Question ED Coder · Nov 24, 2020

I am getting the date 20201121090000 in the HL7 message, How do I convert it to 2020-11-21 09:00:00 in a easy way?

I am currently doing it by extracting the first 7 values and splitting as date and time and then adding a hyphen using substring.

Is there an easier way by using $ZDATE? or something like that?

20
0 2463
Question Oliver Catling · Nov 27, 2020

Hi,

I am working with XML and I would like to be able to access parts of the XML document and return them as a string. I am building an XPath document then evaluating an expression on it which returns a list of DOMResult objects. After accessing one of the objects I would like to convert this to a string and am having difficulty in doing this. I originally went down the path of essentially creating my own parsing method that converts this to xml itself, but a collegue has pointed out I might be able to use the %XML.Writer class to do this. However, I am unable to find a way to pass a DOMResul


4
0 619
Question David.Satorres6134 · Nov 23, 2020

Hi,

I'm trying to access the categories configuration for the WorkMgr via COS, so I can be able to create new categories for our processes and this way try to overlock the limit of cores*2 workers. I've seen that last version of IRIS is supposed to have a menu on the portal (System Administration > Configuration > System Configuration > WQM Categories), but since we are in 2020.1 this doesn't exist. 

Does anyone have experience with WQM.API to manage the categories, or the usage of ^%SYS("WQM") to set it directly?

My goal is to be able to go beyond the limit of cores*2 that currently is in

1
0 304
Article Alex Kogan · Nov 15, 2020 11m read

Hello all,

               I would like to share the Foreign Key setup I recently used for my project and found it is very useful.  When asking around, I realized that there are some developers out there, who would like more information on explicit foreign key setup, so I would like to briefly discuss explicit foreign key setup and give a quick sample on how to set it up

               In some cases, we may consider using explicit Foreign Keys when we have projects, which contain multiple classes, with properties, which depend on one another and specifically, when deleting/updating a record i






3
1 860
Question James Casazza · Nov 12, 2020

In Cache WIndows environment:

Trying to use the $SYSTEM.SQL.DDLImport to import XML File that has ClassMethods, no SQL Table, but it doesn't appear to be working. I can use this ClassMethod to create SQL Tables. The manual method I have been using is to go into Cache Management Portal, Classes, Import.

I create an XML file first, then run the following to import but get no errors. Any ideas?

 Do $SYSTEM.SQL.DDLImport("Oracle",%ID,dlxml,logfl,0,"",";",2)

Beginning of XML file looks like...

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x

2
0 298
Discussion Benjamin De Boe · Nov 9, 2020

Hi,

InterSystems IRIS has long supported the obvious translation functions required to for converting to upper or lowercase to enforce case-insensitive string comparison (e.g. in ObjectScript with $zconvert) and sorting (e.g. with SQL collation functions, not to be confused with NLS collation). Customers in international contexts have at times used custom workarounds to also treat accent insensitivity or even more advanced normalization duct tape. We’re looking to address such use cases at the system and SQL level to increase convenience for this international audience, which is well represented on the Developer Community.

5
0 399
Discussion Dmitry Maslennikov · Nov 9, 2020

Let's imagine you have to implement a method with a definition

/// Set value to %session.Data
ClassMethod setValue(params...) As %Status
{
}

How it should work

do ..setValue("key1", "val")

is equal to

set %session.Data("key1") = "val"

and 

do ..setValue("key1", "key2", "key3", "key4", "val")

is equal to 

set %session.Data("key1", "key2", "key3", "key4") = "val"

so, quite simple, any amount of arguments, while the latest one is a value, and any previous is an index, should accept at least 2 arguments.

How would you implement this method?

15
0 351
Question Nael Nasereldeen · Apr 16, 2018

Hi,

I need to read a UTF8 encoded text file and translate the content to 8-bit.

Using %File class and $ZCVT(TXT,"I","UTF8") works , but I see that if the content is larger than max string  (32000) and we cut the content

To max string chunks, we can get a <translate> error if we cut it in the "wrong" point..

Is there a better way to do this task?

My code looks like this:

    S file=##class(%File).%New(..LocalFileName)
    D file.Open("R")
    While 'file.AtEnd {    
        S Line=$ZCVT(Line,"I","UTF8")
    }
    D file.Close()

and an example of such an error:

USER>s str=$C
10
0 2254
Article Eduard Lebedyuk · Feb 5, 2016 11m read

Class Queries in InterSystems IRIS (and Cache, Ensemble, HealthShare) is a useful tool that separates SQL queries from Object Script code. Basically, it works like this: suppose that you want to use the same SQL query with different arguments in several different places.In this case you can avoid code duplication by declaring the query body as a class query and then calling this query by name. This approach is also convenient for custom queries, in which the task of obtaining the next row is defined by a developer. Sounds interesting? Then read on!

17
7 7677
Article Steven Hobbs · Oct 8, 2019 7m read

$LIST string format and %DynamicArray and %DynamicObject classes

IRIS, and previously Cache, contain several different ways to create a sequence containing a mixture of data values.  A data sequence that has been available for many years is the $LIST string.  Another more recent data sequence is the %DynamicArray class, which along with the %DynamicObject class, is part of the IRIS support for JSON string representation.  These two sequences involve very different tradeoffs.

$LIST String Format

$LIST format was invented some time ago when memory address spaces were small and when disk drive

4
10 3358
InterSystems Official Raj Singh · Oct 20, 2020

Hello Developer Community!

Once again I'm here to talk about the ObjectScript extension for Visual Studio Code, and this time we are excited to announce the release of version 1.0!

The community has come together in an unprecedented way to deliver this product with InterSystems, and its only fitting that a tool so critical to  developer productivity would be built with community testing, feedback and source code from the very beginning.

What's New

Most of the features in this release have been present since 0.9 and were announced earlier in this post. They have all been enhanced and polish

0
0 1148
Question Nora Hutchison · Oct 14, 2020

–  I want to “copy” a file to another, appending if the file already exists. The below code works, except it overwrites the new file, rather than append.  The documentation says CopyFile will append

//Both files exists, so we can combine them
                               
                 set tsc=##class(%File).CopyFile("D:\Files\Out\Vigilanz\AD_Lawson10132020.txt","D:\Files\Out\Vigilanz\employee10132020.txt"
                                if $$$ISOK(tsc)
                                {
                                !, "SQL file copied"
                                }
                

2
0 706
Question Scott Roth · Oct 9, 2020

I noticed when creating Record Map's within Ensemble that it is creating a Persistent cache table as it translates the file and puts it into the Record Map data structure.

I was wondering if there was a way to add a column to the cache table that is Hidden from the record map, but is a calculated date value on when that record was inserted? 

From time to time I have gotten questions about what was valued in the incoming data stream, and I thought it would be helpful to add a date so I can sort on by which date that record came in on.

Thanks

Scott

Cache for UNIX (IBM AIX for System

4
0 330
Article Henrique Dias · Oct 6, 2020 2m read

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!

0
0 456
Discussion Evgeny Shvarov · Sep 28, 2020

Hi developers!

Want to discuss with you the case of %Status.

If you familiar with ObjectScript you know what is it. I'd love to hear the history of the case why it had appeared in ObjectScript but it turned out that almost every system/library classmethods return %Status and there is a whole set of tools to deal with it.

What is does it gives you the responsibility to check the value or %Status of every system method you call.

E.g. if you save the data of the persistent class,  you should never call like this:

do obj.%Save()

you need to call:

set sc=obj.%Save()

if $$$ISERR(sc) do // something or quit.
19
0 1279