Hi,
Is there any COS command could kill all the globals given the namespace?
Thanks.
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.
Hi,
Is there any COS command could kill all the globals given the namespace?
Thanks.
Hello,
I have some beginner questions as I am working through the InterSystems Cache learning path:
- Where I work, we us Cache, but we often learning about and train on MUMPS. No one really talks about or mentions MUMPS here, but my understanding is that ObjectScript is basically MUMPS plus whatever new things InterSystems put on top of it. Is that a fair assessment?
- The training online often refers to IRIS. We don't use IRIS, but we use globals to store data. I suppose I'm just confused on the difference between Cache, Zen, IRIS and other products as they all seem to do similar things.
Has anyone called any outside Javascript code from inside their class files? I asked a long time ago if there was a way to manipulate an image within Cache Object Script, and since Cache doesn't have any image libraries its not really possible. However I have found Javascript to resize an image and wonder how hard it would be to mesh the two together.
Can anyone share any examples?
Thanks
Scott
Hi -
I'm wondering if anyone has coded up a means to create an extension for a %Persistent class from a base class to a sub-class without making a ton of assumptions about the Global structure. I'm trying to create a new "extension" record that would have the same ID as the Base Class
Class BaseRecord Extends %Persistent
and
Class SubRecord Extends BaseRecord
where I would have an instance of a "BaseRecord" and I want to turn it into a "SubRecord" instance and have all of the existing references to the BaseRecord survive.
Hi Everyone!
As you know Advent of Code 2018 is in full swing! Till the 25th of December 2018 each day 2 programming problems to sharpen your programming skills!
And now we're ready to present great prizes for Members of InterSystems Global Masters Advocate Hub!

The following code walks a DOM using %XML.Node. It also prevents %XML.Writer to change whitespace. Run the code using the class method "test":
Class objectscript.walkDOM Extends %Persistent
{
ClassMethod dfs(node As %XML.Node)
{
s entrynode=node.NodeId
do {
//element nodes with one whitespacetyped child are the ones we want to change
if (node.NodeType=$$$xmlELEMENTNODE){
s snode=node.NodeId
if (node.MoveToFirstChild())
{
i ('node.MoveToNextSibling()){
i (node.NodeType=$$$xmlWHITESPACENODE){
s node.NodeType=$$$xmlTEXTNODE
s node.NodeId=snode
}
}
}
s node.NodeId=snode
}
if (node.HasChildNodes()){
d node.MoveToFirstChild()
d ..dfs(node)
}
} while (node.NodeType'="" && node.MoveToNextSibling())
s node.NodeId=entrynode
}
ClassMethod test()
{
set xml = "abcdefg <![CDATA[ ]]> "
s reader=##class(%XML.Reader).%New()
do reader.OpenString(xml)
set writer = ##class(%XML.Writer).%New()
//do some magic
d ..dfs(reader.Document)
w !,"with indent=1:",!
set writer.Indent = 1
do writer.OutputToString()
do writer.Document(reader.Document)
w writer.GetXMLString()
set writer.Indent = 0
w !,"with indent=0:",!
do writer.OutputToString()
do writer.Document(reader.Document)
w writer.GetXMLString()
}
}
Here's a link to the code on GitHub: https://github.com/intersystems-community/code-snippets/blob/master/src/cls/objectscript/walkDOM.cls
This article was written as an attempt to share the experience of installing the InterSystems Caché DBMS for production environment. We all know that the development configuration of a DBMS is very different from real-life conditions. As a rule, development is carried out in “hothouse conditions” with a bare minimum of security measures, but when we publish our project online, we must ensure its reliable and uninterrupted operation in a very aggressive environment.
Hello,
I'm looking to find if there is a datatype convert equivalent in Object Script to SQL convert function. Have a VarBinary string coming in from source application (which is really performing a SQL dump). The source application uses the standard SQL convert function to convert from varchar to varbinary on their side.
I know &sql(Convert()) should work in Object Script, but am wondering if there is a better way of doing this.
Getting data in via flat file (Record Map), then using data transform to transpose this data to SDA3.
Hi Community!
We try a new approach to the InterSystems Developers YouTube Videos called "Coding Talks"!
Coding Talks is a short video in which the developer demonstrates a particular feature or functionality of InterSystems Data Platforms which he/she uses to in coding. Typical format: the face on side and editor with ObjectScript.
Check this video I made by myself participating in Advent of Code 2018 and coding with InterSystems ObjectScript in VSCode.
Coding Advent of Code 2018 Using InterSystems ObjectScript
I have a persistent class that represents cities across the United States. It is below, but basically has a City Id, Name, Lat, Lon and a few other unimportant fields for this issue. Anytime I attempt to query on the Latitude or Longitude it immediately returns no results. My first thought was that it was a casting issue so I tried casting both sides to floats, ints, even strings and in all cases it immediately comes back with no results. I then decided to cast it to a string and attempt a like statement thinking it might be something about how floats are handled, but still no joy.
Are you ready for the next Advent of Code this year?
Just a few days left, the first puzzles will unlock on December 1st at midnight Eastern Time.

Not sure if I will manage to find time to solve those puzzles as quickly as last year, but hope some of you will do. We still have our leaderboard, you can join 130669-ab1f69bf. So, we will see who the best.
Here's a fun test to see how well you know ObjectScript.
What will each of the following statements output?
Did you know that Caché (and now InterSystems IRIS) has available parser for ObjectScript ?
Well, technically, lexer. It hides under the name of %SyntaxColor class. This class provides API to the DLL used by Studio to do syntax highlighting. As a result if works only under Windows.
Is anyone in the fine community of developers who work with ISC technologies looking at Microsoft's Visual Studio Code offering?
One of Bill McCormick's recent posts about Atelier referred to Visual Studio being considered the best IDE. Granted, Code is far less of a tool than VS, and probably always will be. But it claims to be open source and cross-platform, i.e. Linux and OS X as well as Windows.
I'm not 100% sure my post belongs in the Atelier group, but didn't see any other group that would be a better home. Might we benefit from a "Tools" group?
(Originally posted to InterSystems CODE by @Dmitry Maslennikov) The following code snippet outputs message header data in Ensemble. The class method "fetchExecute" runs the process, and the result is stored in the argument "qHandle":
include Ensemble
Class DAiMor.fetchMessageHeaderData extends %RegisteredObject
{
Query Fetch(Namespace As %String) As %Query(ROWSPEC = "Namespace:%String,ID:%Integer,Type:Ens.DataType.MessageType,Priority:Ens.DataType.MessagePriority,Invocation:Ens.DataType.MessageInvocation,TimeCreated:Ens.DataType.UTC,TimeProcessed:Ens.DataType.UTC,Status:Ens.DataType.
(Originally posted on Intersystems CODE by @Iain Bray) The following code snippet converts all indices in a package to bitmap indices. The subroutine "test" runs the code:
I have a XML enabled persistent class and a XML representation of some object of this class (object ID is available).
How can I use XML Reader (or some other mechanism) to automatically update this object?
Hi
Totally new to IRIS and Cache.
Trying to evaluate it and work out how we could use it.
As a standard application database. Object or relational etc. does not matter.
Issue is ObjectScript.
So:
1) Can we develop, maintain and use an IRIS database and never use ObjectScript i.e. use only Java, Python, C++ interfaces etc. (exactly which one does not matter)? Would that make designing and using the IRIS database more prone to inefficiency and error?
2) Can we import an existing Cache database into IRIS and convert its ObjectScript code into Java, Python whatever?
I need to write a script to answer a couple of fairly simple questions:
1) What is the current routine DB (name and location) for this namespace?
2) What is the current data DB (name and location) for this namespace?
3) Is global ^ABC mapped to a different location than the default data DB?
Can anyone point me to some system APIs that would allow me to answer these questions?
Thanks!
Ben
Hi Developers!
New video from Global Summit 2018 is available now on InterSystems Developers YouTube Channel:
Unit Test Coverage in InterSystems ObjectScript
I'm trying to interpret a ObjectScript pattern and I am stumped on the first part. I understand everything else but not sure what 1.A means. I know A stands for Alpha characters just not sure what the 1. means
Hi,
This must be a really easy question but for some reason I am unable to do this
I have a string name = "ERRORMSG"
I want to remove the first 2 characters in the string, so the result should be string newname = RORMSG
Please can you advice on how I can do this?
The following code provides information about software builds. Read the original description below for information about the different methods:
(Originally posted on Intersystems CODE by @Eduard Lebedyuk, 10/12/15) The following code snippet outputs all filenames in the file path "dir" in the Cache/IRIS terminal. The class method "test" runs the code:
Class eduardlebedyuk.filenamesInDir Extends %RegisteredObject
{
classmethod test() {
// replace dir with file path you want
set dir = "D:\directory"
set dir = ##class(%File).NormalizeDirectory(dir)
set file=$ZSEARCH(dir_"*")
while file'="" {
write !,file
set file=$ZSEARCH("")
}
}
}
This code snippet contains the class method "test" which sends an HTML email. Change the literal strings in the method to customize the email's from address, to address, subject, and body:
Class objectscript.sendEmail Extends %RegisteredObject
{
classmethod test() {
set m=##class(%Net.MailMessage).%New()
set m.From="user@company.com"
set m.IsHTML=1
do m.To.Insert("user@company.com")
set m.Subject="Sent by IRIS mail"
set m.Charset="iso-8859-1"
do m.TextData.Write("<HTML><HEAD><TITLE></TITLE>"_$char(13,10))
do m.TextData.Write("<META http-equiv=Content-Type content=""text/html; charset=iso-8859-2""></HEAD>"_$char(13,10))
do m.TextData.Write("<BODY><FONT face=Arial size=2>Test <B>Test</B></FONT></BODY></HTML>")
set s=##class(%Net.SMTP).%New()
set s.smtpserver="mail.company.com"
set status=s.Send(m)
}
}
Here's a link to the code on GitHub
Is it just set varName = 1 or is there an actual true/false value?
Hello all...
Is there two matching patterns in Caché, is there a difference in use one or the other?
Example:
USER>set a = "(1234)"
Using $match.
USER>w $match(a,"\([0-9]{4}\)")
USER>1
Using literal match (sorry if not correctly term expression)
USER>W a?1"("4n1")"
USER>1
What is different from using one or the other?
The 'a?1"("4n1")"' does this pattern exist only Caché.
Exists performance improvement with use pattern Caché?
This code snippet uses %ZEN.Auxiliary.jsonSQLProvider. The namespace and string of SQL can be edited for different situations. The class method "test" runs the code:
Class eduardlebedyuk.passQuestionParams
{
classmethod test(pValue = 50) {
s ns = $Namespace
zn "samples"
s tSQL = "SELECT ID, Name FROM Sample.Person WHERE Id > ?"
s tPR = ##class(%ZEN.Auxiliary.jsonSQLProvider).%New()
s tPR.sql = tSQL
s tPR.%Format = "tw"
s tPR.maxRows = 100
s tParam = ##class(%ZEN.Auxiliary.parameter).%New()
s tParam.value = pValue
d tPR.parameters.SetAt(tParam,1)
d tPR.%DrawJSON()
//d ##class(%ZEN.Auxiliary.jsonSQLProvider).%WriteJSONFromSQL(,,,,,tPR) //same thing
zn ns
}
}
(Originally posted to Intersystems CODE by @Eduard Lebedyuk, 5/13/15)
Here's a link to the code on GitHub
Hi All,
I need some help with sending PDF files to printer using cache instead of using third party tools(Adobe, foxit reader, etc..).
Sometime i getting access issue with the exe files.
Can able to send text data to printer using below code.
Set Dev="|PRN|PrinterName"
OPEN Dev:(/DATATYPE="TEXT"):80
USE Dev Write "Test printing",!
CLOSE Dev
Any suggestions on sending PDF to printer?
Hello,
I am a beginner with Object Script and I hope anyone can help me solving my questions.
1. Is there a way to time a loop in Object Script?
2. My code leads to the following error, even though it executes the method.
Is there a way to ignore this specific error, so that I can repeat my code in a time loop over and over again without stopping?