New post

検索

Article
· May 9, 2023 2m read

Helper for Objectscript Language Extensions

Creating your own commands or shortcut is one of the strongest features of ObjectScript
If you create your own Language Extensions to ObjectScript 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 also programmatically.

  • eg. at first run, or during installation I found this quite useful for my Docker-based demos as it all happens at start time.

This package includes a demo example to visualize the operation of this utility.

How to Use it

 ; typ = "C" ... command extentson
 ;       "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

Open IRIS terminal or console

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>

Warning

It is meant mainly for COS experts !

GitHub

Video

Discussion (0)1
Log in or sign up to continue
Please note that this post is obsolete.
Announcement
· May 2, 2023

[Video] Healthcare Action Engine and CDS Hooks: Sneak Peek

Hi Community,

Watch this video to learn how the upcoming Healthcare Action Engine will combine event detection, complex logic, and a notification framework to improve synchronous and asynchronous notifications:

⏯ Healthcare Action Engine and CDS Hooks: Sneak Peek @ Global Summit 2022

🗣  Presenter: @Frank Pandolfe, Clinical Product Specialist, InterSystems

Subscribe to InterSystems Developers YouTube to stay up to date!

Discussion (0)2
Log in or sign up to continue
Article
· Apr 28, 2023 2m read

How to create a new idea on InterSystems Ideas

Hey Community!

Here is a short article on how to create an idea on InterSystems Ideas

0. Register on Ideas Portal if you aren't a member yet or log in. You can easily register using your InterSystems Developer Community ID.

1. Read carefully Portal Guide page on the Ideas Portal, especially "Idea promotion rules" section. All posted ideas are moderated following these rules.

2. Click on the "Add a new idea" button

and you will see the form to add the idea.

3. First, provide a one-sentence summary of the idea which is the required field. When you start typing, you will see a list of ideas with similar words in their names or tags. In case a similar idea is already created, vote or comment on this idea. The optimal size of an idea summary is 4-12 words.

4. Next, describe the idea in the "Please add more details" field.

In addition to text, you can attach screenshots or other files and insert tables and links. There is a full-screen mode that helps you see the whole description of your idea without scrolling.

5. Then you need to fill in the required field "Category". The correct category will help to assign your idea to the appropriate expert in the InterSystems team. 

In case you first sorted ideas by category and then pushed the button "Add a new idea", the idea's category will be added automatically.

6. Optionally, you can add tags to your idea, so other users can find it easily based on tags. The list of tags starts with tags having an "InterSystems" title, all other tags are sorted in alphabetical order.

7. Click on "Add idea" to submit.

    Hope this helps you share your ideas with others! If you have any questions, please send a direct message to @Vadim Aniskin.

    ---------------------

    * Please take into account that ideas and comments should be in English.
    * Ideas Portal admins can ask questions using Developer Community direct messages to clarify the idea and its category. Please answer these questions to make your idea visible to all users.
    * When you create an idea you automatically subscribe to e-mail notifications related to your idea, including:

    • changes in the status of your idea
    • comments on your idea posted by portal admins (you don't get notifications about comments from other users) 
    Discussion (0)1
    Log in or sign up to continue
    Article
    · Apr 27, 2023 2m read

    How to call Variable-length arguments Python methods from ObjectScript / sample routine calling ChatGPT

    Let's say you have Python including variable-length arguments methods. How can you call it from ObjectScript? 

    def test1(*args):
      return sum(args)
      
    def test2(**kwargs):
      a1 = kwargs.get("a1",None)
      a2 = kwargs.get("a2",None)
      return a1+a2

    You can call this "a.py" from ObjectScript as below.  For **kwargs argument, create Dynamic Object in ObjectScript and put it into methods with <variablename>... (3 dots) format. 

        set a=##class(%SYS.Python).Import("a")
        write a.test1(1,2,3)   ;; 6
        set req={}
        set req.a1=10
        set req.a2=20
        write a.test2(req...)   ;; 30


    Do you like playing ChatGPT? With this way, you can call ChatGPT APIs not only from Language=python method but from ObjectScript world.  As described in OpenAI page , ChatCompletion.create method of OpenAI library has **kwargs argument. So you can call this API with the following ObjectScript routine.

    Please see comments in each line, it's Python code. I hope it will help you when you need to replace Python codes to ObjectScript codes.

      set openai = ##class(%SYS.Python).Import("openai")   // import openai
      set openai.organization = "xxxx"                     // openai.organization = "xxxx"
      set openai."api_key" = "xxxxxxx"                     // openai.api_key = "xxxxxxx"
      set builtins = ##class(%SYS.Python).Builtins()
    
      //  req = (model="gpt-3.5-turbo", messages=[{"role": "user", "content": question ])
      // m1 = {"role": "user", "content": "Hi, How are you?"}
      set m1 = builtins.dict()                         // m1 = {}
      do m1.setdefault("role","user")                  // m1.update (role = 'user')
      do m1.setdefault("content","Hi, How are you?")   // m1.update (content = 'Hi, How are you?')
      // msg = [ m1 ]
      set msg =builtins.list()    // msg = []
      do msg.append( m1 )         // msg.append ( m1 )
      // req = { "model": "gpt-3.5-turbo", "messages" : msg }
      set req = {}                     // req = {}
      set req.model = "gpt-3.5-turbo"  // req.update (model = 'gpt-3.5-turbo')
      set req.messages = msg           // req.update (messages = msg)
      set response = openai.ChatCompletion.create(req...)             // response = openai.ChatCompletion.create(**req)
      write response.choices."__getitem__"(0)."message"."content",!   // print(response.choices[0]["message"]["content"].strip())
    

    [Sample]
    USER>do ^chatGPT
    I'm good, thank you for asking! As an AI language model, I don't have emotions, but I'm always here to help you with any inquiries or tasks. How can I assist you today?

    Happy ObjectScript coding!

    Discussion (0)0
    Log in or sign up to continue
    Question
    · Apr 27, 2023

    What type of inbound connection send an ACK back by default?

    I know that a TCP connection sends back an ACK, but what about REST, SOAP, HTTP, etc..?

    2 Comments
    Discussion (2)2
    Log in or sign up to continue