#Tips & Tricks

12 Followers · 334 Posts

Pieces of experience in InterSystems Technology which solve some particular problem in elegant or unusual way.

Article John Murray · Feb 14, 2017 1m read

User interfaces such as Portal often give us multiple ways of doing a task. Sometimes we stick with habits and don't realize that another way might save us time.

Here's one that I learned by watching someone else using Portal.

Use the Search box to get quickly to a page that may otherwise be several layers deep in the Portal hierarchy. For example, suppose I want to check the status of the ECP networking:

Clicking on a match doesn't take me direct to the page (or am I missing a trick here?). Instead it gives me this:

And now a click takes me to the page I want.

3
0 384
Article Timur Safin · Feb 2, 2017 19m read
This is the second part of my long post about package managers in operating systems and language distributions. Now, hopefully, we have managed to convince you that convenient package manager and rich 3rd party code repository is one key factor in establishing of a vibrant and fast growing ecosystem. (Another possible reason for ecosystem success is the consistent language design, but it will be topic for another day.)

In this second part we plan to discuss the practical aspects of creating a package manager in general and their projection to the Caché database environment.

23
1 1511
Article Steve Wilson · Feb 3, 2017 3m read

Points to remember before you start:

  1. It is not possible in a COS (Caché Object Script) job/process context to have multiple Named Pipes. It is a one Named Pipe per job/process limited line of communication.
  1. Named Pipes, in Caché, like most pipes on most operating systems are Unidirectional. That means you open them for either Read or Write, but not both.
0
0 892
Article Fabian Haupt · Dec 22, 2016 8m read

I was benchmarking the populate utils when I noticed something strange. Consider this simple benchmarking method:

ClassMethod runBench(count As %Integer = 300000)
{
		s types=["name","ssn","company","title","phone","city","street","zip","mission","state","color","product","string","integer","float"]
		//s types=["name","ssn"]
		s iter=types.%GetIterator()
		while iter.%GetNext(.key,.value){
			s start=$P($ZTS,",",2)
			s opt={}
			s opt.type=value
			for i=1:1:count{
				s res=##class(DataGen.Generator).genVal(opt)			}
			s end=$P($ZTS,",",2)
			s total=end-start
		    w value_$C(9)_" total time:"_total_$C(9)_" rate:  "_$NORMALIZE(count/total,2)_" per second",!
		}
}
0
1 540
Article Can (Jon) Gencler · Nov 8, 2016 5m read
Importance and Collection of Exact Version Information ($zv / $zversion)
The explanation of:
- why collecting $zv is important (The WHY),
- what the components of $zv mean (The WHAT),
- and how to collect $zv (The HOW).
(The Ultimate $zv Guide to the ISC Galaxy in large, friendly letters)
4
1 1748
Article Murray Oldfield · Nov 12, 2016 6m read

Index

This is a list of all the posts in the Data Platforms’ capacity planning and performance series in order. Also a general list of my other posts. I will update as new posts in the series are added.


You will notice that I wrote some posts before IRIS was released and refer to Caché. I will revisit the posts over time, but in the meantime, Generally, the advice for configuration is the same for Caché and IRIS. Some command names may have changed; the most obvious example is that anywhere you see the ^pButtons command, you can replace it with ^SystemPerformance.

0
7 6666
Article Mario Sanchez Macias · Nov 10, 2016 1m read

I tried to make atelier look more like XCODE with this simple trick or tip: change the default font to SF Mono and size 14.

To do it I did:

1) Install SF Mono font in the system which is the default font for XCODE and needs to be installed in order to use it.

You can find it in: /Applications/Utilities/Terminal.app/Contents/Resources/Fonts

Double Click SFMono-Regular.otf file and install it. You will get a warning of "serious problems" but it will work all right.

2) Then, in Atelier, go to Preferences / General / Appearance / Color and Fonts The choose Text Font (In Basics category) and Edit.

0
0 536
Article Stuart Salzer · Nov 8, 2016 38m read

What is a core file? and When are they use­ful?

The in­for­ma­tion in this doc­u­ment is cur­rent as ver­sions of InterSystems prod­ucts re­leased through 2024-06-06. This up­date date cov­ers er­rors in that dis­covered up to 2024-08-12, but not changes present in new ver­sions of InterSystems prod­ucts.

Nevertheless, the de­tails for ex­ist­ing prod­ucts are not sub­ject to fre­quent change.

The WRC can supply you with a .PDF ver­sion of this article suitable for printing on either US 8½″ × 11″ or A4 210 mm × 297 mm paper.

1
2 34884
Article Cindy Olsen · Nov 8, 2016 7m read

In this post I would like to talk about the syslog table.  I will cover what it is, how you look at it, what the entries really are, and why it may be important to you.  The syslog table can contain important diagnostic information.  If your system is having any problems, it is important to understand how to look at this table and what information is contained there.

1
2 2976
Article Andrew Krammen · Nov 4, 2016 4m read

This is a follow-up to Murray's article for scripting pButtons data extraction on Unix/MacOS:     Extracting pButtons data to CSV for UNIX/MacOS

###Extracting pButtons data to a CSV file on Windows

PowerShell scripting was used in this article because it is available by default on Windows platforms.

The script, Extract_pButtons.ps1, will search the given pButtons file until it finds the marker for the beginning of the section. The section will be printed line-by-line, from the header to the line before the section end marker.

0
0 947
Article Stephen Walasavage · Nov 1, 2016 2m read

This post is meant to provide a quick possible explanation for a very perplexing problem.

Scenario:  You’ve just created your own administrative user in your 2014.1 (or later) instance of Caché.  You gave it every possible security role (including %All), so it should in theory be able to do anything within the instance.

You’ve written a very advanced routine with a break command in it for debugging:

MyTestRoutine
            set ^MyInitGlobal = 1
            write "Hello, my name is.

1
0 593
Article Kyle Baxter · Aug 29, 2016 6m read

This post is the direct result of working with an InterSystems customer who came to me with the following problem:

SELECT COUNT(*) FROM MyCustomTable

Takes 0.005 seconds, total 2300 rows.  However:

SELECT * FROM MyCustomTable

Took minutes.  The reason for this is subtle and interesting enough for me to write a post about.  This post is lengthy, but if you scroll to the bottom I'll write a quick summary, so if you've gotten this far and think you've already read enough, scroll to the end to get the main point.  Check for the sentence in bold.


11
0 1472
Article Alexey Maslov · Sep 30, 2016 2m read

After reading Stephen Wilson's article "Windows 7 performs shutdown too fast for Cache to close and so it gets forced down" I've recalled another solution that was based on Local Group Policy, which allows to control extra actions that should occur on computer startup or shutdown. How to add a computer shutdown script is well documented in MS Technet article. In short:

  • being logged on as a domain admin, run Local Group Policy Editor (gpedit.
1
0 1135
Article Steve Pisani · Oct 27, 2016 1m read

Hi - If you want to embed Ensemble's Workflow Inbox, (that offers workflow task items to workflow users) inside of your application - you can access the URL directly without necessarily giving users access to the Management Portal - but more importantly, you can strip away the Titlebar, Worklists and Borders that make up the page by default.

You do this by using the same URL parameters you would use, if embedding a regular DeepSee dashboard into your application.

For example, adding &EMBED=1 at the end of the URL as depicted below:

0
1 475
Article Jose Ruperez · Oct 12, 2016 1m read

With a routine like this one, you can quickly calculate how many lines of code you are working with. And it is not only for routines, it works for classes because remember that classes generate routines !

Here you have the routine source code:

LinesOfCode ;
    new SQLCODE,tRoutine
    set tTotalLOC = 0
    &sql(DECLARE ROUTINES CURSOR FOR
     SELECT NAME 
FROM %Library.RoutineIndex 
WHERE TYPE = 'MAC'
ORDER BY NAME)
    &sql(OPEN ROUTINES)
    &sql(FETCH ROUTINES INTO :tRoutine)
    while (SQLCODE=0)
    {
        write !,$j($i(tCount),5),": ",tRoutine
        set tLOC = $get(^rMAC(tRoutine,0,0))
        write "("_tLOC_")"
        set tTotalLOC = tTotalLOC + tLOC
        &sql(FETCH ROUTINES INTO :tRoutine)
    }
    &sql(CLOSE ROUTINES)
    write !!,"Total lines of code = "_tTotalLOC
4
0 929
Article John Hotalen · Oct 4, 2016 1m read

How to parse a URL in Caché:

Let's pretend you are working on a project where you may be retrieving a URL for some purpose and you have the need to be easily able to parse apart that URL to get the various components that make up the URL.

Here's how to do that:

Note:  This example assumes you have a variable named sURL that contains some url (i.e. http://www.intersys.com/main.csp?QUERY=abc#anchor) and you will be creating an array of the URL component pieces, where the array will be named aComponents.

In your class/routine, add the following code:

Do ##class(%Net.URLParser).Parse(sURL,.

8
0 2040
Article Ben Spead · Aug 25, 2016 4m read

Background

Caché 2016.1 introduced some very powerful JSON features.  Unfortunately, the syntax used in the 2016.1 release is going to be changed in the 2016.2 release to bring it closer to Caché ObjectScript syntax.  This will mean that code that works in 2016.1 may not be forwards compatible.   See this announcement and this article for more details about the changes.

11
0 2173
Article Sylvain Guilbaud · Oct 4, 2016 6m read

This sample class will add parameter DSINTERVAL to each class containing the parameter DSTIME

To execute it from a Terminal :


SAMPLES>d ##class(adm.param).add(,,1)
[SAMPLES] parameter DSINTERVAL=5 added to class DeepSee.Study.CityRainfall (via adm.param)
[SAMPLES] parameter DSINTERVAL=5 added to class HoleFoods.Transaction (via adm.param)
[SAMPLES] parameter DSINTERVAL=5 added to class News.DeepSee.NewsArticle (via adm.param)
DSINTERVAL parameter was added to 3 classes

Class adm.param [ Abstract ]
{

/// this class will add DSINTERVAL parameter to each class containing DSTIME
/// in order to synchronize a cube that is based on a source table on a mirror system
/// see: http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=D2IMP_ch_current#D2IMP_current_dstime_enabling
ClassMethod add(name As %String = "DSINTERVAL", value As %String = "5", verbose As %Boolean = 0) As %Status
{
    set sc = $$$OK
    try {
        set statement = ##class(%SQL.Statement).%New()
        // %Dictionary classes are useful to select classes based on their content
        // here we use %Dictionary.ParameterDefinition class which contains all the parameters defined in all classes
        // then we will open the parent class to add the missing parameter
        set query="SELECT a.parent "
                 _"FROM %Dictionary.ParameterDefinition a "
                 _"WHERE a.name='DSTIME' "
                 _"AND substr(a.parent,1,1)<>'%' "
                 _"AND NOT EXISTS (SELECT null "
                 _"FROM %Dictionary.ParameterDefinition b "
                 _"WHERE b.name='"_name_"' and b.parent=a.parent)"
        set sc = statement.%Prepare(query)
        quit:$$$ISERR(sc)
        set classes="",nb=0
        set rs = statement.%Execute()
        while (rs.%Next(.sc)) {
            quit:$$$ISERR(sc)
            if (rs.parent '="") {
                // opening of the parent class 
                set class = ##class(%Dictionary.ClassDefinition).%OpenId(rs.parent)
                if $IsObject(class) {
                    // creating the new parameter
                    set param=##class(%Dictionary.ParameterDefinition).%New()
                    set param.Name=name
                    set param.Default=value
                    // adding the parameter to the parent class
                    do class.Parameters.Insert(param)
                    set sc=class.%Save()
                    // if parent class is successfully saved set the following message
                    set:sc msg="["_$namespace_"] parameter "_name_"="_value_" added to class "_rs.parent_" (via "_..%ClassName(1)_")",severity=0
                    // if parent class is not saved set the following message
                    set:'sc msg="["_$namespace_"] ERROR while saving "_rs.parent_" after having added the parameter "_name_"="_value_" (via "_..%ClassName(1)_") :"_$system.Status.GetErrorText(sc),severity=1
                    // if verbose=1 write the message to the terminal
                    write:verbose msg,!
                    // write the message to cconsole.log
                    do ##class(%SYS.System).WriteToConsoleLog(msg,verbose,severity)
                    // add the class name to compile 
                    set classes(rs.parent)="",nb=$increment(nb)
                }
            }
        }
        set:nb=0 msg=name_" parameter was not added to any class"
        set:nb=1 msg=name_" parameter was added to "_nb_" class"
        set:nb>1 msg=name_" parameter was added to "_nb_" classes"
        write:verbose msg,!
        // compile all modified classes 
        if nb>0 { 
            set sc=$system.OBJ.Compile(.classes,"ck"_$select(verbose:"d",1:"-d"))
            set:sc msg="["_$namespace_"] modified "_$select(nb=1:"class",1:"classes")_" successfully compiled",severity=0
            set:'sc msg="["_$namespace_"] ERROR while compiling classes : "_$system.Status.GetErrorText(sc),severity=1
            do ##class(%SYS.System).WriteToConsoleLog(msg,verbose,severity)
            write:verbose msg,!
        }    
    }
    catch(ex) {
        set sc = ex.AsStatus()
        set msg="["_$namespace_"] error while executing "_..%ClassName(1)_":add("_name_","_value_") : "_ex.DisplayString(),severity=1
        write:verbose msg,!
        do ##class(%SYS.System).WriteToConsoleLog(msg,1,severity)
    }
    return sc
}

}
6
1 1178
Article Evgeny Shvarov · Aug 31, 2016 1m read

Hi!

Sometimes you see that call to DeepSee cube building method:

w ##class(%DeepSee.Utils).%BuildCube("CubeName")

does nothing.

Here are my 2 cents on possible reasons.

1. Run DeepSee Reset method in certain Namespace:

NAMESPACE> w ##class(%DeepSee.Utils).%Reset()

and try again.

2. Make sure, that all the indices in your base class for the cube are rebuilt, rebuild them and run it again:

w ##class(%DeepSee.Utils).%BuildCube("CubeName")

Hope this will save some time for you, and will be helpful as was to me.

2
0 475
Article John Hotalen · Sep 29, 2016 1m read

Checking if Directory or File Exists:

Outlined below is an example of how to check if a directory exists:

Set directoryName="c:\temp\nosuchdir"

/* Check for existence of a directory - Return Value:  0 - directory does not exist;  1 - directory does exist  */

Set directoryExists=##class(%File).DirectoryExists(directoryName)

If ('directoryExists)  // do the processing for when a directory does not exist


Outlined below is an example of how to check if a file exists:

Set fileName="a_test_filename.txt"

/* Check for existence of a file- Return Value:  0 - filename does not exist;  1 - filename does exist  */

Set fileExists=##class(%File).Exists(fileName)

If ('fileExists)  // do the processing for when a filename does not exist
1
0 3396
Article Eduard Lebedyuk · Sep 26, 2016 2m read

We're developing Ensemble PoC and one day our frontend developer (who doesn't have Ensemble production running) said that Populate just doesn't cut it and he needs to see the real data. He needed only one object, but the problem was - it's a big object. Still, I checked ids of everything related and wrote this command (parts omitted, but you get the idea):

w
$SYSTEM.OBJ.Export("project.model.contract.ContractD(6456).gbl,project.model.coA7F9.ObjectAddressD(6741).gbl,project.model.meter.DeviceD(23398).gbl,project.model.StatusHistoryD(7977).gbl,project.model.StatusHistoryD(48006).gbl,project.model.StatusHistoryD(83906).gbl","C:\Users\eduard\Desktop\export.xml")
1
0 821
Article Bob Binstock · Sep 9, 2016 2m read

as described in How to post an article from Word or Google Docs, you can use the Paste from Word button to paste content you have copied from a Word or Google Docs document into a Developer Community post.

this worked well for me pasting from Word 10 documents, and retained most (though not all) of my Word formatting. i did have one problem, however, and wanted to pass on my workaround.

if there are external links in the Word document, they sometimes don’t work when pasted in until you manually add http:// or https://, which can get stripped (don't know if this applies to Google Docs).

0
0 412
Article Daniel Kutac · Sep 8, 2016 2m read

This short article was motivated by a problem of one of my customers. They use Ensemble to integrate many systems, some of them use just plain files.

So they naturally selected File Outbound Adapter to write into target file. Things were running smoothly for years, until recently, when the volume of data being written to the file reached large size of tens of megabytes. The operation took around half an hour to complete, causing timing problems where subsequent operations within the process had to wait, and third party system was not happy to wait so long.

2
0 890
Article Bob Binstock · Sep 7, 2016 6m read

Mirror Outage Procedures

Caché mirroring is a reliable, inexpensive and easy to implement high availability and disaster recovery solution for Caché and Ensemble-based applications. This article provides an overview of recommended procedures for dealing with a variety of planned and unplanned mirror outage scenarios. (For detailed information about mirroring and a wide range of mirror-related procedures, see Mirroring 101.)

A Caché mirror typically consists of two Caché instances on physically independent hosts, called failover members

0
1 1248
Article John Murray · Sep 2, 2016 1m read

I was recently troubleshooting a problem on a Linux (RHEL) instance of 2016.1 at a site. For policy reasons their sysadmins wanted to update the Caché installation so it used network accounts for its cacheusr and iscagent users and groups instead of the locally-created ones that had been set up during original install of Caché.

To do this they ran various commands including chown

Afterwards non-root users couldn't obtain a terminal session using the csession command.

2
0 762