In my routine when I call set filestream.FileName = filename, I get an error

"cn_iptcp://localhost:56773/USER/%Stream.FileBinary.1.INT" does not exist on the Server

I successfully instantiate the %Stream.FileCharacter object. 'filestream' value is '1@%Stream.FileCharacter'. But when I debug the code, the step where I try to set the file name fails.

The port number for local host looks good for my current instance. I have tried a few variations, such as using the method FileNameSet(). But this did not work either.

0 10
0 519

Now I want to return a large amount of data to the front end. The string length has reached 40000 +, and the returned data needs to be encrypted by AES + Base64. I can convert the string into a stream. AES can use the AESCBCEncryptStream method to encrypt, but Base64 has no stream method。Anyone who get the solution would you kindly share the solution please。

Any help would be appreciated. Thanks!

1 10
0 13K

What are the differences between a process private global and a percent variable? Basically I have some code running in an Ensemble operation that processes requests, and it needs access to pieces of data that are scattered throughout XData blocks in various classes. Rather than opening the XData object and deserializing the XML on each request, I opted to cache this data in a percent variable, something like:

set %MyVar(sub1,sub2) = myValue

0 10
0 1.6K

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

0 10
0 1.8K
Question
· Nov 28, 2019
StreamContainer.

Hello,

I make some changes in our ObjectScript code between our prod environment and dev environment in the process 'Hl7AdtFileIsoslBp'.

The operation is a class with "EnsLib.TCP.TextLineOutboundAdapter".

In prod:

0 10
0 444

Hello Developer Community!

I’m pleased to announce the 0.9 release of the ObjectScript extension for Visual Studio Code. Earlier this year I announced that InterSystems would be joining the community in evolving this already popular tool. Since then, we have been hard at work solidifying the code base and building a slew of new features.

11 10
2 758
Article
· Mar 17, 2021 3m read
Making the most of $Query

I ran into an interesting ObjectScript use case today with a general solution that I wanted to share.

Use case:

I have a JSON array (specifically, in my case, an array of issues from Jira) that I want to aggregate over a few fields - say, category, priority, and issue type. I then want to flatten the aggregates into a simple list with the total for each of the groups. Of course, for the aggregation, it makes sense to use a local array in the form:

agg(category, priority, type) = total

Such that for each record in the input array I can just:

14 10
4 884

Hi Community,

Can anyone point me to the docs that show how to add automatic class documentation for the arguments used in a method call? I can auto document the class, methods, properties etc. with the "///" but can't figure out how to get the nice argument documentation for the arguments used when calling a method.

Thanks in advance

0 10
0 131

At the moment I am trying to write a documentation file for a project and intend to use LaTeX for it.
Has anyone already had experience with this? I haven't found syntax highlighting with the LaTeX packages I know yet.
I found a request on Pygment but it was from 2016 and there was no reply on it since then.

Does anyone know a simple way for syntax highlighting COS in LaTeX?
Thanks for your input!

Martin

0 10
0 446

Hi all,

I am trying to use some process private variables (percent variables) in Triggers.

I am referring to values from $System.Process, like the ClientIPAddress and CSPSessionID.
These do to not contain values and I suspect it is bacause of scope. I also checked, and the %session variable is not available if the change originated from a CSP request.
I know that in triggers the scope of the variables are to be kept local, that is why NEW is to be used.

0 10
0 242
Question
· Sep 12, 2023
Scoping OID / OREF map

It's a feature of ObjectScript (perhaps widely known, perhaps not) that if you open the same object ID multiple times, you end up with the same OREF. For example:

USER>set obj1 = ##class(Sample.Person).%OpenId(1)
 
USER>set obj2 = ##class(Sample.Person).%OpenId(1)

USER>w obj1,!,obj2
1@Sample.Person
1@Sample.Person

Generally speaking, this is an important feature - you won't end up accidentally modifying the same record via multiple paths and losing some of the changes.

2 10
2 298

Some weeks ago, I was reading a book by Stephen Hawking and Leonard Mlodinow, The Grand Design. At a certain point, trying to define why do we exist? , why do we use the models we use in physics?, ...those kind of things you know... they pointed at the Game of Life example invented by the mathematician John Coward in 1970... Basically he wanted to show that a system with really basic fundamental laws (Physics) could evolve and "live" to become a more complex system (Chemistry) in which "something" (humans) could work out its own model and complex rules to explain its reality… the rules for this deterministic model that he exposed were so basic that I thought it could be funny to implement them in ObjectScript when I had some spare time... there are others implementations in JavaScript and other languages... but not in ObjectScript... and that had to be corrected!!… so here you are!

7 10
2 772

Using VECTOR_COSINE() in SQL query to perform a text similarity search on existing embeddings in a %VECTOR column.

Code is below.

Commented out sql query returns this error: SQLCODE: -29 Field 'NEW_EMBEDDING_STR' not found in the applicable tables^ SELECT TOP ? maxID , activity , outcome FROMMain .AITest ORDER BY VECTOR_COSINE ( new_embedding_str ,

Sql query as written returns ERROR #5002: ObjectScript error: <PYTHON EXCEPTION> *<class 'OSError'>: isc_stdout_write: PyArg_ParseTuple failed!

0 10
0 83
Article
· Sep 10, 2020 3m read
How To Create "Write-Only" Code

One of the leading benefits of ObjectScript is the speed and efficiency it allows for an experienced developer. Let's look at an example of how you can benefit from ObjectScript today.

Suppose you have a class that stores the names of your users. We'll call the class Data.User, and give it a string property Name. Next, we will need a method to create a new user or update an existing one. A naive, simplistic approach might look like this example:

6 10
0 604

I've created a scheduled task that dumps HL7 messages to flat files. It uses the OutputToLibraryStream() method of EnsLib.HL7.Message. I'd like to be able to run it on a mirror member host whether it's primary or backup.

When run against a database that's mounted read-only, it works fine. However, when I attempt to run it against a mirror backup database, I get the following error:

#5002: Cache error: <PROTECT>%LoadData+7^EnsLib.HL7.Message.1

Tracing that back to the source, I find:

0 9
0 363

Work Queue Manager (WQM) is a feature of InterSystems IRIS that enables you to improve performance by distributing work to multiple concurrent processes programmatically. The idea is that you split the work into chunks, and WQM distributes the chunks across worker processes and can provide the info that the work is done.

However, recently, I got an interesting question: there's a large logical transaction composed of ~1,000,000 individual objects and SQL inserts and updates. Some updates are CPU-intensive, so the original idea was to use WQM to split an update into chunks to speed things up.

But, here's a catch: if one of the individual 1,000,000 changes fails (there's a variety of application-level checks so that it can fail, and that's not even that abnormal a behavior), the entire transaction must be rolled back. That creates a problem: each chunk must report success before committing their individual transactions, and someone must get all these reports and decide if we are committing or not.

Unfortunately, it looks like WQM does not have a bidirectional communication between workers and manager, so I suggested an approach using events:

  1. Start jobs.
  2. Wait for all jobs to report success using $System.Event.WaitMsg().
  3. Send Commit or Rollback using the $System.Event.Signal().
2 9
1 158
Question
· Dec 9, 2020
Code migration using VSCode

I am fairly new to using VSCode. I have used VSCode to create some files on our Test Server, now I need to move them to Production.

Looking through the VSCode extension documentation, maybe I missed it but how to I migrate code from one workspace to another. In Studio I was use to exporting the code into an XML and just being able to import it on the Production server version of Studio.

Thanks

Scott

0 9
0 609

The goal is to construct a comma separated string, using a loop but the same way $listtostring(var,",") would do (i.e. "a,b,c,d,e,f,g,h" without starting or ending comma).

What is the best way to do it, concerning the readability of the code and its performances?

To do so, there are more than 5 methods, but in this example we will test 4 :

1) using a "if" in the loop

3 9
0 418