在同一目录下有这样一个pas文件(test.pas):unit test;interfaceimplementationfunction MyTest(text:string):string;
begin
 Result:=text;
end;end.
(不知道这样写有没有什么语法错误?)然后,我在一个工程中这样引用它:................
implementation
uses test;
.................之后,使用 MyTest() 函数就提示:
  [Error] Unit1.pas(31): Undeclared identifier: 'MyTest'
  [Fatal Error] Project1.dpr(7): Could not compile used unit 'Unit1.pas'或改成:................
interface
uses test;
.................也是同样的提示!怎么办呢?那为什么默认的 Windows,Message 等单元 Delphi 都通过,而我的单元却提示未申明???

解决方案 »

  1.   

    用菜单项project => Add to Project ..选择你要的pas文件,OK了
      

  2.   

    unit test;interface
    function MyTest(text:string):string;
    implementationfunction MyTest(text:string):string;
    begin
     Result:=text;
    end;
      

  3.   

    用菜单项project => Add to Project ..选择你要的pas文件;
    还有就是
    在interface处定义你的函数 function MyTest(text:string):string;
      

  4.   

    你要再pas单元中输出的函数过程一定要在interface中声明,才能在其他单元或程序中什用