unit clsMessage;interfaceresourceString
  rsAddSuccess='Add record successfully';
  rsAddError='This record already exists';
  rsEditSuccess='Edit record successfully';
  rsDelete='Do you really want to delete this record?';
  rsDgBuilder='Builder';
  rsDgBuildDate='Build Date';
  rsDgReviser='Reviser';
  rsDgReviseDate='Revise Date';  rsshowAdd='Add New';
  rsshowEdit='Edit';  //Case Setup
  rsCaseSetupmgInput='Please input ';
  rsCaseSetupmgComfirmDelete='Delete this record will delete all records for this case in Table Case Relation.'; implementationend.谁能解释下为什么这样用,这样用有什么好处.在其他单元如何调用上面的resourceString

解决方案 »

  1.   

    1.这样是将字符串定义成资源串,可以进行共享,并且也可以方便修改,特别是进行多语言编程环境切换。如果你直接写死这些信息,那么要修改就很麻烦,即便是使用const也仍然需要重新编译程序才可以,而放到资源当中,可以使用资源编辑工具进行直接修改。
    其他单元要使用的话,直接uses该单元即可,比如uses consts,uses RTLConsts等。
      

  2.   

    跟cosnt定义的常量意思基本一样Resource strings are stored as resources and linked into the executable or library so that they can be modified without recompiling the program. For more information, see 
    Internationalization and localization and the topics that follow it.Resource strings are declared like other true constants, except that the word const is replaced by resourcestring. The expression to the right of the = symbol must be a constant expression and must return a string value. For example,resourcestring
      CreateError = 'Cannot create file %s';        {  for explanations of format specifiers, }
      OpenError = 'Cannot open file %s';            { see 'Format strings' in the online Help }
      LineTooLong = 'Line too long';
      ProductName = 'Borland Rocks';
      SomeResourceString = SomeTrueConstant;