ObjectScript

Syndicate content 29 

I have come across several cases where I need to set a Date filter to send only send any admit/scheduled date past a certain point. We have a couple different date comparison functions but none looking at the true date. Most of them are date + 15 or etc. Does anyone have a good date function they have written to say if x > 20170102 ?

 

Thanks

Scott

Last answer 20 June 2017
0 2
0

comments

421

views

0

rating

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.

Now I've lost all their default data. That's ok, or so I though... since I supposedly should run %Populate on the Sample.Company to have all data back (their integrity regarding the lost ones isn't relevant). However I notice that even though I could populate data back to Sample.Company, Sample.Employee wasn't being populated

Last answer 13 June 2017
0 2
0

comments

159

views

0

rating

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

Last answer 9 June 2017 Last comment 12 June 2017
0 2
224

views

0

rating

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)

Last answer 8 June 2017 Last comment 8 June 2017
0 7
515

views

+ 4

rating

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

I dug for a bit, and came up with this:   If you set  a numeric string to “<number>.0” an write the variable, it will be set as a string:

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

W​
A = “1.0”
B= 2.2

Last answer 8 June 2017 Last comment 8 June 2017
0 6
220

views

0

rating

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.

Please report any issues on the GitHub issues log.

I will post some benchmarks later in the week.

Sean.

Last comment 8 June 2017
0 6
446

views

+ 5

rating

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;
}

To avoid creating almost identical objects for each of the methods of my REST service, I had thought to implement it with generic classes known in other languages like .NET or JAVA that allow to be able to define at run time the type of that parameter. In addition, that response must be able to be transformed into JSON. I imagine something like this (in pseudo code / COS / .NET):

Last answer 6 June 2017 Last comment 6 June 2017
0 5
260

views

0

rating

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 Intersystem'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.

Per the code below, every time I insert the new record my process fails.  I have also added break points and am able to view via the Global and via xDBC clients

Last answer 2 June 2017 Last comment 2 June 2017
0 0
334

views

0

rating

Hi!

I'm saving object instance using RestForms.

RESTFormsUI calls %Save() for me, which is great. But I want to set the property CreationDate with the current date for every new record being inserted.

So  object callback implementation seems as a reasonable option. I did the following:

Method %OnBeforeSave(insert as %Boolean) As %Status [ Private, ServerOnly = 1 ] 
{

 if insert s ..CreationDate=$H

 q $$$OK

}

And it works fine.

But Documentation says I'd better use %OnAddToSaveSet()

What are you using for the callbacks in similar cases?

Last answer 26 May 2017 Last comment 26 May 2017
0 7
258

views

0

rating

Greetings all.

I present you my project: Port.  

A (really) late-to-the-party VCS agnostic and project based source control for Studio.

 

I started this project several months ago when I noticed that most of the Studio's source control implementations weren't project based thus forcing the user to export/import all projects at once.

By taking a project based approach I noticed that quite some powerful advantages could be introduced, I'll just list them straight from the repo (that, by that way, is exported using Port):

Last comment 22 May 2017
0 0
177

views

+ 3

rating

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

Let's assume that you wrote a program that shows "Hello World!", for example:

  write "Hello, World!"

The program works and everyone is happy.

With time, however, your program becomes more complex, gets more features and you eventually need to show the same string in different languages. Moreover you don't know the number and names of these languages.

The spoiler below contains a description of how the task of multi-language localization is solved in Caché.

Last comment 20 May 2017
0 1
295

views

+ 7

rating

Looking for a way in which I could possibly pass a flag through a property when performing an Insert statement, on a mapped class.

insert into my.class (serialNumber, modelNumber, myFlag) value ('testSerial', 'testModel', 0)
    myFlag is not stored in the DB.

The mapped class then calls a legacy routine (MAC) via CodeMode = 'objectgenerator', (Insert method within the 'objectgenerator')

Within the legacy routine, I am setting an index... but I don't always want to set it (multiple inserts, and I will only set the index on the LAST insert)

How can I pass that flag through the insert call?  I attempted to make the property 'transient' and 'computed'.  But looking at the compiled code (INT), upon performing the Insert the value is nulled and the set, therefore wiping out whatever I passed in.

Is there anyway to do this?

Last answer 15 May 2017 Last comment 15 May 2017
0 3
122

views

0

rating

What is a correct way to pass parameters to the  %CONTAINS in embedded SQL statement when searching thru %Text property?

s sp="child,health"

&SQL(

DECLARE c1 CURSOR FOR

SELECT ID INTO :id FROM ICD WHERE Name %CONTAINS (:sp)

...

is not the same as executing the following in the SQL Manager

SELECT ID FROM ICD WHERE Name %CONTAINS ('child','health')

Last answer 9 May 2017 Last comment 10 May 2017
0 4
206

views

0

rating

Say you have a global in one database that you instead want to map from a different database. If you just create a global mapping to the new database, the existing global will become inaccessible because it still lives on the old database. The documentation notes this problem here but doesn't give details on how to fix it

Last comment 28 April 2017
0 7
484

views

+ 2

rating

On the back of my recent post on writing bug-less code I wanted to raise a few suggestions (to ISC) that would help prevent certain types of bugs at compile time. I've probably missed a few, but these are the main ones in my mind. Please contribute more suggestions.

Btw, these also serve as potential gotchas for new COS developers.

I except that introducing these types of changes can cause legacy code problems. Particularly where developers do some interesting overloading of method arguments. Therefore I would see these as an option that would need to be enabled and that it won't prevent compilation (it would warn not error).

As an alternative I could see these being implemented as a Lint tool. This is something I (and perhaps the community) would be willing to do if we had an open source AST tree as a starting block (if anyone is aware of one in existence for COS)

Last comment 18 April 2017
0 1
667

views

+ 4

rating

I have classes A and B, B derived from A, A has method Abc.

From INT of class B I see that compiler copies implementation of Abc to class B, so that Abc exists both in A and B.

As result, when B invokes Abs, B.Abs() is executed instead of A.Abs(). In result debuger is not able to step into Abs and breakpoints in A.Abs never hit.

Why this happens and how can I avoid this?

Update:

OK, now I know the reason: compiler makes the copy if Abc has this line:

cn=##Expression($$$quote(%classname))

hmmmm... compiler needs name of method's class so it "moves" the method to child class. Well, perhaps there is a good reason for that but for the moment the solution looks strange

Last answer 12 April 2017 Last comment 12 April 2017
0 4
193

views

0

rating

With help from others here I had developed some code to take a Base64 PDF within a OBX.5 and save it locally to the file structure on the server.

I had to make a change to the code to return me a String so I can pass the Path back into Ensemble to use it in the message. When I made this change I am getting " ERROR #5034: Invalid status code structure ("/ensemble/data/transfer/AncillaryPDF/TMSAUDIO/Apr-11-1/980512729TMSAUDIO1046784936436537800.pdf")"

Here is the code...

Last answer 12 April 2017
0 0
0

comments

305

views

0

rating

There is a large file that needs to be processed, with over 500 000 rows. Each row needs to be verified for various data and then all the results collated and reported into a single report.  What is the most efficient way to do this? I tried calling the processing function with Job , where each function jobbed off would report results to a different node of a common global. But the jobbed functions are not updating their respective rows even though I am passing the global name and root node. What is the most efficient way to process this large file? Any Cache/Ensemble ideas are appreciated.

Last answer 12 April 2017
0 2
0

comments

471

views

0

rating