Article
· Sep 13, 2018 1m read
Find a table given its name

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

2 6
0 700
Article
· Sep 6, 2018 1m read
Save a file using %Net.HttpRequest

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

3 0
1 911

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.

What this article is about

  • Generation of an AST for a GraphQL request and its validation
  • Generation of documentation
  • Generation of a response in the JSON format
6 2
2 1K

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

1 3
2 1.7K

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.

17 24
10 2.4K

Caché Localization Manager

CLM is a tool for localization/internationalization/adding multi-language support to a project based on InterSystems Caché.

Imagine that you have a ready project where all the content is in Russian, and you need to add an English localization to it. You wrap all your strings into resources, translate them into English and call the necessary resource for Russian or English when necessary. Nothing tricky, if you think about it. But what if there are lots of strings and there are mistakes in Russian (or English)? What if you need to localize in more than one language – say, ten? This is exactly the kind of project where you should use CLM. It will help you localize the entire content of your project into the necessary language and retain the possibility to correct entries.

6 4
0 915