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

Discussion Francis Galiegue · Apr 4, 2016

Hello community!

At the global summit in Phoenix, we (Lite Solutions) will be presenting a tool performing static code analysis on ObjectScript source files. You can see it in action at this URL:

https://demo.cachequality.com

Technically, the tool is a language plugin over SonarQube (http://sonarqube.org) and consists of three main parts:

  • parsing the language,
  • collecting metrics,
  • collecting issues.

The third point is where we kindly request for feedback.

6
1 2164
Question Mack Altman · May 26, 2016

Does anyone have any experience with getting, unfortunately, an older version of Cache to authenticate via SMTP to send email? I have verified that the settings are set up properly on the mailbox as I have successfully sent an email from a LAMP server, which comes from the same IP address.

If you have any thoughts, I would greatly appreciate it.

This is the error I receive

ERROR #6034: SMTP server connection failed during MAIL FROM command: <READ>zSend+105^%Net.SMTP.1.

when I run the following.

6
0 2738
Question Jack Huser · Aug 22, 2018

Hello Everyone,

I was wondering about the best way to initialize several variables, or several lists of variables.

Would it be better to write it like:

set (var1, var2, var3) = "value1"
set (var4, var5) = "value2"
set (var6,var7,var8) = "value3"

or

set var1="value1", var2="value1", var3="value1", var4="value2", var5="value2", var6="value3", var7="value3", var8="value3"

or

set var1 = "value1"
set var2 = "value1"
set var3 = "value1"
set var4 = "value2"
set var5 = "value2"
set var6 = "value3"
set var7 = "value3"
set var8 = "value3"

When comparing the speed of each methods:

6
0 613
Announcement Daniel Tamajon · May 21, 2018

As a developer, usually I'm concerned about how my code health is, and how the other coders code can affect to my own work.  And I'm quite sure most of us feel very similar.

In our company we use a Static Code Analysis tool to analyze code for different languages to ensure we are writing high quality and easily maintainable code by following a few best practices in terms of code structure and content. And the question was: why should be different for Caché ObjectScript language?

3
4 1233
Question Stella Ticker · Jul 20, 2018

The REST webservice works perfectly when run on SOAP UI. This end point server is an https site that uses basic authentication (uname and pwd).  But when I run the request through an Enslib.Rest.Operation using a configured SSL and stored credentials, I get an "unauthorized" error, unless I explicitly hard code the password in the operation class. HS Version is 2014.1 .

I have 2 questions. Pardon me, they are both related!!

4
0 1234
Discussion Evgeny Shvarov · Apr 22, 2018

Hi, Community!

Have a question for general discussion. 

In ObjectScript we have cls for classes and mac code, which both compile into int code. 

Is there any reason when you use mac instead of cls  for non-persistent classes?

For me the benefits for cls are:

1. Inheritance and other OOP features

2. Auto-documented code 

For mac one visible benefit is easier call in terminal:

do method^Utils(p1,p2)

vs

do ##class(Package.Utils).method(p1,p2)

What is your choice and why?

43
1 3053
Question Laura Cavanaugh · Jul 12, 2018

I have a class that has a property calledTags (like DescriptiveWords, but tags), where multiple tags are possible.  I am trying to decide on list of Objects vs. array of Objects.

Based on this post: https://community.intersystems.com/post/querying-list-property-sql, sounds like using an array of Objects is the better way to go. Indeed, I already noticed that it's not possible to have duplicates when using an array of Objects.

However, I am unable to make my queries on the array of Object use an index.  

4
0 974
Question Jasenko Donlagic · Jul 3, 2018

Hi everyone,

I am still learning the platform for a student project and have to do some streaming and data analysis next. Since for my case I have no "live api" I wanted to just stream json files and output the data as it comes in from the files. (basically to emulate a incoming data scenario)

So thanks to the documentation and community posts I have figured how to create a stream and read data from a JSON but since I'm also new to JSON I have some parsing problems. I don't know how to access subarrays/sub-objects via objectscript.

2
1 2941
Question Stephen Wilson · Aug 8, 2017

I came across this behaviour when debugging some Cache ObjectScript code.  I have provided a simple example below.

Example 1:

START
 ZBREAK /TRACE:ON:"C:/temp/zbreak_trace.log"
 ZBREAK *VAR1:"T"
 ZBREAK *VAR2:"T"
 ZBREAK *VAR3:"T"
 Set (VAR1,VAR2,VAR3)=""
 Kill VAR1,VAR2,VAR3
 Quit

Trace Output:

Trace: ZBREAK SET VAR3="" at START+5^TRACE

Trace: ZBREAK KILL VAR1 at START+6^TRACE

Trace: ZBREAK KILL VAR2 at START+6^TRACE

Trace: ZBREAK KILL VAR3 at START+6^TRACE

$ZV value:

Cache for Windows (x86-32) 2017.1 (Build 792) Mon Mar 20 2017 20:20:07 EDT
3
1 419
Question CM Wang · Jun 27, 2018

I am trying to read some binary data from a local file or through socket.

The binary data is like H.264 codec, I need to read data BYTE by BYTE (even BIT by BIT) and decide the next step based on the data read so far.

I check the documentation and it seems like most of the sample focus on human readable IO, ie: LINE by LINE.

Could I achieve my goal through COS?

Thanks. 

3
0 1491
Question Mack Altman · Jun 25, 2018

Typically, I have time to review the documentation, which I'm sure is here. However, I have a workaround (TEST1) but I was wondering if anyone could assist me in advising how I would need to adapt the curly brace snippet (TEST2) to provide the same result.

Thanks for any help you can provide.

TEST1(STATUS=1) K (STATUS)X "S MSG=$S(STATUS:""HELLO"", 1:""GOODBYE"")"W !,MSGQTEST2(STATUS=1) PUBLIC {X "S MSG=$S(STATUS:""HELLO"", 1:""GOODBYE"")"W !,MSG}
3
0 385
Question Ben Spead · Jun 12, 2018

I have a serial object:

Class EmbedObj Extends %SerialObject

which is stored as a  property of another object

Class ContainerObj Extends %Persistent

Property InnerObj As EmbedObj;

Property Foobar As %String;

Question:

From within the context of an instance of EmbedObj, how can I navigate to the containing instance of "ContainterObj" and find that value of its Foobar property?

Harder Question:  Is there a way I can do this as part of SQLComputeCode? (my EmbedObj has a Calculated property which now needs to depend on the value of property Foobar of the containing object).

8
0 759
Question Jason Parker · Jun 17, 2018

Hello,

If this question is in the wrong section, I apologise.

Has anyone ever used Cache Object Script to connect to any hardware such as a sensor?

What I mean is this :-

Lets assume that code has been written in Cache Object Script where it can detect breaks in electrical connections.

2
0 328
Question Antonio Garcia Martinez · Jun 8, 2018

Hi,

I was wondering if there is any way to count elements from an array. I guess not as an array could be multi-dimensional and that would be a problem to return the number of elements inside the array.

As an example:

S a(1) = "blue"
S a(2) = "red"
S a(3) = "yellow"
w a.count() ==> 3

Information about arrays: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KE…

Thanks

4
0 2161
Question Evgeny Shvarov · Jun 5, 2018

Hi, Community!

$CASE is a fine syntax sugar for "Ifs" with one-line/one-word expressions, like in docs:

SET daynum=$ZDATE($HOROLOG,10)
  WRITE $CASE(daynum,
              1:"Monday",2:"Tuesday",3:"Wednesday",
              4:"Thursday",5:"Friday",
              6:"Saturday",0:"Sunday",:"entry error")

But if my expression for a current case is a multi-line business logic? Can I use "{}" somehow or better go with "IF" instead?

13
1 643