#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 Derek Day · May 10, 2016

I have some logging code that outputs task status information to a log file. I would like to make the log available for reading while it is open for writing. The file is opened using the "L" option (Lock):

Open tLogFile:"WASL" Set tLogOpen=1


My intent was to prevent multiple processes from accidentally writing to the file and having messy output. Unfortunately, if the process is taking longer than expected, one can not simply open the log file to figure out what is going on because the "L" lock prevents the file from being opened for reading as well as writing.

2
0 429
Article Evgeny Shvarov · Apr 16, 2016 1m read

Hi!

Want to share with you code snippet of try catch block I usually use in methods which should return %Status. 


{ 
 try {
  	$$$TOE(sc,StatusMethod())
 }
 catch e {
 	set sc=e.AsStatus()
 	do e.Log()
 }

Quit sc 
}

Here $$$TOE is a short form of $$$TROWONERROR macro.

Inside macro StatusMethod is any method you call which will return %Status value. This value will be placed into sc variable.

In case of sc contains error execution will be routed to try catch block. You can wrap any Status methods calls in your code if you need to catch the errors coming from them.

21
2 3495
Question Ricardo Paiva · May 6, 2016

I am using java gateway imported/proxy classes and JG business service. I need to load a dll at run time.

I use System.loadLibrary/System.load when in java. I’ve tried $ZF(-3,” C:\Windows\System32\pteidlibj.dll”) and $ZF(-4,1,"C:\Windows\System32\pteidlibj.dll") but I’m getting <DYNAMIC LIBRARY LOAD> error.

How can I load a dll at run time using COS?

5
0 1340
Question Francis Galiegue · Apr 20, 2016

Hello,

It is time for me to eat my own dog's food and start implementing unit test running with coverage :) I will be inundating IRC with questions at this point, but I have a more general question first.

In this tutorial, it is supposed that your unit tests are exported as XML first... But that's not very practical. Is there a way, instead, to run all tests from a given project without having this export?

My first thought on how to do this would be to:

3
0 685
Question Francis Galiegue · Apr 30, 2016

Hello,

Still related to the unit test with coverage support project, one goal is to make that package available to everyone.

One possible way I already know of is that all fully qualified class names (ie, the package + the class name) start with %, which mean that on installation all classes will end up in the %SYS namespace, but this requires that the install be done as a user with the necessary privileges to write to %SYS.

6
0 523
Article Timothy Leavitt · Jan 5, 2016 1m read

(Possibly?) little-known fact: It's possible to use $ListBuild on the left hand side of the equals sign in a set command to extract multiple list values at once:

set $ListBuild(several,individual,variables) = list

For example:

USER>kill
 
USER>set colors = $ListBuild("red","orange","yellow")
 
USER>set $ListBuild(r,o,y) = colors
 
USER>write r,!,o,!,y,!
red
orange
yellow

See for reference: http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls…

4
0 483
Announcement Francis Galiegue · Apr 20, 2016

Hello community!

Heretofore is announced a new project which aims at providing a usable library for both running unit tests and collecting code coverage information at the same time:

https://github.com/litesolutions/cache-utcov

I shamelessly admit that this is my first project written in ObjectScript; the only source file right now barely loads a %Studio.Project instance on a given namespace and fails ungracefully on failure (it HALTs; meh); and even on success it will not even list the items correctly... Well, that's part of the learning curve.

14
0 696
Article Evgeny Shvarov · Apr 15, 2016 2m read

Hi!

Please find all the source code Global Summit 2016 Sessions and Experiences in following GitHub repositories:

Codes are in UDL form which is native to Atelier IDE.

Here is small guide how you can check out this project into your Atelier:

Let's see how to load code directly from GitHub URI. 

Open Atelier. Go to File -> Import -> Git -> Clone URI

   2. Specify URL for repository and press Next

1
0 980
Question Francis Galiegue · Apr 18, 2016

Hello,

For CachéQuality I'd love to be able to create issues when the programmer uses classes which are deprecated for this or that version of Caché... But short of reading all the changelogs of all versions, I can't really tell when a command appeared (for instance RETURN; I know now that it appeared in 2014.x, but it took me some time to realize that), or when a (set of) class(es) became deprecated (for instance %GlobalCharacterStream to be replaced with %Stream.GlobalCharacter -- I don't even know since which version this is true :/).

Is there an existing source which I am missing?

2
0 422
Announcement Francis Galiegue · Apr 18, 2016

Hello,

I hereby announce the creation of an IRC channel dedicated to Caché development:

* network: FreeNode (connect to server: irc.freenode.net)

* channel: ##cos (yes, two hashes).

Topic is anything related to Caché development in spite of the name (and the fact that of Caché development I only really know about COS anyway), so sorry in advance for the restrictive channel name :)

Waiting for you here! (my nick is idletask on freenode)

0
0 369
Question Francis Galiegue · Apr 13, 2016

Hello everyone,

I have discussed extensively with Andrew Cheshire, the author of the Atelier parser (which I'll be able to hack on and reuse for CachéQuality -- yay!), and while we were at it, we also discussed code coverage.

We ended up talking about the ZBREAK command and its /TRACE option.

It appears that combining this command and the unit test runner, we can indeed do code coverage (Andrew also told me about a way to map "back" routine lines to original lines in the source code).

4
0 424
Announcement Francis Galiegue · Apr 6, 2016

Hello community!

Two new rules have been implemented:

OS0061: unsafe namespace switch

This rule detects when the body of a method contains two or more of the following statements:

  • set $namespace = something, or
  • znspace something.

If this is the case, it then checks whether there is a new $namespace prior to those two declarations; if not, it raises a warning.

List of issues currently found here:

https://demo.cachequality.com/issues/search#severities=CRITICAL|rules=cachequality%3AOS0061|resolved=false

OS0062: confusing identifiers

8
0 556
Article Francis Galiegue · Apr 10, 2016 1m read

Hello!

Link: https://demo.cachequality.com

In this presentation, developer oriented, we will cover this tool, how it works, how you can use it/administer it, etc. Duration 30 minutes.

The topics will include:

  • a short presentation of Caché Quality and SonarQube (which this plugin uses),
  • a demonstration of the rules and how to tailor them to your need.

Questions will be more than welcome! Hope to see you there!

And a big thanks to Evgeny Shvarov who made this possible!

0
0 662
Question Joel Solon · Feb 18, 2016

This morning on the old Caché Google Group, someone posed the following question, which I've decided to answer here, because it's interesting!

Is there a way to iterate ClassMethod's params, and get param's names and values?

The first answer I can come up with is: it's not easy! In any method, you could try to write code like this (where methodName is the name of your method):

1
0 1896
Question Timothy Leavitt · Feb 9, 2016

Looking at a property defined as follows:

Property SystemTime As %Library.TimeStamp [ SqlComputeCode = {Set {*}=$ZDATETIME($NOW(),3,1,0)}, SqlComputed ];

The documentation talks about using SqlComputed and SqlComputeCode with SqlComputeOnChange (specifying which events will trigger computation), and about using them with the Calculated keyword (so it's always computed). I don't see any specific explanation of the case above, though, when neither SqlComputeOnChange nor Calculated is specified.

From a bit of testing, it seems that the behavior is:

4
0 817
Question Scott Beeson · Feb 8, 2016

I've searched the ObjectScript reference for any instances of Upper, Lower or Case and the only thing is a case/switch statement.  In all the documentation I can only find SQL and Cache Basic references for things like UCASE.

So how do I do this in ObjectScript?

For instance, if (ucase(dtype)="G") { }

2
0 419