Main Page

Get e-mail announcements

NEMUG Newsletters

NEMUG Services

Become a NEMUG Member

Directions to NEMUG Meetings

NEMUG Corporate Sponsors

NEMUG Executive Board

NEMUG Newsletter

July 2005 Articles

Download the full newsletter in PDF format


Board Meetings

NEMUG Executive Board Meetings are open to anyone to attend. Your presence and views are welcome at any time. The meetings are held on the second Monday of even-numbered months, at the office of Henry Elliott in Wellesley. We try to get started at 6:00 pm. The next meeting is on:

  • 02 AUG 2005

If you are planning to attend, please let a board member know in advance, as we provide food and eat as we work, and need to be sure we have enough for everyone. The complete address for the meetings is:

Henry Elliott and Company Inc.
One Washington St. Suite 208
Wellesley, MA 02481

back to the top

Off the Rocker  

Life is good. All of us on the board won our elections. We have our new board including some new members and some continuing.

Congratulations and Thanks
We want to thank Ben Hurley who has served for three years. He is retiring from NEMUG board to spend time with his grandchildren. He has been a super data manager. He is a consistent collector of information, registrar, and reliable contact person. We really appreciated his commitment.

Thanks also to the continuing help from Joe Crisafulli and Bob Macauley who have worked on the newsletter for years.

Thanks to Marilyn Paterno, immediate past chair who worked particularly effectively on the NEMUG reunion April 9th.

Thanks to Ben Bishop who was not on the NEMUG M Celebration committee but who helped in many ways, especially as ex officio treasurer.

The NEMUG web site has moved. Anthony Pilozzi has taken on the transferal of the NEMUG web site to the Intersystems web server. Please take a moment to view the photo gallery and blog. Send us your comments.

back to the top

Tips and Tricks with Caché
Lori Fassman, May 10, 2005

Create a PDF file from Caché with Caché Activate

You can use Caché Activate (a/k/a the ActiveX Gateway) to add functionality to your own application without having to become an expert in that "other thing", e.g., add a spell checker or create PDF files. Demo was done using PDF Lib (see pdflib.com), but this can be done with any third-party PDF generator. Program was written using Caché Basic but would easily have been written in Caché ObjectScript. (I have sample code written both ways.)

This technology works just fine against regular globals and routines…you don't have to be building your applications with objects and sql to take advantage of this feature.

How to use CSP with globals (no objects or SQL)

First I created a ^test global:
for i=1:1:10 set ^test(i)="My number is "_i

Then built a CSP page which created an HTML table pulling data directly out of the global. Note the <script language="cache"> box below:

<table border="1">
<tr>
<th>ID</th><th>Text</th>
</tr>

<script language="cache" runat="server">
set x=""
for set x=$o(^test(x)) quit:x="" do
. write "<tr>",!
. write "<td>",x,"</td><td>",^test(x),"</td>",!
. write "</tr>",!
</script>

</table>

Escape sequences in CSP/HTML

This is more an HTML tip than anything specific to CSP, but it becomes important in CSP sometimes. The question is, how do you get some characters to show up on a web page when Caché and the browser think those characters have a special meaning, like angle brackets (which usually mean the beginning and end of an HTML tag)? You use HTML escape sequences. A quick web search will turn up many tables of all the ASCII characters and their equivalent escape sequences.

My demo looked like this:

I would like to include a GreaterThan sign and a LessThan sign in my text. Here goes.
<p>
Here's my GreaterThan sign: &lt; <br>
Here's my LessThan sign: &gt; <br>
While I'm at it, here's an ampersand: &amp; <br>

Put only essential data in %session
There are different ways to pass information from one page to another, or to hold onto it throughout an entire session. %request object helps you get data from one page to the next, and hidden HTML variables is one way to hold onto information without having to store it in the %session object. We do NOT recommend that you put every single piece of data (about a customer, car, whatever) into the %session object. Just store the ID for the object and open the object again on the next page.

<script language="cache" runat="server">

set pat=##class(NEMUG.Patient).%OpenId(1)
// don't do this:
//do %session.Set("patName",pat.Name)
//do %session.Set("patSSN",pat.SSN)
//do %session.Set("patDOB",pat.DOB)
// etc.
// but instead do this:

do %session.Set("patID",pat.%Id())

</script>

How to use $zobjproperty/method/etc.

This is similar to indirection, but can be used to find a generic way to get properties from a Caché object, or run methods.

Here are three functions, one accessing properties, one accessing "instance" methods (meaning you have to have an object in memory for this to run) and one accessing "class methods", which do not need anything in memory for them to work:

testProp(pat,prop)
write "Patient's ",prop," is: ",!
write $zobjproperty(pat,prop),!
quit 1

testMethod(pat,method)
write "The result of ",method," is: ",!
write $zobjmethod(pat,method),!
quit 1

testClassmethod(method)
write $zobjclassmethod("NEMUG.Patient",method),!
quit 1

Now, to call these functions:

set pat=##class(NEMUG.Patient).%OpenId(1)
write $$testProperty^NEMUG(pat,"Name")
write $$testMethod^NEMUG(pat,"GetAge")
write $$testClassmethod^NEMUG("Today")

Search for $zobjxxx in docs to find documentation on this.

Aviel pointed out that Execute works with objects too:

Set string="write ##class(NEMUG.Patient)."_method
x string

How to Optimize SQL Queries

- Always use TuneTable and ShowPlan to optimize SQL queries in Caché. These tools can be found in the Caché SQL Manager.

- populate Patient with 100 records (no index, no TuneTable)
- run query select Name from NEMUG.Patient where Name %startswith 'A'
- look at Show Plan
- Add an index on Name, run query and look at the query plan again. Much better.
- Run TuneTable and run again…better still!


back to the top

For more information about NEMUG, contact: Gardner Trask at gtrasknemug@gt3.com or call him at (978) 774–1338.

Last Updated: 12-July-05