func init // initialize instance if(linked("Result") and linked("doOperation")) sys.add_var(this.name, 'dynamic') if(not isdef("Default")) blk_init.println(this.codename, ' = ', this.props("Default").value, ';') end end // initialize type of the numbers if(isdef("Op1")) this.type1 = this.get_type(this.props("TypeOp1").value) else this.type1 = typeof(this.props("Op1").value) if(this.type1 == 3) this.type1 = 7 elseif(this.type1 == 2) this.type1 = this.get_type(this.props("TypeOp1").value) end end if(isdef("Op2")) this.type2 = this.get_type(this.props("TypeOp2").value) else this.type2 = typeof(this.props("Op2").value) if(this.type2 == 3) this.type2 = 7 elseif(this.type2 == 2) this.type2 = this.get_type(this.props("TypeOp2").value) end end end func doOperation(data) if(linked("Result")) blk.println(this.codename, ' = ', this.make_result(data), ';') event("onResult", this.codename) else event("onResult", this.make_result(data)) end end func make_result(data) return(this.typed('(' + sys.to_type(d("Op1"), this.type1) + ' ' + this.props("OpType").value + ' ' + sys.to_type(d("Op2"), this.type2) + ')')) end func typed(r) if(this.type1 == 1) sub(r, this.type2) else sub(r, this.type1) end return(r) end func get_type(t) if(t == 0) return(7) elseif(t == 1) return(108) elseif(t == 2) return(1) elseif(t == 3) return(105) elseif(t == 4) return(107) elseif(t == 5) return(0) end end func Result if(linked("doOperation")) return(this.codename) else return(make_result()) end end