#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 Kurro Lopez · Jan 24, 2018 3m read

Sometimes, we need to copy part of the properties of an object into a different one. 
The simplest thing would be to do the following:

Set obj1.FirstName = obj2.FirstName

Set obj1.SecondName = obj2.SecondName

What happens if the object contains a large number of properties? or we just want to extract an important group of data, and complement the information in another object?

Having the following classes:

6
0 1838
Question Thembelani Mlalazi · Mar 27, 2018

Morning guys  I have a SQL operation that I use to read data and results to a record map. But seems to have trouble saving the objects to a record map as I get this message

ERROR ErrException:
zInsertObject+2^%Library.RelationshipObject.1 -- logged as '-' number - @''

please help  here is my code let me know if I missing anything thank you in advance

2
0 771
Question Ben Spead · Mar 23, 2018

I've been writing ObjectScript for a long time and was a little surprised by this behavior so I'd like to understand what is going on.

I was doing a peer review on some source which had roughly the equivalent of the following line:

Set myRecord = ##class(MyObj.Record).%OpenId(id)
Set emailList = previousEmails_","_myRecord.RecordGroup.EmailList

I flagged it for further testing because the code didn't check if RecordGroup was set and I knew that not all records were part of a Group so I was expecting that in cases where it wasn't set this line should throw an <INVALID OREF>

2
0 405
Question Jiri Svoboda · Mar 8, 2018

Hello community,

I need to perform some processing-heavy operations on a set of input objects and I would like to utilize more than a single processor core to do the heavy lifting.

Is there any way to call methods in parallel and wait for the results in a blocking way?

Basically, I am looking for an equivalent of the pythonese

with Pool(n) as p:
    results = p.map(function, data)

Thanks

Jiri

EDIT: Correct English :)

5
0 635
Article Vitaliy Serdtsev · Nov 17, 2017 6m read

This series of articles aims to address the following topics:

  • Creation of a web application based on REST pages;
  • Overview of some tools for tracing (debugging) HTTP requests;
  • Switching from hyperevents to... hyperevents;
  • Integration with jQuery File Upload;
  • Conversion of JSON from the {id:1,parentId:1} format to the {id:1,children:[{}]} format for tree visualization;
  • Integration with jQuery EasyUI (using datagrid and tree as examples);
  • Other topics.
1
1 1095
Question Vivek Ranjan · Feb 1, 2018

WRF to below example my idea is to check whether red is present in the list mylist.  You can very well use LINQ on enumerable in C#

mylist.Where(x => (x.Property2 == "red")).ToList().Count;
set mylist=##class(%ListOfObjects).%New()For i=1:1:2 {S object = ##class(User.NewClass).%New()
  Sobject.Property1=iS object.Property2="red"do mylist.Insert(object)}

It can be done with iterating over mylist

for j=1:1:mylist.Count(){Set item = mylist.GetAt(j)
   If (item.Property1 = "red") { // get the count }
   //set exist = item.Find("viv",1)}
3
0 555
Question Arun Kumar · Feb 1, 2018

Hi Guys,

Can you please advise on the below queries. 

Query 1:

Example 1:

 S a="345",b="arun",c="kumar",d="hi",e="yello",f="orange"

Example 2:

S a="345"

S b="arun"

S c="kumar"

S d="hi"

S e="yello"

S f="orange"

Can you please advise me, which one is performance wise is better. 

Query 2:

Example 1:

S:a=1 R="Arun"

Example 2:

I a=2 R="Arun"

Please advise me, which one is giving better performance in this. 

Any lead would be appreciated. 

Thanks,

Arun Kumar Durairaj. 

11
0 1127
Question Kishan Ravindran · Oct 12, 2017
Set httprequest=##class(%Net.HttpRequest).%New()
	Set httprequest.Server="www.intersystems.com"
	Do httprequest.Get("/")
	Do httprequest.HttpResponse.OutputToDevice()
	Do httprequest.Get("/cache/")
	Do httprequest.HttpResponse.OutputToDevice()

The above is the code which i found in this link http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?… 
How do the above code works and can i be able to run this?

Thanks in advance.

5
0 3571
Article Robert Cemper · Feb 16, 2018 2m read

The base class Bmap.Person defines persons within an organization distributed
by various countries. All records are indexed by (Country, PersonalId).
this structure doesn't allow use of bitmaps.

So a wrapper class Bmap.PersonQ around the data eliminates the top level of
the index (Country) and isolates the PersonalId (%Integer, MINVAL=1).
We are ready to use a Bitmap index.

A few performance figures on 300010 generated records.
You see that Relative Cost are sometimes quite misleading.

base

  select count(*) from Bmap.Person  
  300010 global references 1600446 lines executed   

demo 1

0
1 981
Question Mike Minor · Feb 9, 2018

I'm trying to learn how To use SQL in CACHE, so I hope I don't bore you with "Dumb" questions.... 

I'm getting "ERROR #6022: Gateway failed" message following this line of code. 

s sc=gc.Prepare(hstmt,pQuery) 

This line of code comes from an example I found in the documentation.  pQuery is the "Select" statement setting up the variables and tables I'm trying to pull information from. 

What does that error indicate? 

Thank you. 

5
0 1469
Question Arun Kumar · Feb 5, 2018

Hi Guys,

I would to know, I have a drop down list items in my applications. While, am clicking on the drop down bx, there are few numbers of listed items, while am doing mouse over action, I should display the entire text of selected item from that drop down list box, even am not selecting that item. I would like to know about the what is exact text it contains in Zen framework. 

If any lead would be appreciated. 

Thank you in advance. 

13
0 1332
Question Khalid Saleem · Feb 5, 2018

I am trying to determine the write-access to a windows-directory, using the method %File.Writeable(). But, this method always returns the boolean "true", even when I have revoked the write-access of Healthshare-user in this directory.

Note:

  1. When the same ensemble-service tries to write a file in this directory (which it says is "writeable"), it fails.
  2. The method %File.Writeable(...) works perfectly in the case of files.

Any help is appreciated. Thanks in advance... :-)

17
0 1158
Question Minsu Kim · Feb 5, 2018
Hi global developers!

I am using terminal but I have some problem with it.

I use $C(1) (ascii code 1) to separate data but I can't see it in the terminal and This is really hard to see in the table.

So I want to get you guys good brain and skill :)

how can I see it in the terminal ?

Terminal(intersystems) :

I can't see anything

another program :

It replaced ascii code 1 (=SOH) to  ┌ (Special Character)

I want to see like another program in Intersystems's terminal.

Thank you smart developers!

3
0 510
Question Robert Harris · Jan 27, 2018

Hi,

I have an Atelier question.

I have a routine developed in Studio to upload a tab-delimited text file to process using Objectscript into Cache.

In Windows, to upload the file “test.txt”, I used the Objectscript commands,

 Set uploadfilename = “c/testdata/RNAseq/GDC download 11-19-17/GDC download 11-19-17 counts/GDC download 11-19-17 unzipped/test.txt”
      set file = ##class(%Stream.FileCharacter).%New()
      set file.Filename = uploadfilename  ; pass in the file name of the file you want to open.

How should this be done on a mac?

Should I use the UNIX,

7
0 408
Question Scott Roth · Nov 18, 2016

I am trying to come up with a way to decode the Base64 we receive in an HL7 message into a PDF file and save it in a directory on our AIX machine. I thought I had the following working at one time but I am having issues. Has anyone done this before?

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream, Ancillary As %String) As %Boolean
{
set Oref = ##class(%FileBinaryStream).%New()
set Oref.Filename = Ancillary
Do base64.Rewind()
While 'base64.AtEnd {
    set ln=base64.ReadLine()
    set lnDecoded=$system.Encryption.Base64Decode(ln)
do Oref.Write(lnDecoded)
}
Do Oref.%Save()
quit 1
}

Thanks

Scott

5
2 4621
Question Andrei Luiz Nenevê · Feb 24, 2017

Hi,

My doubt is about the SQL Query in Caché:

I don't want to take all results from the table and orgainze them manually, for example: I have a table with 50 records, but I only want to select 10 records, being from tenth until the twentieth and this without knowing their IDs.

So, how can I do this, without losing performance, there is any way?

NOTE: In other SQL languages I can do, for example, SELECT * FROM extbl Limit 10 OFFSET 10

Thanks,

Andrei L. Nenevê

8
1 3583
Question Scott Roth · Jan 12, 2018

What happens if you don't declare a Persistent value when you call ExecuteQuery()? What does Ensemble set as the key value for your query? I have a query that I've executed on SQL Server, and I get 15 rows, but because this is my second time querying the data Ensemble thinks it exists. 

The Method in question is SelectProviderClarityAudit. If I call this query multiple times it is not returning the same number of results each time in Ensemble.

3
0 520
Question Brian Downing · Jan 8, 2018

This is probably a very naive question but :
Is it possible to create a Windows executable file from a Cache MUMPS (COS) routine, such that the routine can be run directly from Windows ?
If so, could some kind soul direct me to a source of information that describes the process.
I am using the free Intersystems Cache installation (CachePCkit V2017.1) on Windows 10 for my own use & personal development.

Thanks

13
0 1527
Question Manikandasubramani S · Jan 4, 2018

Hi All,

I am new to webservice and UPS. I have tried the sample URL's that UPS have given for testing in PHP codes and it works just perfect for me.

But when i try to hit the same URL's in Ensemble. it gives some errors from UPS.

If anyone of you guys here has any knowledge about UPS integration or the webservice please help me. it will be much appreciated and helpful.

The ensemble code that i am trying with is,

5
0 1428
Question Joe Schra · Jan 4, 2018

Hi Everyone,

I am trying to reference a field, however, in our production environment, it can be found in the first second or third iteration. My code was only qualifying on the first iteration. I have been attempting to include all iterations, but I have come up short...below is a snippet of what I am attempting to use.  My original code simply had GetValueAt("PID:13.4") but this only referenced the first iteration. Thanks for any thoughts!

Set PID13 = pInput.GetValueAt("PID:13")
For iIndex=1:1:4 {
  Set Eaddr = pInput.GetValueAt("PID:13.4[iIndex]")
  If (..Contains(Eaddr, "@")) {
1
0 316
Announcement Evgeny Shvarov · Dec 26, 2017

Hey guys!

Thanks for participating in our small but productive COS marathon on behalf Adventofcode 2017!

The leaderboard is here:

And we are ready to announce the winner but need your public repositories with COS solutions inside. Please share it below in comments.

We have results!

1st place: Bert Sarens!  Repository.

2nd place: Peter SteiwerRepository.

3rd place: Dmitry MaslennikovRepository.

Congratulations Bert! 

You get 10,000 Global Masters points and the title of the AdventOfCode champion in Caché ObjectScript at least until December 2018! 

10
0 679