I need to convert "dd/MMM/yy" to "YYYYmmdd".
Input = dd/MMM/yy
Output = YYYYmmdd
example
Input = 13/Jun/23
Output = 20230613
I used below , I get 1923 as year but I need 2023.
$ZDATE($ZDATEH("13/Jun/23",8),8) = 19230613
InterSystems ObjectScript is a scripting language to operate with data using any data model of InterSystems Data Platform (Objects, Relational, Key-Value, Document, Globals) and to develop business logic for serverside applications on InterSystems Data Platform.
I need to convert "dd/MMM/yy" to "YYYYmmdd".
Input = dd/MMM/yy
Output = YYYYmmdd
example
Input = 13/Jun/23
Output = 20230613
I used below , I get 1923 as year but I need 2023.
$ZDATE($ZDATEH("13/Jun/23",8),8) = 19230613
Hi folks!
Just curious, how can I use $znspace in embedded python code?
How does other $functions work, e.g. $zv, $job, etc
Hi folks!
Consider I need to call a python function which name contains "_" symbol (which is quite often in Python). How it could be called from ObjectScript?
E.g. here is the code:
Set sm = ##class(%SYS.Python).Import("sample")
write sm.helloworld() ; function without _
white sm.hello_world() ; function with _ - won't compile.Thanks in advance!
Sorry, somewhat of novice here, but how is a mac or a routine created into a binary or is there a way to hide your routines so that no other user can edit them? Like remove source code and have an executable?
I would like to do this MAC and CSP pages
How Job command can be used with Embedded Python code?
Excuse if this is obvious to Python programmers but for those crossing over from ObjectScript this may be a useful tip.
The scenario is developing some Embedded python commands.
Testing out functionality is being confirmed via the shell:
$SYSTEM.Python.Shell() Python 3.9.5 (default, Mar 14 2023, 06:58:44) [MSC v.1927 64 bit (AMD64)] on win32 Type quit() or Ctrl-D to exit this shell. >>>
When Python evaluates an expression in the shell, it prints the result of the expression to the terminal.
>>> 1 + 2 3
It is quite easy to accidentally evaluate and print out values
>>> iris.cls("%Dictionary.MI am working with a REST API JSON Response that contains a list of integers (departmentids).
JSON Response:
{
"status":"ACTIVE",
"departmentids":[
72
],
"subscriptions":[
{
"eventname":"LabResultAdd"
},
{
"eventname":"LabResultUpdate"
},
{
"eventname":"LabResultClose"
}
]
}
I am having trouble getting that to parse into my custom message structure using the %JSONImport method.
do pResponse.%JSONImport(tHttpResponse.Data.Read())
Here is my custom message class (pResponse):
Class AH.AHLIB.Custom.Athena.Message.GetEventsSubscribedResponse Extends (Ens.Response, %JSON.Adaptor)
{
PrHello!
I would like to find all classes not up to date in a namespace programmatically.
With IRIS Studio, we can see the single "+", but I don't know how to do that with a script.
Set sql = "SELECT ID, Name FROM %Dictionary.ClassDefinition WHERE NOT ID %STARTSWITH ?"Set params($Increment(params)) = "%"Set tResult = ##class(%SQL.Statement).%ExecDirect(, sql, params...)
If (tResult.%SQLCODE'=0)&&(tResult.%SQLCODE'=100) Set sc = $$$ERROR($$$SQLError, tResult.%SQLCODE, tResult.%Message) Quit sc
While tResult.%Next() {
// if class not up to date ??
}I am writing a custom business class. I need to use the business service name that will be using the class within a SQL statement. How can I get the business service name that is using the class?
Good morning,
I was wondering:
Given the following scenario where we have a string where each two items are being splitted by "|" as follows: "squadName|initialLetter"
"Alfa|A|Bravo|B|Charlie|C|Delta|D|Echo|E|Foxtrot|F|Golf|G|Hotel|H|India|I|Juliett|J|Kilo|K|Lima|L|Mike|M|November|N|Oscar|O|Papa|P|Quebec|Q|Romeo|R|Sierra|S|Tango|T|Uniform|U|Victor|V|Whiskey|W|X-ray|X|Yankee|Y|Zulu|Z"
And we would need to generate a String structure like:
[
{
"number": "number 1",
"squad": "Alfa",
"answer": [
{
"initialLetter": "A"
}Hi folks!
Those who actively use unittests with ObjectScript know that they are methods of instance but not classmethods.
Sometimes this is not very convenient. What I do now if I face that some test method fails I COPY(!) this method somewhere else as classmethod and run/debug it.
Is there a handy way to call the particular unittest method in terminal? And what is more important, a handy way to debug the test method?
Why do we have unittest methods as instance methods?
Using the Config.Configuration class and SYS.Database class methods, you can create and register a namespace database from the terminal.
Below is a series of execution examples that create database file /CacheDB/AAA/cache.dat and register database AAA and namespace AAA in the configuration file (cache.cpf).
* Execute in the %SYS namespace. *
* Make sure that this script runs as the user that is used for all IRIS processes to ensure that the directory has appropriate ownership and permissions *
I have the following method call (have included html and css as well). when I debug the code in a browser, JavaScript seems to work fine. Loading image is coming up, table is getting hidden. But when I close the debug and just load the page and run it, loading image is not coming up, neither the table is hidden. Not sure what is going on? I need help to understand what I am doing wrong?
XData Style
{
<style type="text/css">
#loading {width: 100%;height: 100%;top: 0px;left: 0px;position: fixed;display: block; z-index: 99}
#loading-image {position: absolute;top: 40%;left: 45%;z-index: 100}
</style>
}
X
We are looking at what we need to do to migrate from our current usage of Zen reports to InterSystems Reports. One of the hurdles for us is figuring out ways to interact with InterSystems reports programmatically from ObjectScript routines. There is a Java API for it, but it is possible to generate a report from InterSystems reports to a stream object in ObjectScript without diving into Java by using a %Net.HttpRequest. Here is a code example, followed by an explanation:
#include %cspIncludeGetStream(catalog="",report="",type="2",paramnames,paramvalues,str) public{
try{
set namI am trying to call to a website that renders a xml structure as a response.if I put the url on the browser an xml rendered page is returned but if i call to this using the below code I get an object reference error which I am finding had to understand is there anyone who could help understand this error or point me in the right direction thanks.
Set tSC=$$$OK
Set httpRequest = ##class(%Net.HttpRequest).%New()Set httpRequest.Server = "msedgewebdriverstorage.blob.core.windows.net"
Set httpRequest.Port=443
Set httpRequest.ContentType ="application/octet-stream"
;;"application/xml"
Set
Hi,
I'm trying out VS Code with IRIS for Health 2023.2 (not available in above dropdown) in a local container. I can open read-only files in the Objectscript viewer and have a local folder connected to the correct namespace. However, when I make changes and try the "import and compile" option, I get:
ERROR #16006: Document <filepath> name is invalid
The first four chars of <filepath> appear to have been truncated
Here is my settings.json
{
"security.workspace.trust.untrustedFiles": "open",
"workbench.colorTheme": "InterSystems Default Dark",
"intersystems.servers": {
"l
Hi,
just want to know if indexes in IRIS / SQL are autobuilding.
I define an index in a table and then i costantly do a lot of insert/delete in that table. Will i face index problem? Do i need to rebuild it often?
Thanks
Methods written in ObjectScript can use pass-by-reference arguments to return information to the caller. Python doesn’t support pass-by-reference arguments, so Embedded Python in IRIS doesn’t support them either. That's it, that's the end of the post, hope you liked it. 😉 But wait, what about the Classic Rock & Roll?
Actually, since returning values in method arguments can be useful, this post demonstrates several ways to do this, between ObjectScript and Embedded Python. So let’s start with the simplest example: calling an ObjectScript method that already has a pass-by-reference argument from
Example:
Method Execute (args...) As %Status {
...
#dim statement as %SQL.Statement
set statement = ##class(%SQL.Statement).%New(2)
set statement.%Dialect = "CACHE"
do statement.prepare(query)
#dim rs as %SQL.StatementResult
set rs = statement.execute(args...)
My questions are: 1) how do I get the size of **args **2) how to get all values of **args **3) is it possible to modify the args?
I would like guidance on the most effective approach for converting UTC time, such as "2023-11-24T14:00:00.000Z," to the format "202311241400," while taking into account the 1-hour time difference during UK summer time. Any suggestions or advice would be greatly appreciated.
Trying to gather basic code examples written in ObjectScript and realized it's probably easiest to ask the people who know what they're doing!
I'm looking for examples of the following five prompts all in ObjectScript:
Prompt 1. Write a function that partitions the array into two subarrays: one with all even integers, and the other with all odd integers. Return your result in the following format:
[[evens], [odds]]Prompt 2. Create a function that computes the hamming distance between two strings
Prompt 3. Make a function that encrypts a given input with these steps:
Input: "apple"
Step 1: Reverse
I have a situation where I have a handful of classes which I need to copy to another Namespace (which uses a different RoutineDB) on the same instance, load it and compile it.
Can anyone help me come up with a command that will do this quickly and easily? Perhaps something with extended reference?
This is somewhat time sensitive so thank you in advance for your ideas!
Hi folks!
Just want to introduce you a new util to import CSV into IRIS - csvgenpy!
Install
USER>zpm "install csvgenpy"
Use:
do ##class(shvarov.csvgenpy.csv).Generate("file or url","table","schema")Example:
USER>do ##class(shvarov.csvgenpy.csv).Generate("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv","titanic","data")This will create table and class data.titanic in IRIS and will load the data. you can proof it with:
1.
Has anyone had success with passing in a collections property within a SOAP request to a Soap Service in Ensemble? Please reply with how you set up that collections property. I am able to successfully send a SOAP request correctly containing the elements of the collection property to Cache, as seen in a custom soap log file which I am using to troubleshoot. But the collection property in the Ensemble request is not getting serialized, meaning MyContainers has nothing.
My.Request consists of a property, MyContainers, which can have 0 or more Containers (My.Container)
When MyContainers is of
A question for anyone using InterSystems technology:
What are the biggest challenges you’ve faced either trying to hire developers that know ObjectScript, or trying to train developers on ObjectScript?
As you know ObjectScript has neither FOREACH system command nor system function.
But it has a wide room for creativity.
The task is to loop over a global or local array and do something FOR EACH element.
There are 2 possible solutions:
##; ZFOREACHMACRO ; macro definitions
##; %key = variable provide to loop trough array
##; %arr = the gobal or local array to be loopedWe are currently using different iterations of Ens.Director.EnableConfig items to start/stop objects within the Interoperability Namespace. We are looking for ways to minimize our downtime as we move from AIX to a new section of our Network and Red Hat Servers.
Besides using Ens.Director.EnableConfig item and waiting for a response, or just disabling the objects through the Namespace class file, is there a quicker way to stop Services and Operations to ensure the TCP disconnect is sent to those endpoints so we can move the networking rules to ensure they point to new servers?
I'm trying to write an ObjectScript function that sorts version numbers to help learn ObjectScript. This is all I can think of after staring at VS Code for a while, but I don't know where to go with it. Can someone please help out with a tip? The goal is to take something like ["1.4.5", "0.5.3", "6.3.2", "1.2.4"] and turn it into ["0.5.3", "1.2.4", "1.4.5", "6.3.2"]
ClassMethod SortVersion(input As %String[]) As %String[] {
Set sorted = []
for i=1:1:input.%Size() {
Set version = input.Get(i)
Set major = $NUMBER($PIECE(version, ".", 1))
Set minor =Is there any ObjectScript or a basic function that takes a string and separates it into words + punctuation/spaces array/list? Just not to reinvent the wheel. Say, process "It is a test, after all" into "It", space, "is", space, "a", space, "test", ", ", "after", space, "all". Or something to that effect.
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.
This package includes a demo example to visualize the operation of this utility.
;