CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  PowerBuilder >  非技术版

关于PB中英文翻译的文章(2天类结帖)(前天的帖子刚结帖了)

楼主windyman518(风一样的男子)2005-06-05 15:25:04 在 PowerBuilder / 非技术版 提问

需要pb   相关技术的文章,最好原著是英文,且有中文的翻译。  
   
  2   天内结帖,人多了,另外开帖! 问题点数:100、回复次数:6Top

1 楼njupt_zhb(攒钱买飞机)回复于 2005-06-05 15:26:50 得分 100

http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=79&ID=68347&page=2  
  http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=79&ID=82482&page=2  
  Top

2 楼windyman518(风一样的男子)回复于 2005-06-06 02:25:44 得分 0

译自pb的联机帮助。  
  原文在:pb安装目录\PowerBuilder   9.0\Help\pbman90.chm:  
  Application   Techniques   ->   Language   Techniques   ->   Chapter3   ->   Exception   handling   in   PowerBuilder  
   
  因为我没有装PB9,能把Exception   handling   in   PowerBuilder这篇英文帖出来吗?  
   
     
  Top

3 楼njupt_zhb(攒钱买飞机)回复于 2005-06-06 10:33:17 得分 0

Exception   handling   in   PowerBuilder  
  When   a   runtime   error   occurs   in   a   PowerBuilder   application,   unless   that   error   is   trapped,   a   single   application   event   (SystemError)   fires   to   handle   the   error   no   matter   where   in   the   application   the   error   happened.   Although   some   errors   can   be   handled   in   the   system   error   event,   catching   the   error   closer   to   its   source   increases   the   likelihood   of   recovery   from   the   error   condition.    
   
  You   can   use   exception-handling   classes   and   syntax   to   handle   context-sensitive   errors   in   PowerBuilder   applications.   This   means   that   you   can   deal   with   errors   close   to   their   source   by   embedding   error-handling   code   anywhere   in   your   application.   Well-designed   exception-handling   code   can   give   application   users   a   better   chance   to   recover   from   error   conditions   and   run   the   application   without   interruption.  
   
  Exception   handling   allows   you   to   design   an   application   that   can   recover   from   exceptional   conditions   and   continue   execution.   Any   exceptions   that   you   do   not   catch   are   handled   by   the   runtime   system   and   can   result   in   the   termination   of   the   application.    
   
    Machine   code   If   you   need   to   build   machine   code   DLLs,   you   cannot   use   exception   handling.   The   process   of   building   machine   code   does   not   support   the   exception   handling   mechanism.   Attempts   to   compile   machine   code   DLLs   from   code   that   uses   exception   handling   fail   and   display   an   error   message.   For   more   information   about   choosing   between   Pcode   (PBDs)   and   machine   code   (DLLs),   see   "Compiler   basics".  
   
  PowerBuilder   clients   can   catch   exceptions   thrown   from   EAServer   components   and   recover   from   them.   Components   developed   with   PowerBuilder   can   also   define   and   throw   their   own   exception   types,   making   them   more   consistent   with   other   EAServer   component   types   like   Java.  
   
  Exception   handling   can   be   found   in   such   object-oriented   languages   as   Java   and   C++.   The   implementation   for   PowerBuilder   is   similar   to   the   implementation   of   exception   handling   in   Java.   In   PowerBuilder,   the   TRY,   CATCH,   FINALLY,   THROW,   and   THROWS   reserved   words   are   used   for   exception   handling.   There   are   also   several   PowerBuilder   objects   that   descend   from   the   Throwable   object.  
   
  Basics   of   exception   handling  
  Exceptions   are   objects   that   are   thrown   in   the   event   of   some   exceptional   (or   unexpected)   condition   or   error   and   are   used   to   describe   the   condition   or   error   encountered.   Standard   errors,   such   as   null   object   references   and   division   by   zero,   are   typically   thrown   by   the   runtime   system.   These   types   of   errors   could   occur   anywhere   in   an   application   and   you   can   include   catch   clauses   in   any   executable   script   to   try   to   recover   from   these   errors.  
   
  User-defined   exceptions  
  There   are   also   exceptional   conditions   that   do   not   immediately   result   in   runtime   errors.   These   exceptions   typically   occur   during   execution   of   a   function   or   a   user-event   script.   To   signal   these   exceptions,   you   create   user   objects   that   inherit   from   the   PowerScript   Exception   class.   You   can   associate   a   user-defined   exception   with   a   function   or   user   event   in   the   prototype   for   the   method.  
   
  For   example,   a   user-defined   exception   might   be   created   to   indicate   that   a   file   cannot   be   found.   You   could   declare   this   exception   in   the   prototype   for   a   function   that   is   supposed   to   open   the   file.   To   catch   this   condition,   you   must   instantiate   the   user-defined   exception   object   and   then   throw   the   exception   instance   in   the   method   script.  
   
  Objects   for   exception   handling   support  
  Several   system   objects   support   exception   handling   within   PowerBuilder.    
   
  Throwable   object   type  
  The   object   type   Throwable   is   the   root   datatype   for   all   user-defined   exception   and   system   error   types.   Two   other   system   object   types,   RuntimeError   and   Exception,   derive   from   Throwable.  
   
  RuntimeError   and   its   descendants  
  PowerBuilder   runtime   errors   are   represented   in   the   RuntimeError   object   type.   For   more   robust   error-handling   capabilities,   the   RuntimeError   type   has   its   own   system-defined   descendants;   but   the   RuntimeError   type   contains   all   information   required   for   dealing   with   PowerBuilder   runtime   errors.  
   
  One   of   the   descendants   of   RuntimeError   is   the   NullObjectError   type   that   is   thrown   by   the   system   whenever   a   null   object   reference   is   encountered.   This   allows   you   to   handle   null-object-reference   errors   explicitly   without   having   to   differentiate   them   from   other   runtime   errors   that   might   occur.  
   
  Error   types   that   derive   from   RuntimeError   are   typically   used   by   the   system   to   indicate   runtime   errors.   RuntimeErrors   can   be   caught   in   a   try-catch   block,   but   it   is   not   necessary   to   declare   where   such   an   error   condition   might   occur.   (PowerBuilder   does   that   for   you,   since   a   system   error   can   happen   anywhere   anytime   the   application   is   running.)   It   is   also   not   a   requirement   to   catch   these   types   of   errors.  
   
  Exception   object   type  
  The   system   object   Exception   also   derives   from   Throwable   and   is   typically   used   as   an   ancestor   object   for   user-defined   exception   types.   It   is   the   root   class   for   all   checked   exceptions.   Checked   exceptions   are   user-defined   exceptions   that   must   be   caught   in   a   try-catch   block   when   thrown,   or   that   must   be   declared   in   the   prototype   of   a   method   when   thrown   outside   of   a   try-catch   block.    
   
  The   PowerScript   compiler   checks   the   local   syntax   where   you   throw   checked   exceptions   to   make   sure   you   either   declare   or   catch   these   exception   types.   Descendants   of   RuntimeError   are   not   checked   by   the   compiler,   even   if   they   are   user-defined   or   if   they   are   thrown   in   a   script   rather   than   by   the   runtime   system.  
   
  Top

4 楼njupt_zhb(攒钱买飞机)回复于 2005-06-06 10:33:40 得分 0

Handling   exceptions  
  Whether   an   exception   is   thrown   by   the   runtime   system   or   by   a   THROW   statement   in   an   application   script,   you   handle   the   exception   by   catching   it.   This   is   done   by   surrounding   the   set   of   application   logic   that   throws   the   exception   with   code   that   indicates   how   the   exception   is   to   be   dealt   with.  
   
  TRY-CATCH-FINALLY   block  
  To   handle   an   exception   in   PowerScript,   you   must   include   some   set   of   your   application   logic   inside   a   try-catch   block.   A   try-catch   block   begins   with   a   TRY   clause   and   ends   with   the   END   TRY   statement.   It   must   also   contain   either   a   CATCH   clause   or   a   FINALLY   clause.   A   try-catch   block   normally   contains   a   FINALLY   clause   for   error   condition   cleanup.   In   between   the   TRY   and   FINALLY   clauses   you   can   add   any   number   of   CATCH   clauses.    
   
  CATCH   clauses   are   not   obligatory,   but   if   you   do   include   them   you   must   follow   each   CATCH   statement   with   a   variable   declaration.   In   addition   to   following   all   of   the   usual   rules   for   local   variable   declarations   inside   a   script,   the   variable   being   defined   must   derive   from   the   Throwable   system   type.  
   
  You   can   add   a   TRY-CATCH-FINALLY,   TRY-CATCH,   or   TRY-FINALLY   block   using   the   Script   view   Paste   Special   feature   for   PowerScript   statements.   If   you   select   the   Statement   Templates   check   box   on   the   AutoScript   tab   of   the   Design   Options   dialog   box,   you   can   also   use   the   AutoScript   feature   to   insert   these   block   structures.  
   
  Example  
  Example   catching   a   system   error   This   is   an   example   of   a   TRY-CATCH-FINALLY   block   that   catches   a   system   error   when   an   arccosine   argument,   entered   by   the   application   user   (in   a   SingleLineEdit)   is   not   in   the   required   range.   If   you   do   not   catch   this   error,   the   application   goes   to   the   system   error   event,   and   eventually   terminates:    
   
   
   
  Double   ld_num   ld_num   =   Double   (sle_1.text)   TRY         sle_2.text   =   string   (acos   (ld_num))   CATCH   (runtimeerror   er)               MessageBox("Runtime   Error",   er.GetMessage())   FINALLY               //   Add   cleanup   code   here               of_cleanup()               Return   END   TRY         MessageBox("After",   "We   are   finished.")  
   
  The   system   runtime   error   message   might   be   confusing   to   the   end   user,   so   for   production   purposes,   it   would   be   better   to   catch   a   user-defined   exception--see   the   example   in   "Creating   user-defined   exception   types"--and   set   the   message   to   something   more   understandable.  
   
  The   TRY   reserved   word   signals   the   start   of   a   block   of   statements   to   be   executed   and   can   include   more   than   one   CATCH   clause.   If   the   execution   of   code   in   the   TRY   block   causes   an   exception   to   be   thrown,   then   the   exception   is   handled   by   the   first   CATCH   clause   whose   variable   can   be   assigned   the   value   of   the   exception   thrown.   The   variable   declaration   after   a   CATCH   statement   indicates   the   type   of   exception   being   handled   (a   system   runtime   error,   in   this   case).  
   
  CATCH   order  
  It   is   important   to   order   your   CATCH   clauses   in   such   a   way   that   one   clause   does   not   hide   another.   This   would   occur   if   the   first   CATCH   clause   catches   an   exception   of   type   Exception   and   a   subsequent   CATCH   clause   catches   a   descendant   of   Exception.   Since   they   are   processed   in   order,   any   exception   thrown   that   is   a   descendant   of   Exception   would   be   handled   by   the   first   CATCH   clause   and   never   by   the   second.   The   PowerScript   compiler   can   detect   this   condition   and   signals   an   error   if   found.  
   
  If   an   exception   is   not   dealt   with   in   any   of   the   CATCH   clauses,   it   is   thrown   up   the   call   stack   for   handling   by   other   exception   handlers   (nested   try-catch   blocks)   or   by   the   system   error   event.   But   before   the   exception   is   thrown   up   the   stack,   the   FINALLY   clause   is   executed.  
   
  FINALLY   clause  
  The   FINALLY   clause   is   generally   used   to   clean   up   after   execution   of   a   TRY   or   CATCH   clause.   The   code   in   the   FINALLY   clause   is   guaranteed   to   execute   if   any   portion   of   the   try-catch   block   is   executed,   regardless   of   how   the   code   in   the   try-catch   block   completes.    
   
  If   no   exceptions   occur,   the   TRY   clause   completes,   followed   by   the   execution   of   the   statements   contained   in   the   FINALLY   clause.   Then   execution   continues   on   the   line   following   the   END   TRY   statement.  
   
  In   cases   where   there   are   no   CATCH   clauses   but   only   a   FINALLY   clause,   the   code   in   the   FINALLY   clause   is   executed   even   if   a   return   is   encountered   or   an   exception   is   thrown   in   the   TRY   clause.    
   
  If   an   exception   occurs   within   the   context   of   the   TRY   clause   and   an   applicable   CATCH   clause   exists,   the   CATCH   clause   is   executed,   followed   by   the   FINALLY   clause.   But   even   if   no   CATCH   clause   is   applicable   to   the   exception   thrown,   the   FINALLY   clause   still   executes   before   the   exception   is   thrown   up   the   call   stack.  
   
  If   an   exception   or   a   return   is   encountered   within   a   CATCH   clause,   the   FINALLY   clause   is   executed   before   execution   is   transferred   to   the   new   location.  
   
  Top

5 楼njupt_zhb(攒钱买飞机)回复于 2005-06-06 10:34:22 得分 0

Creating   user-defined   exception   types  
  You   can   create   your   own   user-defined   exception   types   from   standard   class   user   objects   that   inherit   from   Exception   or   RuntimeError   or   that   inherit   from   an   existing   user   object   deriving   from   Exception   or   RuntimeError.    
   
  Inherit   from   Exception   object   type  
  Normally,   user-defined   exception   types   should   inherit   from   the   Exception   type   or   a   descendant,   since   the   RuntimeError   type   is   used   to   indicate   system   errors.   These   user-defined   objects   are   no   different   from   any   other   nonvisual   user   object   in   the   system.   They   can   contain   events,   functions,   and   instance   variables.    
   
  This   is   useful,   for   example,   in   cases   where   a   specific   condition,   such   as   the   failure   of   a   business   rule,   might   cause   application   logic   to   fail.   If   you   create   a   user-defined   exception   type   to   describe   such   a   condition   and   then   catch   and   handle   the   exception   appropriately,   you   can   prevent   a   runtime   error.    
   
  Throwing   exceptions  
  Exceptions   can   be   thrown   by   the   runtime   engine   to   indicate   an   error   condition.   If   you   want   to   signal   a   potential   exception   condition   manually,   you   must   use   the   THROW   statement.    
   
  Typically,   the   THROW   statement   is   used   in   conjunction   with   some   user-defined   exception   type.   Here   is   a   simple   example   of   the   use   of   the   THROW   statement:  
   
   
  Exception         le_ex   le_ex   =   create   Exception   Throw   le_ex   MessageBox   ("Hmm",   "We   would   never   get   here   if"   &               +   "the   exception   variable   was   not   instantiated")  
   
  In   this   example,   the   code   throws   the   instance   of   the   exception   le_ex.   The   variable   following   the   THROW   reserved   word   must   point   to   a   valid   instance   of   the   exception   object   that   derives   from   Throwable.   If   you   attempt   to   throw   an   uninstantiated   Exception   variable,   a   NullObjectError   is   thrown   instead,   indicating   a   null   object   reference   in   this   routine.   That   could   only   complicate   the   error   handling   for   your   application.  
   
  Declaring   exceptions   thrown   from   functions  
  If   you   signal   an   exception   with   the   THROW   statement   inside   a   method   script--and   do   not   surround   the   statement   with   a   try-catch   block   that   can   deal   with   that   type   of   exception--you   must   also   declare   the   exception   as   an   exception   type   (or   as   a   descendant   of   an   exception   type)   thrown   by   that   method.   However,   you   do   not   need   to   declare   that   a   method   can   throw   runtime   errors,   since   PowerBuilder   does   that   for   you.  
   
  The   prototype   window   in   the   Script   view   of   most   PowerBuilder   painters   allows   you   to   declare   what   user-defined   exceptions,   if   any,   can   be   thrown   by   a   function   or   a   user-defined   event.   You   can   drag   and   drop   exception   types   from   the   System   Tree   or   a   Library   painter   view   to   the   Throws   box   in   the   prototype   window,   or   you   can   type   in   a   comma-separated   list   of   the   exception   types   that   the   method   can   throw.    
   
  Example  
  Example   catching   a   user-defined   exception   This   code   displays   a   user-defined   error   when   an   arccosine   argument,   entered   by   the   application   user,   is   not   in   the   required   range.   The   try-catch   block   calls   a   method,   wf_acos,   that   catches   the   system   error   and   sets   and   throws   the   user-defined   error:  
   
   
   
  TRY               wf_acos()   CATCH   (uo_exception   u_ex)               MessageBox("Out   of   Range",   u_ex.GetMessage())   END   TRY  
   
  This   code   in   the   wf_acos   method   catches   the   system   error   and   sets   and   throws   the   user-defined   error:  
   
   
   
  uo_exception   lu_error   Double   ld_num   ld_num   =   Double   (sle_1.text)   TRY         sle_2.text   =   string   (acos   (ld_num))   CATCH   (runtimeerror   er)               lu_error   =   Create   uo_exception         lu_error.SetMessage("Value   must   be   between   -1"   &               +   "and   1")         Throw   lu_error   END   TRY  
   
  Integration   with   EAServer  
  If   you   declare   exceptions   on   a   method   of   a   user   object   and   deploy   the   user   object   as   a   component   to   EAServer,   the   exceptions   are   translated   to   IDL   (CORBA)   as   part   of   the   method   prototype.   This   means   that   PowerBuilder   components   in   EAServer   can   be   defined   to   throw   exceptions   that   can   be   handled   by   any   type   of   EAServer   client   application.    
   
  Other   benefits   for   EAServer   applications   Another   benefit   for   component   development   is   that   you   can   handle   runtime   errors   in   the   component.   If   you   do   not   handle   an   error,   it   is   automatically   translated   into   an   exception   and   the   component   stops   executing.    
   
  PowerBuilder   client   applications   that   use   EAServer   components   can   handle   exceptions   thrown   by   any   type   of   EAServer   component.   If   a   Java   EAServer   component   has   a   method   on   it   that   is   defined   to   throw   an   exception   and   a   PowerBuilder   proxy   is   created   to   use   that   component,   the   method   on   the   PowerBuilder   proxy   is   also   declared   to   throw   a   user-defined   exception.   The   definition   of   the   user-defined   exception   is   created   automatically   at   the   time   of   the   PowerBuilder   proxy   creation.  
   
  For   more   information   about   error   handling   in   EAServer   clients,   see   "Handling   errors   ".  
   
  IDL   restrictions   Deployment   of   components   to   EAServer   imposes   restrictions   on   the   way   you   can   use   exception   handling   within   PowerBuilder.   Only   the   public   instance   variables   defined   on   the   exception   type   are   actually   translated   to   IDL.   This   is   because   IDL   exceptions   cannot   have   methods   declared   on   them.   Therefore   if   the   exception   type   has   methods   defined   on   it,   those   methods   can   be   called   within   the   execution   of   the   component   but   cannot   be   called   by   client   applications   that   catch   the   exception   thrown.    
   
  You   must   keep   this   restriction   in   mind   when   designing   exception   objects   for   distributed   applications,   exposing   all   exception   information   as   public   instance   variables   instead   of   through   accessor   methods   on   an   exception   object.    
   
  Two   other   interface   restrictions   also   apply   to   exception   types   of   a   user   object   that   is   deployed   as   an   EAServer   component.   Instance   variables   of   exceptions   on   the   user   object   methods   cannot   have   object   datatypes.   Null   data   is   supported   only   for   instance   variables   with   simple   datatypes;   if   instance   variables   are   structures   or   arrays,   null   values   for   individual   elements   are   not   maintained.  
   
  Top

6 楼windyman518(风一样的男子)回复于 2005-06-08 04:30:25 得分 0

一直忙,现在结贴.Top

相关问题

  • 帮我修改一段中英文翻译好吗?
  • 帮我修改一段中英文翻译好吗?
  • 求asp外文翻译,中英文对照的。
  • 请问那里有网页浏揽的翻译软件(中英文)?
  • 高分求救,谁有中英文资料翻译(5000字以上)发给我?
  • 求一篇关于sql数据库的中英文翻译!谢谢
  • 共享(如何在PB中切换中英文输入法数)
  • 谁有关于PB的中英文对照资料?
  • 求一篇关于数据传输加密解密技术的中英文翻译
  • 急求一篇关于sql数据库开发的中英文翻译文章!谢谢!不甚感激!!

关键词

  • powerbuilder
  • runtime
  • component
  • anywhere
  • pb
  • clause
  • runtimeerror
  • exceptions
  • thrown
  • easerver

得分解答快速导航

  • 帖主:windyman518
  • njupt_zhb

相关链接

  • PowerBuilder类图书
  • PowerBuilder类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo