func init // define project name sys.set_project(this.name) // initialize properties platform_target = this.props("Platform").value sys.set_typed_field(20, 'BackgroundColor') sys.set_typed_field(1, 'BufferHeight') sys.set_typed_field(1, 'BufferWidth') sys.set_typed_field(1, 'CursorLeft') sys.set_typed_field(1, 'CursorSize') sys.set_typed_field(1, 'CursorTop') sys.set_typed_field(104, 'CursorVisible') sys.set_typed_field(20, 'ForegroundColor') sys.set_typed_field(20, 'InputEncoding') sys.set_typed_field(20, 'OutputEncoding') sys.set_typed_field(2, 'Title') sys.set_typed_field(104, 'TreatControlCAsInput') sys.set_typed_field(1, 'WindowHeight') sys.set_typed_field(1, 'WindowLeft') sys.set_typed_field(1, 'WindowTop') sys.set_typed_field(1, 'WindowWidth') // makes implementation methods for properties sys._prop_init('BackgroundColor', 1, 1, 0, 'Console') sys._prop_init('BufferHeight', 1, 1, 1, 'Console') sys._prop_init('BufferWidth', 1, 1, 1, 'Console') sys._prop_init('CapsLock', 1, 0, 104, 'Console') sys._prop_init('CursorLeft', 1, 1, 1, 'Console') sys._prop_init('CursorSize', 1, 1, 1, 'Console') sys._prop_init('CursorTop', 1, 1, 1, 'Console') sys._prop_init('CursorVisible', 1, 1, 104, 'Console') sys._prop_init('Error', 1, 0, 0, 'Console') sys._prop_init('ForegroundColor', 1, 1, 0, 'Console') sys._prop_init('In', 1, 0, 0, 'Console') sys._prop_init('InputEncoding', 1, 1, 0, 'Console') sys._prop_init('KeyAvailable', 1, 0, 104, 'Console') sys._prop_init('LargestWindowHeight', 1, 0, 1, 'Console') sys._prop_init('LargestWindowWidth', 1, 0, 1, 'Console') sys._prop_init('NumberLock', 1, 0, 104, 'Console') sys._prop_init('Out', 1, 0, 0, 'Console') sys._prop_init('OutputEncoding', 1, 1, 0, 'Console') sys._prop_init('Title', 1, 1, 2, 'Console') sys._prop_init('TreatControlCAsInput', 1, 1, 104, 'Console') sys._prop_init('WindowHeight', 1, 1, 1, 'Console') sys._prop_init('WindowLeft', 1, 1, 1, 'Console') sys._prop_init('WindowTop', 1, 1, 1, 'Console') sys._prop_init('WindowWidth', 1, 1, 1, 'Console') // initialize events sys.event_add('onCancelKeyPress', 'ConsoleCancelEventHandler', '', '', 'Console') sys.event_imp('onCancelKeyPress', '', '', '', 'Object sender, ConsoleCancelEventArgs args') // initialize fields this.setfield('args', 'args' + this.id) end func doStart() // adds using namespace sys.add_use('System') // add common references sys.reference_add('System') sys.reference_add('System.Core') sys.reference_add('System.Xml.Linq') sys.reference_add('System.Data.DataSetExtensions') sys.reference_add('Microsoft.CSharp') sys.reference_add('System.Data') sys.reference_add('System.Xml') event('onStart') // init all unlinked elements ---------------------------------- this.parent.initall() // create main unit --------------------------------------------- blk = block.reggen() blk.copyhere(blk_using) .println() .println('namespace my', code(replace(project_name(), "-" , "_"))) .println('{').inc() if(not blk_struct.empty()) blk.copyhere(blk_struct) .println() end blk.println('class Program {').inc() if(not blk_fields.empty()) blk.copyhere(blk_fields) .println() end blk.copyhere(blk_vars) .println() .println('static void Main(string[] ', this.args, ')') .println('{').inc() .println('// init --------------------------------------------') .copyhere(blk_init) .println('// main body ---------------------------------------') .copyhere(blk_lvars) .println() .copyhere(blk_body) .dec().println('}') .copyhere(blk_proc_imp) for(i = 0; i < inits.size(); i++) blk.copyhere(inits.get(i)) end blk.dec().println('}') .copyhere(blk_class) .dec().println('}') .println('// Made by HiAsm Studio version ' + version) pname = code(project_name()) fname = pname + '.cs' blk.save(fname) blk = block.reg("result") blk.println('') .println('').inc() .println('').inc() .println('', this.props("Platform").value, '') .println('Exe') .println('', namespace, '') .println('', pname, '') .println('v4.0') .println('', this.props("FileAligment").value, '') b = this.props("Constants").value arr = new array() if(b _and_ 1) arr.add('DEBUG') end if(b _and_ 2) arr.add('TRACE') end if(not isdef("Symbols")) blk.println('true') arr.add(code(this.props("Symbols").value)) end blk.println('', lower(this.props("DebugInfo").value), '') .println('', lower(this.props("Optimize").value), '') if(isdef("OuputPath")) blk.println('', code(project_dir()), '') else blk.println('', code(this.props("OutputPath").value), '') end blk.println('', arr.join(';'), '') if(not isdef("ErrorReport")) blk.println('', lower(this.props("ErrorReport").value), '') end blk.println('', this.props("WarningLevel").value, '') .println('', lower(this.props("Unsafe").value), '') if(not isdef("SuppressWarning")) blk.println('', code(this.props("SuppressWarning").value), '') end if(not isdef("TreatWarnings")) blk.println('true') end if(not isdef("WarningsAsErrors")) blk.println('', code(this.props("WarningsAsErrors").value), '') end blk.println('', lower(this.props("Serialization").value), '') if(not isdef("Language")) blk.println('', code(this.props("Language").value), '') end if(not isdef("CheckOverflow")) blk.println('true') end if(not isdef("NoStdLib")) blk.println('true') end blk.copyhere(blk_prop) .println('true') .dec().println('') .println('').inc() .copyhere(blk_refs) .dec().println('') .println('').inc() .println('') .copyhere(blk_comp) .dec().println('') .copyhere(blk_resx) .println('').inc() .println('') .dec().println('') .println('') .dec().println('') end func CommandLineArgs return(this.args) end func doClear() blk.println('Console.Clear();') end func OpenStandardError return('Console.OpenStandardError()') end func doOpenStandardError2(data) if(linked("onOpenStandardError")) event("onOpenStandardError", 'Console.OpenStandardError(' + d("bufferSize") + ')') else blk.println('Console.OpenStandardError(', d("bufferSize"), ');') end end func OpenStandardInput return('Console.OpenStandardInput()') end func doOpenStandardInput2(data) if(linked("onOpenStandardInput")) event("onOpenStandardInput", 'Console.OpenStandardInput(' + d("bufferSize") + ')') else blk.println('Console.OpenStandardInput(', d("bufferSize"), ');') end end func OpenStandardOutput return('Console.OpenStandardOutput()') end func doOpenStandardOutput2(data) if(linked("onOpenStandardOutput")) event("onOpenStandardOutput", 'Console.OpenStandardOutput(' + d("bufferSize") + ')') else blk.println('Console.OpenStandardOutput(', d("bufferSize"), ');') end end func Read return('Console.Read()') end func ReadKey return('Console.ReadKey()') end func doReadKey2(data) if(linked("onReadKey")) event("onReadKey", 'Console.ReadKey(' + sys.get_typed_field(data, 'Intercept', 104) + ')') else blk.println('Console.ReadKey(', sys.get_typed_field(data, 'Intercept', 104), ');') end end func ReadLine return('Console.ReadLine()') end func doResetColor() blk.println('Console.ResetColor();') end func doSetError(data) blk.println('Console.SetError(', d("newError"), ');') end func doSetIn(data) blk.println('Console.SetIn(', d("newIn"), ');') end func doSetOut(data) blk.println('Console.SetOut(', d("newOut"), ');') end func doWrite(data) blk.println('Console.Write(', d("value"), ');') end func doWrite2(data) blk.println('Console.Write(', d("format"), ', ', d("arg0"), ');') end func doWrite3(data) blk.println('Console.Write(', d("format"), ', ', d("args"), ');') end func doWrite4(data) blk.println('Console.Write(', d("buffer"), ', ', d("index"), ', ', d("count"), ');') end func doWrite5(data) blk.println('Console.Write(', d("format"), ', ', d("arg0"), ', ', d("arg1"), ');') end func doWrite6(data) blk.println('Console.Write(', d("format"), ', ', d("arg0"), ', ', d("arg1"), ', ', d("arg2"), ');') end func doWriteLine() blk.println('Console.WriteLine();') end func doWriteLine2(data) blk.println('Console.WriteLine(', d("value"), ');') end func doWriteLine3(data) blk.println('Console.WriteLine(', d("format"), ', ', d("arg0"), ');') end func doWriteLine4(data) blk.println('Console.WriteLine(', d("format"), ', ', d("args"), ');') end func doWriteLine5(data) blk.println('Console.WriteLine(', d("buffer"), ', ', d("index"), ', ', d("count"), ');') end func doWriteLine6(data) blk.println('Console.WriteLine(', d("format"), ', ', d("arg0"), ', ', d("arg1"), ');') end func doWriteLine7(data) blk.println('Console.WriteLine(', d("format"), ', ', d("arg0"), ', ', d("arg1"), ', ', d("arg2"), ');') end