Eduard Lebedyuk · Dec 26, 2017 go to post

If you can, always invoke code directly:

do ##class(circle).radius()

Use classmethod only if you can't invoke method directly.

Eduard Lebedyuk · Dec 26, 2017 go to post

Class include is not required (and does not seem to affect anything) and can be omitted

Include Child

Why that happens, as  methods generators are compiled before methods?

 

As for the second approach, I'd like to avoid duplicating code (in a real case I have about 20 methods 1-50 lines long).

Eduard Lebedyuk · Dec 26, 2017 go to post

Interesting,

Sorry, that I didn't specify it earlier, but I can't modify Parent.inc too.

Eduard Lebedyuk · Dec 22, 2017 go to post

Have you tried d format flag

 d - output Caché numeric properties that have value "" as null
Eduard Lebedyuk · Dec 22, 2017 go to post

Thank you, turns out Telnet was disabled.

I can have only one telnet terminal per windows server or is there an option to specify port?

Eduard Lebedyuk · Dec 21, 2017 go to post

Got "Connection refused". Shouldn't I specify 1972 port? Tried both 'telnet' and 1972 ports, still 'connection refused'.

Eduard Lebedyuk · Dec 21, 2017 go to post

Replacing "" with null seems like a better solution to me as " symbol is escaped to \", so "" should not be encountered in JSON, except for empty strings.

Eduard Lebedyuk · Dec 21, 2017 go to post

It seems to fail on second line of this code sample:

set prevspace="^"_$zu(96,12)
u 0::"^%X364"    ; Set mnemonic space
u 0::prevspace
Eduard Lebedyuk · Dec 21, 2017 go to post

Additional JSON functionality, such as JSON (de)serialization for arbitrary classes was at one point available but currently under review. It may appear in one of future versions. I've posted a workaround.

You can also check RESTForms - REST API  for your persistent classes, it does support JSON (de)serialization. Another article about RESTForms.

Eduard Lebedyuk · Dec 21, 2017 go to post

You can convert object to dynamic object and output it to JSON:

zn "samples"
set per = ##class(Sample.Person).%OpenId(1)
set obj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(per)
write obj.%ToJSON()

Also check %ObjectToJSON in %ZEN.Auxiliary.altJSONProvider class.

Eduard Lebedyuk · Dec 20, 2017 go to post

1. There's no need to instantiate tResponse, it would be reinstantiated later anyway.

2. Please post ConsultaPaciente method from your class specified in WebServiceClientClass setting.

Eduard Lebedyuk · Dec 20, 2017 go to post

2016.2 supports Atelier, so you need to either install new 2016.2 instance or update to 2016.2.

Install atelier by following these instructions.

UPD. Sandbox means you only need sample data? You can install new 2016.2 instance. It takes 10 minutes tops.

Eduard Lebedyuk · Dec 20, 2017 go to post

Another example - lets say you want to delete several files and check that all is fine:

ClassMethod MassDelete()
{
  #dim sc As %Status = $$$OK

  // Deletes the file. Returns true if it succeeds and false otherwise.
  // Pass return by reference to obtain the low level return value in case of errors
  #define del(%file,%return) ##class(%File).Delete(%file,%return)

  set file1 = "file1.txt"
  set file2 = "file2.txt"
  if (('$$$del(file1, .return1)) | ('$$$del(file2, .return2))) {
    set sc = $$$ERROR($$$GeneralError, "Files '%1', '%2' deletion failed with codes: %3, %4", file1, file2, $get(return1), $get(return2))
  }
  quit sc
}

In case of "||" if the first delete was successful , the second delete would not be called. Use '|' to attempt both deletes 

Eduard Lebedyuk · Dec 20, 2017 go to post

Can you show us your code?

To use XML reader you need to call Correlate method, which correlates any specified XML element to class.

Eduard Lebedyuk · Dec 15, 2017 go to post

This assures that all expressions are valid.

More importantly this assures that all expressions were executed.

Eduard Lebedyuk · Dec 15, 2017 go to post

You shouldn't create TestCsv.Csv class. CSVTOCLASS method would create the class you specified as a last argument automatically. After that you need to open  that new class, it would have an Import method. Call it with your file to actually import data.

Eduard Lebedyuk · Dec 14, 2017 go to post

Generally it goes like this:

<scope>
Do stuff, maybe throw exceptions (or just set status variable to error status)
<faulthandlers>
<catchall>
Process errors. context.%LastError contains your error
</catchall>
</faulthandlers>
</scope>

Check docs for these elements, there are several examples available:

Also, check EnsLib.ebXML.Process.MessageSender for example.