Question Dominic Chui · Jan 3, 2023 How to canonicalize XML enabled classes? I have a registered object class that extends %XML.Adaptor and I want to convert an object of it into canonical XML. From reading the documentation and some trial and error, it seems like I would need to use %XML.Writer to write the object to XML first using the RootObject() method, then read it with %XML.Reader, and then use the Canonicalize() method of %XML.Writer to write it out again. Is there a better approach? #XML #Caché 1 2 1 422
Question Dominic Chui · Oct 4, 2022 Is there a way to directly open % classes in VS Code? When using VS Code for Objectscript, is there a way to directly open % classes, like %Library.String, without needing to search for a property of that type and right clicking->"Go to Definition"? I know it is possible to use "system=1" in the workspace uri definition to see all the % classes, but that tends to clog up the left side viewer with many extra directories. There is also the option in the settings to selectively hide some by defining files.exclude, but it seems fairly complicated to set up a filter for exactly the relevant directories. #ObjectScript #VSCode 1 4 1 358
Question Dominic Chui · Jul 14, 2022 What's the best way to structure a list of tuples for passing into a method? Let's say I have two lists of connected data where elements of listTwo only make sense if given an item of listOne as context: listOne = ["A", "B", "C"] listTwo = ["x", "y", "z"] Tuples like ("A", "y") and ("C, "x") make sense, but "A" or "x" by themselves don't. I would like to pass in a list of such tuples into a method and have it handle each tuple in the list. So what would be the best way to format them given that ObjectScript does not have specialized tuples? Would it be nested $LISTBUILD lists or something else? #ObjectScript #Caché #InterSystems IRIS 0 1 0 279
Question Dominic Chui · Apr 6, 2022 Dynamic SQL and Setting SQLCODE Is there a reason why calling %ExecDirect() (or %Execute) won't set the %SQLCODE of the result set to 100 even when the query returns no data? Here is the code in question with a bit of contrivance to force the issue: set statement = ##class(%SQL.Statement).%New()set result = ##class(%SQL.Statement).%ExecDirect(statement,"select top 0 0 from Example.Testing")w result.%SQLCODE The %SQLCODE is set to 0 in this case. The same happens if I use %Prepare and %Execute, e.g. #Caché 1 8 0 530
Question Dominic Chui · Oct 11, 2021 Relatively Quick and Simple Way to Convert from Old Dot Scoping to New Parentheses Scoping? Does anyone know of a relatively quick and straightforward way of converting code written in the old dot scoping syntax with argumentless do (see here for reference: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_cdo_legacy) to the modern parentheses scoping syntax? It's not too bad to do it by hand, but it's also easy to make a mistake and leave a "quit" in an if statement by accident for example. E.g. #Caché #InterSystems IRIS 1 10 1 561
Question Dominic Chui · Apr 27, 2021 VS Code Server-Side Editing Issues with 1) Unqualified Class Names in Routines and 2) 'Go to Definition' from CSP to CLS I have run into two annoyances when using VS Code for server-side editing of Objectscript and was wondering if anyone knows of any solutions or workarounds. 1. In .mac routine files, class names that aren't fully qualified (e.g. ##class(example) instead of ##class(Package.example)) fail to be understood, so the class will have a red squiggly underneath it and a problem that reads "Class 'example' does not exist. InterSystems Language Server". #VSCode #Caché #InterSystems IRIS 0 2 0 221