Skip to content

Commit 58d866c

Browse files
committed
Added new visited setting. Set it equal to valid Caché ObjectScript code and recompile Form.JSON.OBJ class to modify SetVisited method code. SetVisited method allows you to define what object can be output any number of times (by default object can be written once to prevent write loops).
1 parent 72e3a7e commit 58d866c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Form/JSON/OBJ.cls.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
<Super>%ZEN.Auxiliary.jsonProvider</Super>
88
<TimeCreated>64099,77101.820492</TimeCreated>
99

10+
<Method name="SetVisited">
11+
<ClassMethod>1</ClassMethod>
12+
<CodeMode>objectgenerator</CodeMode>
13+
<FormalSpec><![CDATA[&pVisited,pObject:%RegisteredObject,pLevel:%Integer]]></FormalSpec>
14+
<Implementation><![CDATA[
15+
#include %occCPTJSgen
16+
set code = ##class(Form.Settings).getSetting("visited")
17+
if code'="" {
18+
do %code.WriteLine($$$TAB _ code)
19+
} else {
20+
do %code.WriteLine($$$TAB _ "set pVisited(pObject) = """"")
21+
}
22+
]]></Implementation>
23+
</Method>
24+
1025
<Method name="%ObjectToJSON">
1126
<Description><![CDATA[
1227
Write out the contents of object instance <var>pObject</var> to
@@ -44,7 +59,7 @@ w - Windows-style cr/lf newline<br/>]]></Description>
4459
Quit
4560
}
4661
47-
set pVisited(pObject) = ""
62+
do ..SetVisited(.pVisited, pObject, pLevel)
4863
4964
Set tClass = $classname(pObject)
5065

Form/Settings.cls.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Set setting "name" value</Description>
4343
if ((value'="utc") && (value'="ignore")) {
4444
set sc = $$$ERROR($$$GeneralError, "Value '" _value _ "' is not a valid timezone setting. Valid values are: ignore, utc")
4545
}
46+
} elseif name = "visited" {
47+
/// TODO add check
4648
} else {
4749
set sc = $$$ERROR($$$GeneralError, "Setting '" _ name _ "' does not exist")
4850
}

0 commit comments

Comments
 (0)