Skip to content

Instantly share code, notes, and snippets.

@kenwebb

kenwebb/xholonWorkbook.xml

Last active Feb 14, 2021
Embed
What would you like to do?
functional beh
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Sun Feb 14 2021 11:49:33 GMT-0500 (Eastern Standard Time)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: functional beh
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 4ac8657c88b205608565a593fb631741
Keywords:
My Notes
--------
In this workbook, I experiment with using arrow functions in Xholon Behavior (script) nodes.
See Heightbehavior node.
the default code provided in a new workbook:
<Heightbehavior implName="org.primordion.xholon.base.Behavior_gwtjs">
var myHeight, testing;
var beh = {
postConfigure: function() {
testing = Math.floor(Math.random() * 10);
myHeight = this.cnode.parent();
},
act: function() {
myHeight.println(this.toString());
},
toString: function() {
return "testing:" + testing;
}
}
//# sourceURL=Heightbehavior.js
</Heightbehavior>
// successful use of arrow notation
// Note: beh must use "var" and can't use "const" or "let"
<Heightbehavior implName="org.primordion.xholon.base.Behavior_gwtjs">
let me, testing
var beh = {
postConfigure: () => {
beh.logstuff()
testing = Math.floor(Math.random() * 10)
me = this.parent()
},
logstuff: () => console.log(console.log(this), console.log(this.parent()), console.log(beh), console.log(beh.cnode)),
act: () => me.println(beh.toString()),
toString: () => "testing:" + testing
}
//# sourceURL=Heightbehavior.js
</Heightbehavior>
// unsuccesful attempt to use IIEF notation:
// &jslib=FreeformText2XmlString
(() => {
console.log("testing 1")
let me, testing
var beh = {
postConfigure: () => {
beh.logstuff()
testing = Math.floor(Math.random() * 10)
me = this.parent()
},
logstuff: () => console.log(console.log(this), console.log(this.parent()), console.log(beh), console.log(beh.cnode)),
act: () => me.println(beh.toString()),
toString: () => "testing:" + testing
}
})()
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<Block/>
<Height superClass="Quantity"/>
</_-.XholonClass>
<xholonClassDetails>
<!--<Block>
<port name="height" connector="Height"/>
</Block>-->
</xholonClassDetails>
<PhysicalSystem>
<Block>
<Height>0.1 m</Height>
</Block>
</PhysicalSystem>
<Blockbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var a = 123;
var b = 456;
var c = a * b;
if (console) {
console.log(c);
}
//# sourceURL=Blockbehavior.js
]]></Blockbehavior>
<Heightbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
let me, testing
var beh = {
postConfigure: () => {
beh.logstuff()
testing = Math.floor(Math.random() * 10)
me = this.parent()
},
logstuff: () => console.log(this, this.parent(), beh, beh.cnode),
act: () => me.println(beh.toString()),
toString: () => "testing:" + testing
}
//# sourceURL=Heightbehavior.js
]]></Heightbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Block</title>
<rect id="PhysicalSystem/Block" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>Height</title>
<rect id="PhysicalSystem/Block/Height" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment