Hi community,
I am now working with an ftp adapter. I have no problem connecting to the FTP server, but there are problems with interacting with files. Has anyone had any experience with an FTP adapter, such as getting/modifying/deleting files?
Hi community,
I am now working with an ftp adapter. I have no problem connecting to the FTP server, but there are problems with interacting with files. Has anyone had any experience with an FTP adapter, such as getting/modifying/deleting files?
Now the Classes/Rutines/DeepSee files will be automatically exported to the working directory after saving or compiling and files will be automatically deleted .
To install isc-dev , you just need to download and import the file isc-dev.xml from last release.
Some ways to import isc-dev .xml file:
NS>do $system.OBJ.Load("yourpath/isc-dev.xml","ck")
NS>zpm
zpm: NS>install isc-dev
NS>do ##class(dev.code).workdir("/path/to/your/working/directory/src/")
dev.FileManExtension class as the main one and save it.Here is an ObjectScript snippet which lets to create database, namespace and a web application for InterSystems IRIS:
set currentNS = $namespace
zn "%SYS"
write "Create DB ...",!
set dbName="testDB"
set dbProperties("Directory") = "/InterSystems/IRIS/mgr/testDB"
set status=##Class(Config.Databases).Create(dbName,.dbProperties)
write:'status $system.Status.DisplayError(status)
write "DB """_dbName_""" was created!",!!
write "Create namespace ...",!
set nsName="testNS"
//DB for globals
set nsProperties("Globals") = dbName
//DB for routines
set nsProperties("Routines") = dbName
set status=##Class(Config.Namespaces).Create(nsName,.nsProperties)
write:'status $system.Status.DisplayError(status)
write "Namespace """_nsName_""" was created!",!!
write "Create web application ...",!
set webName = "/csp/testApplication"
set webProperties("NameSpace") = nsName
set webProperties("Enabled") = $$$YES
set webProperties("IsNameSpaceDefault") = $$$YES
set webProperties("CSPZENEnabled") = $$$YES
set webProperties("DeepSeeEnabled") = $$$YES
set webProperties("AutheEnabled") = $$$AutheCache
set status = ##class(Security.Applications).Create(webName, .webProperties)
write:'status $system.Status.DisplayError(status)
write "Web application """webName""" was created!",!
zn currentNS
As I understand it. The local or global indexes can contain a maximum of 500 characters. How can I go around this limitation?
This code snippet is an example of a CSP page that has a dynamically reloading table:
(Originally posted by @Sascha Kisser on March 11, 2014) The following 2 classes are a component for a webcam, and a ZEN page that incorporates it. The webcam can take a snapshot and save it to Caché:
The class method "test" in the following code snippet sends an HTML email with an embedded image. Edit the literal strings to change the embedded image, to address, from address, subject, and body of the email.
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
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
(Originally posted by @Ben Spead on June 25, 2014)
This code snippet generates a list of Ensemble Lookup Tables and Schema documents in the user's current namespace. Run the code by running the class method "test":
Class benspead.EnsTablesSchema
{
classmethod test() {
If ##class(%Dictionary.CompiledClass).%ExistsId("Ens.Util.LookupTableDocument") {
// only supported in Ensemble 2012.1+
Write !,!,"Exporting Ensemble Lookup Tables..."
Set sc = $$$OK
Set rs = ##class(%ResultSet).%New("Ens.Util.LookupTableDocument:List")
Do rs.Execute()
While rs.Next() {
Set item=rs.Data("name")
Write "document found: "_ item,!
}
Do rs.Close()
Set rs=""
}
If ##class(%Dictionary.CompiledClass).%ExistsId("EnsLib.HL7.SchemaDocument") {
Write !,!,"Exporting Ensemble HL7 Schemas..."
Set sc = $$$OK
Set rs = ##class(%ResultSet).%New("EnsLib.HL7.SchemaDocument:List")
Do rs.Execute()
While rs.Next() {
Set item=rs.Data("name")
Continue:$listfind($lb("2.1.HL7","2.2.HL7","2.3.HL7","2.4.HL7","2.5.HL7","2.6.HL7","2.7.HL7","2.3.1.HL7","2.5.1.HL7","2.7.1.HL7","ITK.HL7")
,item)
Write "document found: "_ item,!
}
Do rs.Close()
Set rs=""
}
}
}
Here's a link to the code on GitHub: https://github.com/intersystems-community/code-snippets/blob/master/src/cls/benspead/EnsTablesSchema.cls
The following class contains 1 class method "test" that creates a Zen Application and Page:
The data model of your solution based on InterSystems platforms constantly changes over time. But what do you do with the data that was entered before? Back then, the data was valid, but what’s happening to it now after a number of data model changes? The answer to this question can be provided by the IDP DV tool that checks the property data of persistent and serial classes according to the types of these properties. In case any discrepancies are found, the tool generates a detailed error report for the user.
(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":
(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:
The following code provides information about software builds. Read the original description below for information about the different methods:
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
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
This code snippet provides a ZEN page that downloads a stream from its database directly:
/// We assume that you have stored your data within this schema:
/// MyApp.Model.Storage: Filename,FileSize,Content,ContentType
Class zen.downloadStream Extends (%ZEN.Component.page,%CSP.StreamServer)
{
/// Wrapper to get the id of the download, we assume that the id is passed to this zen page
/// as a URI parameter, i.e.: MyApp.Downloads.cls?OID=1234
ClassMethod GetId()
{
Quit $Get(%request.Data("OID",1))
}
/// Set the appropriate header for the file.
ClassMethod OnPreHTTP() As %Boolean
{
Set tId = ..GetId()
If ##Class(MyApp.Model.Storage).%ExistsId(tId) {
Set tStream = ##Class(MyApp.Model.Storage).%OpenId(tId)
// You could "guess" the content type by its file extension
// or you can store it (before) in the database separately (like in this example).
// Set Extension = $Piece(tStream.Filename,".",$Length(tStream.Filename,"."))
// Set ContentType = ..FileClassify(Extension)
Set %response.ContentType = tStream.ContentType
Do %response.SetHeader("content-disposition","attachment; filename="_tStream.Filename)
Do %response.SetHeader("Content-Length",tStream.FileSize)
}
Else {
Set %response.Status="404 File Not Found"
Quit 0
}
Quit $$$OK
}
ClassMethod OnPage() As %Status
{
Set Download = ##Class(MyApp.Model.Storage).%OpenId(..GetId())
Do Download.Content.OutputToDevice()
Quit $$$OK
}
}
Link to code on GitHub
The following class method "test" contains code that can create a new class, create new properties for classes, or create new methods for classes. "test" runs all three of these processes once, and the code that performs each action is labelled by comments in the method:
ClassMethod test() As %Status
{
set sc = $$$OK
// Create a class
set class = ##class(%ClassDefinition).%New("MyClass")
set class.Description = "This is my test class"_$c(13,10)_"testing %ClassDefinition"
set class.Super = "%Persistent"
// Create a property and add it
set property = ##class(%PropertyDefinition).%New("MyClass.MyProperty")
set property.Type = "%String"
set property.Description="This is a property"
set sc1 = class.Properties.Insert(property)
do:$$$ISERR(sc1) $system.Status.DisplayError(sc1)
set sc = $$$ADDSC(sc, sc1)
// Create a method and add it
set method = ##class(%MethodDefinition).%New("MyClass.MyMethod")
set method.ReturnType = "%Integer"
set method.FormalSpec = "x:%Integer,y:%Integer=10"
set method.Description = "Return product of x and y"
set method.CodeMode = "code"
set method.Code = " new result"_$c(13,10)_" set result=x*y"_$c(13,10)_" quit result"
set sc2 = class.Methods.Insert(method)
do:$$$ISERR(sc2) $system.Status.DisplayError(sc2)
set sc = $$$ADDSC(sc, sc2)
// Save the class definition
set sc3 = class.%Save()
do:$$$ISERR(sc3) $system.Status.DisplayError(sc3)
set sc = $$$ADDSC(sc, sc3)
return sc
}
Here's a link to the code on GitHub
This code snippet determines the day of the week associated with a date. The class method "test" takes a date as a string in "mm/dd/yyyy" format, and returns an integer corresponding to a day of the week:
Class cartertiernan.getDayfromDate Extends %RegisteredObject
{
classmethod test(date) as %Integer {
//Set date = $ZDATE(date) // Looks like: mm/dd/yyyy
Set monthList = $LISTBUILD(0,3,3,6,1,4,6,2,5,0,3,5) // (Jan,Feb,Mar,Apr,...)
Set centuryList = $LISTBUILD(6,4,2,0) // first two digits divisiable by 4, then subsequent centuries. EX (2000, 2100, 2200, 2300)
Set dayList = $LISTBUILD("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") // Index goes from 0-6
Set day = $PIECE(date,"/",2) // get the day
Set monthVal = $LIST(monthList,($PIECE( date,"/",1 ))) // get the month value
Set first2DigsYear = $PIECE( date,"/",3 ) \ 100 // get the last 2 digits of the year
Set last2DigsYear = $PIECE( date,"/",3 ) # 100 // get the first 2 digits of the year
// Used for DEBUG perpouses
/*write !,"day: ",day
write !,"Month: ",monthVal
write !,"last2: ",last2DigsYear
write !,"first2: ",first2DigsYear
write !,"cen Val: ",$LIST(centuryList,(first2DigsYear # 4) + 1),!!*/
// Look here for formula explination (its the "Basic method for mental calculation")
// http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
Set dayOfWeekVal = ( day + monthVal + last2DigsYear + (last2DigsYear\4) + $LIST(centuryList,(first2DigsYear # 4) + 1 ) ) # 7
Quit dayOfWeekVal
}
}
Here's a link to the code on GitHub
(originally posted to CODE by Carter Tiernan, 6/18/14)
The following code snippet includes a class method "test" that runs code to find a class based on the class's name. "test" takes one argument, which is the name of the table:
Class objectscript.findTable Extends %RegisteredObject
{
classmethod test(name as %String="mytable")
{
#Dim result as %ResultSet
#Dim tName as %String
#Dim contain as %Integer
Set contain=0
Set result = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
Do result.Execute()
While(result.Next())
{
Set tName=$get(result.Data("Name"))
&sql(select position (:name in :tName) into :contain)
Write:contain'=0 tName, " ... ", name, " (", contain,")", !
}
Return $$$OK
}
}
Here's a link to the code on GitHub
This code snippet allows for a file on the web to be saved into the file system. Specify the server and GET request, as well as the directory the file should be saved to. The class method "test" runs the code:
Class objectscript.saveFileHTTP Extends %RegisteredObject
{
classmethod test() {
Set httprequest = ##class(%Net.HttpRequest).%New()
Set httprequest.Server = "docs.intersystems.com"
Do httprequest.Get("documentation/cache/20172/pdfs/GJSON.pdf")
Do $System.OBJ.Dump(httprequest.HttpResponse)
Set stream=##class(%FileBinaryStream).%New()
Set stream.Filename="c:\test.pdf"
Write stream.CopyFrom(httprequest.HttpResponse.Data)
Write stream.%Save()
}
}
Here's a link to the code on GitHub

I already talked about GraphQL and the ways of using it in this article. Now I am going to tell you about the tasks I was facing and the results that I managed to achieve in the process of implementing GraphQL for InterSystems platforms.
This code snippet changes all passwords in a system to a specified string. The two literal strings at the beginning of the snippet can be adjusted to edit the system or password string. The class method "test" runs the code:
Class eduardlebedyuk.changePasswords Extends %RegisteredObject
{
ClassMethod test()
{
set ns = $namespace
zn "%SYS"
set NewPass = "NewPassString"
set rs=##Class(%ResultSet).%New("Security.Users:List")
set st = rs.Execute()
while rs.Next() { set st=$SYSTEM.Security.ChangePassword(rs.Get("Name"),NewPass)}
zn ns
}
}
Hello,
Currently, I'm working with a Java Gateway, and I have the following problem. When importing a class into IRIS, which uses methods from a generic class, I can not find the general methods I need. I'm talking about the test2 method from the class test. How can I import the java method that returns a generic?
(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("")
}
}
}
(Originally posted by Timur Safin on Intersystems CODE, 3/2/15) This code snippet is a routine that parses options saved in an arguments array. The subroutine "test" runs the code:

GraphQL is a standard for declaring data structures and methods of data access that serves as a middleware layer between the client and the server. If you’ve never heard about GraphQL, here is a couple of useful online resources: here, here and here.
In this article, I will tell you how you can use GraphQL in your projects based on InterSystems technologies.
How do I append a string to the beginning of a %FileCharacterStream in an existing file?
How can I do second dimension for the dimension, where we have comma delimited expression?