func init // adds using namespace sys.add_use('System.Net') // initialize instance this.wc = sys.get_undef_manager("WebClient") if((linked("Result") and linked("doOpenRead")) or linked("doClose")) sys.add_var(this.name, 'Stream') end end func doOpenRead(data) if(linked("Result") or linked("doClose")) blk.println(this.codename, ' = ', this.make_result(data), ';') event("onResult", this.codename) else event("onResult", this.make_result(data)) end end func doClose() blk.println(this.codename, '.Close();') end func Result if(sys.is_linked(1)) return(this.codename) else return(this.make_result()) end end func make_result(data) return(this.wc + '.OpenRead(' + d("URI") + ')') end