Article
· Mar 2, 2019 6m read
Belated - Advent of Code 2018 Day 1

I know it's late, but I really love the advent of code theme each year to find some project ideas to go out and code something and push myself.

I had the intentions of completing the AOC 2018 before the new year, but I've got 2 young kids (1yo and 4yo), so most nights I just want to sleep.

I've been looking at this on my half hourly commute each day before and after work.

So whilst doing this, I found not many people had posted what they had done and in previous years.

0 2
0 211

I'm getting this compilation error:

Kompilieren der Klasse digi.packet
FEHLER #5002: Caché-Fehler: <FUNCTION>zLockUse+5^%ExtentMgr.GlobalRegistry.1
> FEHLER #5030: Während der Kompilierung von Klasse 'digi.packet' ist ein Fehler aufgetreten

when importing one of my classes on the production server into one particular namespace:

0 8
0 649

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 528

I am new to Intersystems Cache, so please bear with me. We are using HealthShare 2013.1.

I have a routine to compare databases from separate instances where I want to ignore values that begin with %sqlcq. I thought this would be easy with pattern matching operator '?' but it is proving difficult and it seems to be because of the percent character.

For example:

0 4
0 422
Article
· Feb 8, 2019 2m read
Client Websockets based CSP

The Caché / Ensemble standard distribution contains in namespace SAMPLES
a nice example of a CSP page consuming WebService as a Client.
I have modified it not only to display the replies but to feed them back into a Global.
I used the classic Hyperevent to achieve this. The replies end up as a log in global^WSREPLY.
When there is no input anymore the page closes and goes away.

There are 2 versions with visible and hidden display during operation.
dc.WSCSP.reverseVerbose.cls and dc.WSCSP.reverseHidden.cls

11 0
0 475

Our development server is set up to automatically keep the .INT code of compiled classes and routines, but the live servers are set to not keep the .INT code.

I know how to set the system to keep this code ($SYSTEM.OBJ.SetQualifiers() ?) but what are the ramifications of keeping this code on the live servers? Is it just a space issue? I always thought it was to keep the code more private.

0 4
0 531

Today in docs I found this example using NULL:

 WRITE $LISTVALID($LB(NULL)),!

simplified

zzdump $LB(NULL)

and NULL can be case-insensitive:

zzdump $LB(null)

seems the same as just:

zzdump $LB()

But if null variable is defined then list would contain value from variable. Case sensitive in that situation.

Does anyone have any Idea what is this? Is NULL used anywhere besides as a list element?

0 5
0 330

Recently I needed a classmethod that returns annotation value based on a name of a activity.

As doing it at runtime seemed inefficient, I wrote compile-time utility that iterates over all business process activities and generates relevant code.

This code could be used in a variety of situations when you need to iterate over business process activities, just add it as a secondary superclass to your BPL processes.

1 2
1 383

Let Say I have
Class Carrier Extends %Persistent

Property Employee As Array of Class Employees

Class Employees Extends %SerialObject

Property Name As %String

Property Address As Array of Class AddressDetail

Class AddressDetail Extends %SerialObject

Property Street1 As %String

Property Street2 As %String


I can get value for Employee Name as Employee_Name.

But I want to Get Value of Address Street1 and Street2 of Class AddressDetail using SQL Query
How can I get that?

0 3
0 365

I need to automate the handling of usernames passwords, serverNames etc for use in the sending and receiving of emails, logging into SFTP servers etc etc for use within COS code
To manage external passwords we could use LastPass or any other proprietary password loggers, but I need to be able to call them as part of the automation (COS code) and occasionally visually look them up to "remind" the staff of their passwords.

any suggestions as to the best class data constructs to handle this scenario. Should the whole table be encrypted, only the passwords etc.

0 9
0 471

This code snippet sends an XML request to a server and saves the response to a file. The class method "test" runs the code:


Class objectscript.postXML
{
    classmethod test() {
        Set HTTPRequest = ##class(%Net.HttpRequest).%New()
        Set HTTPRequest.ContentType = "text/xml"
        Set HTTPRequest.NoDefaultContentCharset = 1
        Set HTTPRequest.Location = "ITOMCZ"
        Set HTTPRequest.Server = "wph.foactive.com"
        Do HTTPRequest.RemoveHeader("User-Agent")  
        Do HTTPRequest.RemoveHeader("Accept-Encoding") 
        Do HTTPRequest.RemoveHeader("Connection")
        Do HTTPRequest.SetHeader("Expect","100-continue")
     
        Set RequestXML = ##class(%Library.File).%New("c:\test.xml")
        Do RequestXML.Open("RS")
        Do HTTPRequest.EntityBody.CopyFrom(RequestXML)
        Do RequestXML.%Close()
     
        Do HTTPRequest.Post(HTTPRequest.Location)
     
        Do $System.OBJ.Dump(HTTPRequest)
        Do $System.OBJ.Dump(HTTPRequest.HttpResponse)
     
        Write HTTPRequest.HttpResponse.Data.Size
        Write HTTPRequest.ContentLength
     
        Set ResponseStream = ##class(%Stream.FileBinary).%New()
        // Second part is typically the file extension, i.e.: application/pdf -> pdf
        Set FileType = $Piece(HTTPRequest.HttpResponse.GetHeader("CONTENT-TYPE"),"/",2)
        Set ResponseStream.Filename = "C:\test."_FileType
     
        Write ResponseStream.CopyFrom(HTTPRequest.HttpResponse.Data)
     
        Write ResponseStream.%Save()
        Do ResponseStream.%Close()
    }
}

Here's a link to the code on GitHub

1 0
0 805
Question
· Jan 3, 2019
n00b questions

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?

0 16
0 655

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

2 9
1 1.4K

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.

0 7
0 405
Article
· Dec 27, 2018 2m read
Use %XML.Node to walk a DOM

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"
     
      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/...

1 0
0 316

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.

7 2
5 1.6K

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.

0 4
0 686

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

https://www.youtube.com/embed/GyFJ67jqXCU
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

3 0
1 362