func init // define project name sys.set_project(this.name) // defines using namespaces if(not isdef("Using")) arr = this.props("Using").value for(i = 0; i < arr.size(); i++) sys.add_use(code(arr.get(i))) end end // defines using interfaces if(not isdef("Interfaces")) arr = this.props("Interfaces").value this._interfaces = code(arr.join(', ')) end // defines level this.level = isdef("AccessModifier") ? '' : lower(this.props("AccessModifier").value) + ' ' // defines class type t = this.props("TypeModifier").value this.type = ((t _and_ 1) ? 'abstract ' : '') + ((t _and_ 2) ? 'partial ' : '') + ((t _and_ 4) ? 'sealed ' : '') + ((t _and_ 8) ? 'static ' : '') + ((t _and_ 16) ? 'virtual ' : '') // defines class name if(isdef("ClassName")) this.cName = this.codename else this.cName = code(this.props("ClassName").value) end // defines base class this.base = isdef("Base") ? '' : ': ' + code(this.props("Base").value) // defines gaps blk_vars.dec() blk_body.dec() blk_proc_imp.dec() // clean arr.clear() end func doStart() // init all properties this.parent.init_managers("Property") // init all events this.parent.init_managers("Event") // init all other unlinked elements this.parent.initall() // defines attributes if(not isdef("Attributes")) arr = this.props("Attributes").value attr = code(arr.join(', ')) end // creates class blk = block.reg("result") blk.copyhere(blk_using) .println() .println('namespace ', code(this.props("Namespace").value)) .println('{').inc() .copyhere(blk_struct) .println() // defines comments arr.clear() if(not isdef("Comment")) arr = this.props("Comment").value for(i = 0; i < arr.size(); i++) blk.println('/// ', code(arr.get(i))) end end // declares class isdef("Attributes") ? '' : blk.println('[', attr, ']') blk.println(this.level, this.type, 'class ', this.cName, this.base, isdef("Interfaces") ? '' : (isdef("Base") ? ': ' : ', ') + this._interfaces) .println('{').inc() .copyhere(blk_fields) .copyhere(blk_vars) if(blk_constructor.empty()) blk.println('public ', this.cName, '()') .println('{').inc() .copyhere(blk_init) .dec().println('}') else blk.copyhere(blk_constructor) end blk.println() for(i = 0; i < inits.size(); i++) blk.copyhere(inits.get(i)) end blk.copyhere(blk_proc_imp) .dec().println('}') .dec().println('}') // makes element if(not isdef("MakeElement")) // makes .ini file f = block.reggen() f.println('[About]') .println('Version=', code(this.props("Version").value)) .println('Author=', code(this.props("Author").value)) .println('Mail=', code(this.props("Mail").value)) .println() .println('[Type]') .println('Class=', this.props("ClassType").value) .println('Info=', code(this.props("Info").value)) .println() .println('[Property]') if(hws_constructors.size()) s = 'Constructor=Sets the Constructor of the element. ARG(enum)|14|0|None,' + hws_constructors.get(0) for(i = 1; i < hws_constructors.size(); i++) s += ',' + hws_constructors.get(i) end f.println(s) end if(not blk_props.empty()) f.copyhere(blk_props) end f.println() .println('[Methods]') if(not blk_methods.empty()) f.copyhere(blk_methods) end f.println(this.cName, '=Returns the instance of the element. ARG(', this.cName, ')|3|0') pname = code(project_name()) fname = pname + '.ini' tmp = pname + '.ini.tmp' f.save(tmp) block.delete(f) if(not fcopy(code_dir() && tmp, project_dir() && fname)) error(this.name + ' - can not copy file to project_dir()') end // makes .hws file f = block.reggen() f.println('func init').inc() .println('// add using module') .println('sys.add_use(\'', pname, '\')') .println() .println('// use external class') .println('sys.UseClass(\'', pname, '\')') .println() .println('// initialize instance') if(hws_constructors.size()) f.println('params = this.props(\'Constructor\').value') .println('if(params == \'None\')').inc() .println('sys.add_var(this.name, \'', this.cName, '\')') .dec().println('else').inc() .println('if(params == \'', hws_constructors.get(0), '\')').inc() .println('params = \'\' + ', code(hws_args.get(0))) for(i = 1; i < hws_constructors.size(); i++) f.dec().println('elseif(params == \'', hws_constructors.get(i), '\')').inc() .println('params = \'\' + ', hws_args.get(i)) end f.dec().println('end') .println('sys.add_object(this.codename, \'', this.cName, '\', params)') .println('') if(not blk_hws_props.empty()) f.println('// initialize properties') .copyhere(blk_hws_props) .println() end if(not blk_hws_events.empty()) f.println('// add event handlers') .copyhere(blk_hws_events) end f.dec().println('end') else // simple contructor f.println('sys.add_object(this.codename, \'', this.cName, '\')') end f.println() .println('// makes implementation methods for properties') .println('sys._mtd_as_prop_init(\'', this.cName, '\')') if(not blk_hws_props_init.empty()) f.println('// makes implementation methods for properties') .copyhere(blk_hws_props_init) .println() end if(not blk_hws_events_imp.empty()) f.println('// makes implementation methods for event handlers') .copyhere(blk_hws_events_imp) .println() end f.dec().println('end') .println() for(i = 0; i < hws_blocks.size(); i++) f.copyhere(hws_blocks.get(i)) .println() end ver = split(version, '.') fname = 'hi' + pname + '.hws' tmp = 'hi' + pname + '.hws.tmp' f.save(tmp) block.delete(f) if(not fcopy(code_dir() && tmp, project_dir() && fname)) error(this.name + ' - can not copy file to project_dir()') end // makes .his file if(ver.get(0) == "4") f = block.reggen() f.println('function run() {').inc() .println('var f1 = sys.curdir() + "', pname, '.cs";') .println('var f2 = ', this.props("IconPath").value, ';') .println('var f3 = sys.curdir() + "hi', pname, '.hws";') .println('if( !sys.extelement( "cnet", "', pname, '" ) ) {').inc() .println('AddElement( f1, f2 , f3);') .dec().println('} else {').inc() .println('WshShell = new ActiveXObject("WScript.Shell");') .println('var Res = WshShell.Popup( "Overwrite old element?", 0, "Install Element", vb.Question + vb.YesNo );') .println('if( Res == vb.Yes ) {').inc() .println('AddElement( f1, f2 , f3);') .dec().println('}') .dec().println('}') .dec().println('}') .println() .println('function AddElement( f1, f2 , f3) {').inc() .println('var fso = new ActiveXObject("Scripting.FileSystemObject");') .println('if( fso.FileExists( f1 ) ) {').inc() .println('var f = fso.GetFile( f1 )') .println('f.Copy( sys.hiasmdir() + "\\\\Elements\\\\CNET\\\\code\\\\classes\\\\', pname, '.cs" );') .dec().println('} else {').inc() .println('MsgBox( "File not found: " + f1, vb.Critical + vb.OKOnly, "Install Element" )') .dec().println('}') if(not isdef("IconPath")) f.println('if( fso.FileExists( f2 ) ) {').inc() .println('var f = fso.GetFile( f2 )') .println('f.Copy( sys.hiasmdir() + "\\\\Elements\\\\CNET\\\\icon\\\\', pname, '.ico" );') .dec().println('} else {').inc() .println('MsgBox( "File not found: " + f2, vb.Critical + vb.OKOnly, "Install Element" )') .dec().println('}') end f.println('sys.addelement( "cnet", "', pname, '", ', this.props("Info").value, ', ', this.props("Tab").value, ' );') .println('if( fso.FileExists( f3 ) ) {').inc() .println('var f = fso.GetFile( f3 )') .println('f.Copy( sys.hiasmdir() + "\\\\Elements\\\\CNET\\\\code\\\\hi', pname, '.hws" );') .dec().println('} else {').inc() .println('MsgBox( "File not found: " + f3, vb.Critical + vb.OKOnly, "Install Element" )') .dec().println('}') .dec().println('}') .println() sys.LoadMethod("JScript", f) fname = pname + '.his' tmp = pname + '.his.tmp' f.save(tmp) block.delete(f) if(not fcopy(code_dir() && tmp, project_dir() && fname)) error(this.name + ' - can not copy file to project_dir()') end end // copy .cs file to project folder and install an element if(not isdef("InstallElement")) fname = pname + '.cs' tmp = pname + '.cs.tmp' blk.save(tmp) if(not fcopy(code_dir() && tmp, project_dir() && fname)) error(this.name + ' - can not copy file to project_dir()') end cmd = '"' + sys.get_folder(0) + 'elementinstaller.exe" ' + escape(project_dir()) + ' ' + pname + ' ' + this.props("Info").value + ' ' + ver.get(0) + (isdef("IconPath") ? '' : (' "' + this.props("IconPath").value + '"')) if(not exec(cmd, 1)) error(this.name + ' - can not exec() ' + cmd) end end end // cleanup arr.clear() end func Class return('this') end