#ObjectScript

0 Followers · 1.5K 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 Eduard Lebedyuk · Aug 9, 2016 2m read

Process-private Globals  can be used as a data global in storage definition. That way, each process can have its own objects for the class with ppg storage. For example lets define a pool, which can:

  • add elements to a pool (ignoring duplicates)
  • check if an element exists in the pool

Here's the class:

2
0 990
Question Eduard Lebedyuk · May 23, 2016

Problem: I have a REST broker, and if I hit a code block, which does IO redirection, the REST reply becomes broken in one of the following ways:

  • Binary output
  • No output
  • First 4096 characters of the reply are missing

Consider the following REST broker:

3
1 1306
Question Ponnumani Gurusamy · Aug 12, 2016

How to get a user input in cache . Below this program run in browser but displayed the error of "

Caché Server Pages Version 2016.1.1.108.0

Error Condition      The processing of the request was interrupted

CSP application closed the connection before sending a complete response"

<html>
<head>
<title>User input </title>
</head>
<body>
<script language="Cache" runat="server">
"enter 1ST num",x
"Enter 2ND num",y
= x+y
z
</script>
</body>
</html>
 

1
0 685
Question Scott Roth · May 9, 2016

At the Global Summit several folks had mention that they developed their own production monitor. I am looking to create a monitor similar to eGate that we only display those Services/Processes/Operations that are in trouble, and those Errors that are showing up in the Event Log. Does anyone have any examples of this?

Thanks

Scott Roth

The Ohio State University Wexner Medical Center

3
1 685
Question Bapu Hirave · Aug 4, 2016

Hello Cache experts,

Has anyone tried using Cache object script to check windows service is running or windows service installed or not on same computer or remote computer ? basically i am trying to develop cache program which will check "windows service" running or installed on current computer or remote computer. Based on the status of this windows service, i want to write some business logic in our application. Any suggestions will be more welcome

1
0 552
Announcement Rustam Ibragimov · Aug 4, 2016

Hello, guys. 

We have recently created a syntax highlighting for COS for Atom text editor. You can find it on https://github.com/intersystems-ru/atom-language-cos

Installation: 

  1. Download or clone this repository
  2. Copy everything to ~/.atom/packages/
  3. If you have your Atom editor open, then you need to reload it (enter  Window: Reload in Command line)

It's been few days since the release, so please if you find a bug, let us know through creating an issue or forking and making a pull request. 

P.S. After it gets more or less usable, we will use this syntax as a basis for GitHub highlighting for COS.

0
0 603
Question Jean Millette · Jul 25, 2016

We are creating a package (written in Caché Object Script) that will provide access to an external DB (MySQL). Because applications that use our package will be run from machines with various, potentially unexpected, operating systems, we’d like to establish a connection to the external DB without using DSNs (we’ve heard that setting up DSNs on certain non-Windows machines can be cumbersome and problematic).

4
0 1253
Article Daniel Kutac · Jul 18, 2016 3m read

Cache tricks

Several years ago, long before Developer Community Portal was launched, I published a series of Caché tricks at one of Czech web sites. In this article, I’m posting translated version of one of them.

Capturing output of someone else’s methods or routines

Suppose you, or someone else created a useful method or routine, that was producing some computation that you’d like to benefit from, but the routine was writing output to process principal device.

4
0 2870
Article Leo Makowski · Jul 15, 2016 5m read

              While Studio and Atelier are useful development interfaces, there are occasionally situations where a quick edit needs to be made to code and only terminal access is available.  A useful set of tools to do this are the zload, zprint, zinsert, zremove, and zsave commands.  These are abbreviated to zl, zp, zi, zr, and zs respectively.  While each of these commands has its own page in documentation, this article will synthesize that information with examples to provide instruction for their combined use.

2
1 796
Question Eduard Lebedyuk · Jul 14, 2016

I have the following problem:

  • There are several classes with method generators, which needs to be compiled during every compilation
  • I have "ckub" qualifiers enabled in studio
  • I don't want to remove "u" qualifier because I need it very much in another namespaces

So how do I force classes with method generators to recompile when "u" qualifier is present?

2
0 1355
Question Rustam Ibragimov · Jul 12, 2016

Hello, everyone!

I opened one project and there I found such lines as 

$$Export^%occXMLExport(filename,"-d /diffexport",InternalName)

Do DecomposeStatus^%apiOBJ(sc,,"d")

The problem is I can't go to their definition and find them in documentation. It says that they don't exist on the server. However, the project works and these routines execute. 

How can I import them into my project? 

3
0 810
Question Rustam Ibragimov · Jul 13, 2016

Hello, guys!

I want to get access to the folder where all files of the namespace are stored using COS. I found a way to get access to class files and found a folder where all csp, html, css etc files are stored.

However, is there any folder which contains all files(even .mac and .int)?  

Or, probably, there is a method which gives all files content?

2
0 445
Question Nikita Savchenko · Jun 14, 2016

Hello!

In Caché there is a way to print all current variables using write command without arguments:

USER>set Einstein = 1879
USER>set Mozart = 1756
USER>write
Einstein=1879
Mozart=1756

But is there a way to get a list of this variables? I am looking for something that would return value like $LB("Einstein", "Mozart") for this case.

Thanks!

16
0 1752
Question Evgeny Shvarov · Jun 23, 2016

Hi!

Here is the question in Russian Forum regarding roots extracting.

In Caché ObjectScript we use exponentiation operator (**) to raise an exponent to power. F.e. let's raise 3 to power of 3: 

USER> write 3**3 

27

And we use the same operator to extract the root. 

USER> write 27**(1/3) 

2.999999999999999963

And 2.999999999999999963 is not 3, obviously.

How to extract roots properly in Caché ObjectScript?

5
0 446
Question David Losiewicz · Jun 23, 2016

I am testing application code and want to simulate error conditions. 

I am trying to use the following to define a custom error with a class method.

$SYSTEM.Status.Error($$$GeneralError,"Any text here")

My class method code looks like this....

set RunStatus=$System.Status.Error($$$GeneralError,"DXL Testing Run Error")

Class compile fails because the $$$GeneralError is unknown. 

ERROR: DBMS.Reports.TaskPage.1(5) : MPP5610 : Referenced macro not defined: 'GeneralError'
 TEXT: set RunStatus=$System.Status.Error($$$GeneralError,"DXL Testing Run Error")
 

5
0 1452
Question Francis Galiegue · Apr 27, 2016

Hello,

I am still a beginner with COS and am struggling with these concepts. While digging through the official documentation will eventually tell you everything you need to know, getting started is nevertheless not an easy feat...

Is it possible to create a "lists/array/multidimensional 101" page for beginners? And, for instance, its interaction with $data, what it means to use "as list of something" or "as array of something", how to walk lists, how to add/remove elements, how to extract sublists etc?

12
0 654
Question Nikita Savchenko · Jun 1, 2016

Hello!
Are there any short ways of serializing COS entity to the string? I am searching for something like .$toJSON() , but I need Caché 2013.* support.

The one way I supposed to work is to use $listbuild:

set str = $LISTTOSTRING($LB(1,2,3,",",5))
set list = $LISTFROMSTRING(str,",")
zw list
list=$lb("1","2","3","","","5")

 

But the problem is that $listbuild does not escape delimiters, and it is not possible to deserialize serialized string. The structure I need to serialize may contain any characters.

Are there any short ways to do this in Caché to avoid writing custom parser?

15
0 3319
Article Alexander Koblov · May 20, 2016 12m read

Order is a necessity for everyone, but not everyone understands it in the same way (Fausto Cercignani)

Disclaimer: This article uses Russian language and Cyrillic alphabet as examples, but is relevant for anyone who uses Caché in a non-English locale.Please note that this article refers mostly to NLS collations, which are different than SQL collations. SQL collations (such as SQLUPPER, SQLSTRING, EXACT which means no collation, TRUNCATE, etc.) are actual functions that are explicitly applied to some values, and whose results are sometimes explicitly stored in the global subscripts. When stored in subscripts, these values would naturally follow the NLS collation in effect (“SQL and NLS Collations”).

7
1 3115
Question Paul Reesman · Jun 7, 2016

We have noticed that when compiling with Atelier (either Atelier itself or sending the code through the REST interface) that the build will fail if all brackets '() {} []' are not closed. This includes brackets opened in comments.

For example, this will fail:

class myclass

{

//if someVar {

}

I do not know if this issue has been fixed or if this issue has been brought up, but it has been a nuisance over here.

3
0 413
Question Nikita Savchenko · Jun 6, 2016

Hello!

I have a WebSocket application which spawns new process using JOB command.

Sometimes WebSocket connection can be terminated, and in the meantime I need to hold spawned process alive until it can be associated with the new WebSocket connection. (Do not suggest serializing process state here instead please)

Technically, in Caché WebSocket connection is represented by the class, which executes in its own process. This process is terminated when the connection is lost. In this case the JOBbed process does not terminates (thanks Edward), but it rely on $ZPARENT variable.

11
0 449
Question Paul Reesman · May 18, 2016

I am just trying to make a quick hand off HTTP production. I have the class built and compiled onto the server and the production is running as a service. When the production is called (by an inbound job) I can see that the HTTP.InboundAdapter is being used successfully and the stack continues all the up to ProcessInput where OnProcessInput is called in Ens.BusinessService. Instead of using the class that I wrote which has both extended Ens.BusinessService and implemented my own overriden OnProcessInput method, it calls the OnProcessInput within the Ens.BusinessService which just returns a

15
0 1534
Article Mike Kadow · May 24, 2016 2m read

NewBie's Corner Session 4 The Plus Sign and Concatenation Operators

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Click on the Caché Cube in your system tray and select Terminal to try out the commands.

Plus Sign (+) operator

Typically, the Plus sign (+) adds two numbers together. This is true in COS (Caché ObjectScript), but COS uses it in other ways as well.

Set the variable X to a value of +12

Set X=+12
Write X
12

Set the variable X to the value of +"ABC"

Set X=+"ABC"
Write X
0
0
0 469
Article Mike Kadow · May 17, 2016 3m read

NewBie's Corner Session 2 Variables Set and Write commands

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Session 2 – Click on the Caché Cube in your system tray and select Terminal to try out the commands.

Variables

Like other computer programming languages, Caché uses Variables and the values they represent to control programming. Variables are elements that represent data values. Manipulating and interrogating variables is at the root of programming.

0
0 421
Article Blaise ZARKA · May 13, 2016 1m read

Hi,

If you want to import data from a mySQL export file (exported with mysqldump), you will find here a little script that could help.

Only the INSERT commands in the sql file are executed into Caché. Indices are not computed for better performance.
%NOINDEX, %NOCHECK and %NOLOCK are generated on each INSERT line.

Currently, the file can not contain a "),(" pattern inside the values part of the INSERT command. If this is the case, the line is skipped. This feature may be implemented in the extractValuesList method.

3
0 588
Article Mark Hanson · May 11, 2016 1m read

Often when debugging COS code you get an error message such as '<UNDEFINED>test^routine *test' so the first thing you want to do is to take a look at this code and see what it is doing. From the command line you can:

ZLOAD routine ZPRINT test

Which means splitting the $zerror information into the routine name and the line and adding the zload/zprint commands. Also you often want to view the lines above the one where the error happened as this gives you some context of how you got to this line, using ZPRINT you could 'ZPRINT +1:test' but that may display hundreds of lines.

6
0 1002