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

Question Jiri Svoboda · Aug 3, 2017

Hi community,

I have some constants hardcoded in my class as parameter values, and those constants are referenced in many places in my module. Now the need has arisen to provide different value for those parameters depending on some context. Is it possible to create some sort of accessor method for the parameter (like it is possible for properties), or do I need to perform a thorough refactoring?

Thanks.

Jiri

1
0 417
Question Thiago Zenaro · Jul 27, 2017

Hi,

How can I read the stack of another process?

I know about ^JOBEXAM, but I only know how to use through terminal, and I need to get a string, or at least do a method that returns me a string

For example:

I have process A and B

B monitors process A at each second.

B logs information about process A in a table

Informations about lock I get through %SYS.LockQuery and the process through %SYS.Process

How can I get stack of process A from process B to log in the table?

Cache 2015.2.1

Thanks

2
0 589
Question Marek Bernád · Jul 28, 2017

Good day,

I would like to know how to detect in Caché ObjectScript if data saved in string is number and furthermore, if it's type is integer.

I maybe found a solution:
 

set value = "44.2d3"

try{
     set status = $INUMBER(value,"")
     if ('$FIND(+value,".")){
          w "your variable: '"_value_"' is number and integer"
     }else{
          w "variable is number but no integer"
     }
}catch(e){
     w "variable is not number" 
}


But I don't know how to do it correctly or if there exist better solution in COS (or maybe my solution is incorrect).

Thanks in advance for answers.

10
0 2090
Article Eduard Lebedyuk · Oct 18, 2016 7m read

In this article I would like to tell you about macros in InterSystems Caché. A macro is a symbolic name that is replaced with a set of instructions during compilation. A macro can “unfold” in various instruction sets each time it is called, depending on the parameters passed to it and activated scenarios. This can be both static code and the result of ObjectScript execution. Let's take a look at how you can use them in your application.

3
0 2468
Question Stefan Cronje · Jul 17, 2017

Hi,

I have a situation where I write a character stream to a file. The file content gets signed and the signature is sent to a service provider together with the file content.

The signing is done using openssl.

This works perfectly on a dev PC, which is runnning Windows and has a little-endian architecture.

The problem is as soon as I do this on the server, which has a big-endian architecture, the signed value is incorrect according to the service provider.

The content is signed using RSA SHA256 with PSS padding.

I've had a look at $nconvert, $sconvert, etc., but can't get to a solution.

8
0 3396
Question Mack Altman · Jul 12, 2017

It is my understanding that when a routine accesses a global it is temporarily stored in global memory. While the global is within global memory, any other routine would be able to readily access the global from memory and not from disk so long as the same node is being utilized.

For example, RoutineB() would be able to access ^Global(1) and ^Global(1,2) since RoutineA() utilized them, but RoutineB() would have to read ^Global(1,7) from disk as it was not utilized by RoutineA().

2
0 460
Question Thiago Zenaro · Jul 13, 2017

Hi everyone

Is there any way to change a class definition (especifically a query definition during the compilation time)?
The idea is: 
    I have an abstract class with a parameter where I will define the ROWSPEC of a query and some methods to populate e temporary table
The implementation class will override the parameter, specifying the ROWSPEC of this implementation, and the methods will populate the rows in the same format as the ROWSPEC.

4
0 713
Question Mike Kadow · Jul 11, 2017

I am working with Caché Relationships.

I know how to iterate through the One side of the relationship and for each One iterate through all the various Manys.

What I have been trying to figure out, is the code (I can put into a Class) that will start at the top of the Manys, iterate down and for each of the Manys, pull the associated One.

I can do this with SQL or Globals, but I want to use only Class type code.

Is that clear? Any help?

6
0 689
Article Vitaliy Serdtsev · Jul 7, 2017 19m read

Quotes (1NF/2NF/3NF)ru:

Every row-and-column intersection contains exactly one value from the applicable domain (and nothing else). The same value can be atomic or non-atomic depending on the purpose of this value. For example, “4286” can be
  • atomic, if its denotes “a credit card’s PIN code” (if it’s broken down or reshuffled, it is of no use any longer)
  • non-atomic, if it’s just a “sequence of numbers” (the value still makes sense if broken down into several parts or reshuffled)

This article explores the standard methods of increasing the performance of SQL queries involving the following types of fields: string, date, simple list (in the $LB format), "list of <...>" and "array of <...>".

0
0 1168
Article Stephen De Gabrielle · Jul 5, 2017 2m read

I needed to pass through a file with Ensemble but the operation wasn't writing some filenames as given because the  EnsLib.File.PassthroughOperation 'sanitizes' filenames removing characters that are not valid on some operating
systems;
09000655_AEDC_C3344059_A&#47;E_Martin Browne_09000655_201706221018.pdf
09000655_AEDC_C3344059_A#47E_Martin_Browne_09000655_201706221018.pdf

Oh No! It has stripped out my semicolon and ampersand! I need them! (and they are valid filename characters in windows)

0
0 1216
Question Marek Bernád · Jul 3, 2017

Good day, I would like to find out the size of Caché ObjectScript variable in order to guarantee that my program will not leak, equally in terminal and Caché globals.  For example how huge number I can store in that variable ? And what happen in Caché when variable will leak ? How is this behavior treated? (how much memory is reserved for common variable?)

Thanks  in advance for your answers.

2
0 738
Article Vitaliy Serdtsev · Jun 22, 2017 4m read

This is a translation of the following article. Thanks [@Evgeny Shvarov] for the help in translation.

This post is also available on Habrahabrru.

The post was inspired by this Habrahabr article: Interval-associative arrayru→en.

Since the original implementation relies on Python slices, the Caché public may find the following article useful: Everything you wanted to know about slicesru→en.

Note: Please note that the exact functional equivalent of Python slices has never been implemented in Caché, since this functionality has never been required.
And, of course, some theory: Interval treeru→en.

All right, let’s cut to the chase and take a look at some examples.

1
0 710
Question Roger de Coninck · Jun 23, 2017

Class documentation:

class %Exception.General extends AbstractException

Simple exception class that can be throw in user code. You can throw this with code similar to:

	Throw ##class(%Exception.General).%New(name,numericCode,location,data)

The name is a string name for the exception, the numericCode is a numeric error code. If the location field is blank and $$$envCallerErrorInfo is defined then the system will attempt to fill in this location where the exception was thrown from automatically. You can pass additional exception data in the data argument.

1
0 554
Question Rubens Silva · Jun 12, 2017

Here's my issue. I've been using Sample.* globals and packages mapped to another development namespace to realize unit tests. So when I ran it, I notice that I forgot to start a transaction in order to be able rollback it to it's original data.
I assumed that I should use transactions since I was manipulating it's data but I didn't want it to be persisted.

1
0 411
Question Scott Roth · Jun 9, 2017

I have a case where I am creating a PDF file from an Encoded String, and I need to transfer this file over to another server. I was wondering since this is PDF file if I could just invoke the FTP.OutboundAdapter within my Object script that is creating the PDF from the encoded string. Is this possible? Does anyone have an examples of using EnsLib.FTP.OutboundAdpater within their Object Script?

Thanks

Scott Roth

Integration - Interfaces

The Ohio State University Wexner Medical Center

5
0 654
Question Eduard Lebedyuk · Jun 6, 2017
Hi, Community!Last weekend we held the Final of InterSystems Contest on InterSystems Caché and DeepSee as a part of IT Planet Student Championship in Sochi. BTW, this year we had about 2 000 participants in InterSystems Contest.
One of the tasks for the finals was to solve the following  with Caché ObjectScript and use the minimum code. 
Problem description
Write a method that would return the string 9876543210, however cls code should not contain numbers 0-9.
The goal is to write the shortest method.
Here's a method signature (it can't be modified):

ClassMethod main() As %String

23
0 1204
Question Jorge Torres · Jun 7, 2017

Hello experts,

I’m working on an "Sort After" (]]) bug that I traced back to some weird behavior in ObjectScript.  Perhaps someone can enlighten me…

The problem is as follows:

Let’s say we have:

Set A = “1.0”
Set B = “2.2”

If you execute the command ‘Sort After’ (]]), you get the following:

W A]]B
​1

…Which is wrong, A does NOT sort after B.  The output should be 0.

If you set A and B to numeric values, it correctly outputs false (0):

set A = 1.0
set B = 2.2
​W A]]B

0

9
0 520
Article Sean Connelly · Jun 7, 2017 1m read

The Cogs.JsonClass library is now available in the Cogs project on GitHub.

https://github.com/SeanConnelly/Cogs

Please see the README and the /docs folder on how to use the class.

Overview

The Cogs.JsonClass class provides a one step serialisation and deserialisation to and from Caché registered and persistent classes. It is not dependent on any other code and should be compatible with older versions of Caché.

The unit tests have been included in the update, but until I release the dependent Touchstone unit test solution it won't be possible to run these tests.

5
0 674
Question Javier Gonzalez · Jun 6, 2017

Hello everyone,

I'm doing a REST service for integration between 2 systems. The system that invokes me expects a response object where only one of its attributes changes. It could be something like this:

Class ResponseCustomer  {
    Property Code As %String;
    Property Info As Customer;
}
Class ResponseAppointment {
    Property Code As %String;
    Property Info As Appointment;
}
Class ResponseCancellation  {
​    Property Code As %String;
    Property Info As %String;
}
3
0 639
Question P Patz · Jun 1, 2017

I need to guarantee that a parent AND child rows has been inserted successfully before any other process is able to read ANY of the data.

What is the proper way to prevent DIRTY reads?  Per the InterSystems's documentation I should be able to use 'START TRANSACTION ISOLATION LEVEL READ COMMITTED'.  I have attempted to use these commands in embedded and dynamic SQL calls to no avail.

I have to be able to insert the data via JDBC calls, but legacy Caché (.MAC) may be reading the data, and if the data is read to quickly, I could have processing errors, as all the child rows have not been inserted.

3
0 859