Article
· Sep 27, 2018 2m read
Method to Create a Class

The following class method "test" contains code that can create a new class, create new properties for classes, or create new methods for classes. "test" runs all three of these processes once, and the code that performs each action is labelled by comments in the method:


ClassMethod test() As %Status
{
    set sc = $$$OK
    
    // Create a class
    set class = ##class(%ClassDefinition).%New("MyClass")
    set class.Description = "This is my test class"_$c(13,10)_"testing %ClassDefinition"
    set class.Super = "%Persistent"

    // Create a property and add it
    set property = ##class(%PropertyDefinition).%New("MyClass.MyProperty")
    set property.Type = "%String"
    set property.Description="This is a property"
    set sc1 = class.Properties.Insert(property)
    do:$$$ISERR(sc1) $system.Status.DisplayError(sc1)
    set sc = $$$ADDSC(sc, sc1)
    
    // Create a method and add it
    set method = ##class(%MethodDefinition).%New("MyClass.MyMethod")
    set method.ReturnType = "%Integer"
    set method.FormalSpec = "x:%Integer,y:%Integer=10"
    set method.Description = "Return product of x and y"
    set method.CodeMode = "code"
    set method.Code = " new result"_$c(13,10)_" set result=x*y"_$c(13,10)_" quit result"
    set sc2 = class.Methods.Insert(method)
    do:$$$ISERR(sc2) $system.Status.DisplayError(sc2)
    set sc = $$$ADDSC(sc, sc2)
    
    // Save the class definition
    set sc3 = class.%Save()
    do:$$$ISERR(sc3) $system.Status.DisplayError(sc3)
    set sc = $$$ADDSC(sc, sc3)
    
    return sc
}

Here's a link to the code on GitHub

1 1
0 566

Hi Community,

It's time for the new videos from Global Summit 2019 on InterSystems Developers YouTube Channel! Are you ready?

Please welcome the first session recording from InterSystems Developers:

The State of the InterSystems Developer Community

https://www.youtube.com/embed/sTSzhETokWQ
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 260

Hi Developers,

New video, recorded by @Stefan Wittmann, is already on InterSystems Developers YouTube:

🗣 Multi-Inheritance in a Multi-Model Environment

https://www.youtube.com/embed/xjB1sik8a_E
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 214

Hi Developers,

Please welcome a new video on InterSystems Developers YouTube Channel:

Machine Learning 201: Deep Learning

https://www.youtube.com/embed/y2hMiFBC-p0
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 2
0 350

Hi Community!

We're pleased to invite you to the upcoming "Speed Test: ESG Labs Database Performance Test" webinar on August 5 at 9:30 AM EDT!

Join our live webinar with Mike Leone, senior analyst with Enterprise Strategy Group’s Validation Services, to learn about a speed test that measures and compares the concurrent real-time data ingest and query performance of InterSystems IRIS® data platform, a leading in-memory database, a cloud relational database, and a traditional relational database.

1 1
0 440
Announcement
· Aug 14, 2020
New Video: REST at Ease

Hi Developers,

The new video from Global Summit 2019 is available on InterSystems Developers YouTube:

REST at Ease

https://www.youtube.com/embed/Iuf-MlcrG-E
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 433

Doing a new project with %JSON.Adaptor, unexpectedly realized that %JSON.Adaptor does not support export to native JSON. %JSONExport just outputs directly to the current device, and there are two more methods %JSONExportToString, and %JSONExportToStream.

In conjunction with generating REST from swagger specification, where any generated method accepts as a result %DynamicObject, which is good.

I have multiple places in my REST where I have to return JSON for an object, but I have to modify the result a bit, just extend it with some other way.

1 7
2 767

Hi Developers!

Here're the technology bonuses for the InterSystems Multi-Model Contest that will give you extra points in the voting:

  • InterSystems IRIS BI
  • InterSystems IRIS NLP
  • IntegratedML
  • Real data usage
  • InterSystems Reports
  • ZPM Package deployment
  • Docker container usage

See the details below.

1 4
0 227

So I've got the IRIS AMI spun up in AWS EC2; it seems to be running fine.

I've added an EBS volume to it for persistent storage, and now I'm pondering how to make it actually do something useful.

What's the best way to do deploy code to this instance? I can think of a few ways to do it, but what's the least painful way? Push my code to an S3 bucket and figure out how to load it at system start? Github project?

1 2
0 194

Monitoring IRIS through SAM (sam:1.0.0.115)

While I've used to make it work in the past, I'm not able any more to fix the already faced issue : "State: Unreachable"

Despite all the ip-addresses attempts (or hostname = host.docker.internal) and while "/api/monitor/metrics" is running well...

Could someone provide good practices to make it work cleanly ?

1 13
0 381

This is the third in a series of releases that are part of the developer preview program for 2022.2 Future preview releases are expected to be updated biweekly and we will add features as they are ready. Many updates, fixes and enhancements have been added in 2022.2, in SQL management, cloud integration, Kafka and JMS adapters, the SQL Loader, and other areas. Please share your fe

1 1
0 190

Hi Community,

Let's meet together at the online meetup with the winners of the InterSystems Interoperability Contest – a great opportunity to have a discussion with the InterSystems Experts team as well as our contestants.

Winners' demo included!

Date & Time: Thursday, September 22, 09:00 AM EDT

>> Register here <<

1 3
1 192

This is the fourth in a series of releases that are part of the developer preview program for 2022.2 Future preview releases are expected to be updated biweekly and we will add features as they are ready. Many updates, fixes and enhancements have been added in 2022.2, in SQL management, cloud integration, Kafka and JMS adapters, the SQL Loader, and other areas.

1 0
0 273

Hey Community,

Enjoy watching the new video on InterSystems Developers YouTube:

Let InterSystems IRIS Do the Work: Git Source Control & Linting ObjectScript Across Editors @ Global Summit 2022

https://www.youtube.com/embed/Fh0uyC9owyE
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 1
1 351

I'm trying to read the response to a long (indefinitely) running HTTP response with Transfer-Encoding: chunked. Ideally I'd be able to read the individual chunks from the response and do something with them as they arrive rather than needing to wait for the response to finish (because it never will) - ultimately I'm thinking to wrap these back up over a WebSocket connection which seems cleaner from an API perspective.

So far it looks like my options are:

1 3
0 688

Hi Community,

Watch this video to learn how InterSystems software enables both horizontal and vertical scaling:

Scaling for User and Data Volume in InterSystems IRIS

https://www.youtube.com/embed/A477wcJL2LA
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 155

Hey Community,

Enjoy watching the new video on InterSystems Developers YouTube:

Best Practices for InterSystems IRIS System Performance in the Cloud @ Global Summit 2023

https://www.youtube.com/embed/2nUzXjymRXs
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 142

Hey Community,

Watch this video to learn how to build and run machine-learning models using InterSystems IRIS Cloud IntegratedML using the example of 15,000 rows of data from New York City taxi rides to predict the tip for a given ride:

Building Models with IntegratedML in the Cloud

https://www.youtube.com/embed/SVW5J7wqHoQ
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

1 0
0 108

Some readers of my previous article, Caché eXTreme for .NET - direct access to globals from C#, wondered if you could access information not just from the same instance in which you’re working, but also from another instance on the same computer, or from an instance located on another computer in the same local network. Some theorized, correctly, that this would be possible using the Enterprise Cache Protocol (ECP). In this article I’m going to show how it can be done.

1 0
0 667