Article
Robert Cemper · Apr 1, 2021 2m read

Helper for ObjectScript Language Extensions

If you create your own Language Extensions to Object you mostly have to find the
proper %ZLANGC00 or %ZLANGV00 or %ZLANGF00 and add the extensions manually.
A few utilities do it already automatically (ZPM, ZME, ..)
This utility allows you to add your extensions programmatically. (eg. at first run, or during installation)
I found this quite useful for my Docker-based demos as it all happens at the start time.

It is related to these articles


I have also added a small demo example to visualize the operation of this utility.

Prerequisites

Make sure you have git and Docker desktop installed.

Installation

Clone/git pull the repo into any local directory

$ git clone https://github.com/rcemper/helper-for-objectscript-language-extensions.git

Open the terminal in this directory and run:

$ docker-compose build

Run the IRIS container with your project:   

$ docker-compose up -d

Hot to Use it

  ; typ = "C" ... command extension
  ;       "F" ... function extension
  ;       "V" ... variable Extensin
  ; ext = name of the extension
  ; code (by ref) numbered array of lines to add
  ; 
  ; do cmd^zLangExtender(typ,ext,.code) ;>> add extension 

How to Test it

$ docker-compose exec iris iris session iris
USER>ZN "%SYS"
%SYS>do ^zLangExample

Compiling routine : %ZLANGF00.mac

label="ZZDUMMY"
line=6
line(1)=" ; "
line(2)=" ; just a demo dummy"
line(3)="ZZDUMMY(%a) "
line(4)=" quit " I got '"_%a_"' for test""
line(5)=" ; what a nice demo "
line(6)=" ; "
sc=1
typ="F"
**** try ****
sc=" I got 'hi folks' for test"

result:
         ;Generated by %ZPM.PackageManager: Start
ZPM(pArgs...) Quit ##class(%ZPM.PackageManager).Shell(pArgs...)
         ;Generated by %ZPM.PackageManager: End
         ;
         ; just a demo dummy
ZZDUMMY(%a)
         quit " I got '"_%a_"' for test"
         ; what a nice demo
         ;
%SYS>

And if you run it a second time?
It returns a standard error %Status.

%SYS>do ^zLangExample
%objlasterror="0 ...ZZDUMMY^%ZLANGF00 already defined.........
label="ZZDUMMY"
line=6
line(1)=" ; "
line(2)=" ; just a demo dummy"
line(3)="ZZDUMMY(%a) "
line(4)=" quit " I got '"_%a_"' for test""
line(5)=" ; what a nice demo "
line(6)=" ; "
sc=""0 ...ZZDUMMY^%ZLANGF00 already defined.........
typ="F"
ERROR #5001: ZZDUMMY^%ZLANGF00 already defined
%SYS>

see Video here

30
1 0 0 72
Log in or sign up to continue