1.delphi中常用内部函数有哪些?包括1.返回指定字符串的第i位字符值的函数2.查找指定字符串是否存在某一个字符的查找函数3.代替指定字符串中指定位字符的替换函数,也就是说字符串操作函数
2.为什么我用showmessage(length(edit.1.text));得不到答案,程序报错
3.用openDialog读取某一个txt文件时,如何先读到一个字符型变量中,处理后再显示在memo中
4.请给出application.message得详细参数,如何在memo中显示程序运行时所在的目录
5.如何判断指定目录下某一个文件是否存在以及如何对它进行操作(复制,删除)

解决方案 »

  1.   

    我KAO,你这灌水也太猛了吧,
    1.1 str[i]就是返回字符串第I位的值
    1.2 and 1.3自己查DELPHI
    2 showmessage(inttostr(length(edit1.text)));
    3 filename:=opendialog.filename;
      memo.loadfromfile(filename);
    4. 你是问APPLICATION中的MESSAGEBOX还是MESSAGE?
    Message contains the text string to display in the exception dialog box when the exception is raised.property Message: stringDescriptionMessage stores the error-message string to display when the exception is raised. All Exception constructors expect a string parameter to store in Message. Message text can be hard-coded as a parameter to an Exception constructor, created as dynamic parameter, or loaded from a resource file as a static or dynamically formatted parameter.
      

  2.   

    5,好象是OPFILEOPRATION还是什么东东,忘了
      

  3.   

    uses ShellAPI
    var
      p:_shfileopstruct;
      a:integer;
    begin
      p.Wnd:=handle;
      p.wFunc:=FO_delete;
      p.pFrom:='f:\test'#0#0;  //删除f盘的test文件夹
      p.pTo:=nil;
      p.fFlags:=fof_noconfirmation;
      p.fAnyOperationsAborted:=true;
      a:=shfileoperation(p);
    end;
    其实都是用上边这个API,其它操作是DELPHI封装了的
    Removedir只能删除空文件夹的。
    Delphi提供了关于文件操作的许多函数,其中关于目录操作的有目录的创建与删除、设置当前目录、获取当前目录等。目录的删除有函数(Function)RemoveDir和过程(Procedure)RmDir,但它们都只能删除空目录,对于非空目录则不能删除。要实现删除整个目录树(DelTree)必须编写程序来删除其中的子目录和文件。   目录中的文件可以通过调用函数DeleteFile来删除,但对于特殊文件(只读、系统、隐藏等)则不能有效删除,必须更改文件属性为普通文件才能删除。更改文件属性可以用函数FileSetAttr,这里将特殊文件的属性设置为普通文件属性(属性值为0)。   考虑到树型目录结构最适合于递归方法,所有这里用递归算法来实现DelTree函数。下面是具体实现程序。   //path是需删除的目录路径   //目录成功删除返回True,否则返回False   function TForm1.Deltree (path : string): Boolean ;   var    SearchRec: TSearchRec;   begin   //判断目录是否存在 if DirectoryExists(path) then begin   //进入该目录,删除其中的子目录和文件    oldDir := GetCurrentDir;    ChDir(path);   //查找目录中所有任何文件   FindFirst(′.′, faAnyFile, SearchRec);   repeat   //修改文件属性为普通属性值    FileSetAttr(SearchRec.Name,0);   //如果是目录并且不是.和..则递归调用DelTree   if(SearchRec.Attr and faDirectory >  0) then   begin   if(SearchRec.Name[1]< > ′.′) then   if(not Deltree(SearchRec.Name)) then   break;   end   //如果是文件直接删除   else   if(not DeleteFile(SearchRec.Name))then   break ;   //继续查找,直到最后   until (FindNext(SearchRec)< > 0) ;   //回到父目录,删除该目录   ChDir(′..′);   Result := ReMoveDir(path); SetCurrentDir(oldDir);   end   else   Result := False ;   end ; 
      

  4.   

    1、SetString:='30234';
       length(SetString);
       Getstring:=Setstring[i];
    2、showmessage(length(edit.1.text));
    3、filename:=opendialog.filename;
       memo1.loadfromfile(filename);
    4、获得目录:extractfilepath(paramstr(0));
    5、if fileexists('c:\a.txt') then
       copyfile('c:\a.txt','extractfilepath(paramstr(0))+a.txt',true);
      //复制文件到程序所在目录
      

  5.   

    1.delphi中常用内部函数有哪些?包括
      1.返回指定字符串的第i位字符值的函数
      答:直接用字符串名称加索引,例如Str[I];
      2.查找指定字符串是否存在某一个字符的查找函数
      答:Pos函数 
      3.代替指定字符串中指定位字符的替换函数,也就是说字符串操作函数
      答:Concat函数和Copy函数联合使用2.为什么我用showmessage(length(edit.1.text));得不到答案,程序报错
    答:ShowMessage(Length(Edit1.Text));3.用openDialog读取某一个txt文件时,如何先读到一个字符型变量中,处理后再显示在memo中
    答:代码如下:我已经是第三次给你代码了!
    var
      fContent:TStringList;
    begin
      fContent:=TStringList.Create;
      with fContent do 
      begin
        fContent.LoadFromFile(OpenDialog1.FileName);
        Memo1.Lines:=fContent;
        Free;
      end;
    end;4.请给出application.message得详细参数,如何在memo中显示程序运行时所在的目录
    答:是MessageBox方法吧:function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer;
    Text表示显示信息框中的文本内容
    Caption表示显示信息框的标题
    Flags表示显示信息框的按钮(类型)用ExeName属性
    5.如何判断指定目录下某一个文件是否存在以及如何对它进行操作(复制,删除)
    答:用FileExists函数来判断
    删除用DeleteFile函数
    复制方法很多,自己查查吧!
      

  6.   

    对,复制可以使用API函数CopyFile!--------------------------------------------------------------------另外,楼主,照你这个样子,写完一个程序,你的可用分就全光了!
      

  7.   

    楼主也真是要自己多检查呀
    像: showmessage(length(edit.1.text)) 一样
    只要自己仔细看一下就行了...楼上说的也真不错
      

  8.   

    1.s[i]为字符串s的第i个字符 .
      Pos('s',string1)如果返回的值大于0则说明在STRING1中含有字符's'。
      StringReplace(stirng1,'aab','aac', [rfReplaceAll])
      在string1中aab替换为aac,stringreplace的返回值为你要的.
    其他你想知道的别人已经回答了!
      

  9.   

    好方法!StringReplace,这个函数俺可是还是头一次见啊!
      

  10.   

    StringReplace function-----------------------------------------------------------------------Returns a string with occurrences of one substring replaced by another substring.UnitSysUtilsCategorystring handling routinesDelphi syntax:function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;C++ syntax:extern PACKAGE AnsiString __fastcall StringReplace(const AnsiString S, const AnsiString OldPattern, const AnsiString NewPattern, TReplaceFlags Flags);DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string may contain Multibyte characters.S is the source string, whose substrings are changed.OldPattern is the substring to locate and replace with NewPattern.NewPattern is the substring to substitute for occurrences of OldPattern.Flags is a set of flags that govern how StringReplace locates and replaces occurrences of OldPattern. If Flags does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, StringReplace replaces all instances of OldPattern with NewPattern. If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
      

  11.   

    StringReplace function-----------------------------------------------------------------------Returns a string with occurrences of one substring replaced by another substring.UnitSysUtilsCategorystring handling routinesDelphi syntax:function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;C++ syntax:extern PACKAGE AnsiString __fastcall StringReplace(const AnsiString S, const AnsiString OldPattern, const AnsiString NewPattern, TReplaceFlags Flags);DescriptionStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string may contain Multibyte characters.S is the source string, whose substrings are changed.OldPattern is the substring to locate and replace with NewPattern.NewPattern is the substring to substitute for occurrences of OldPattern.Flags is a set of flags that govern how StringReplace locates and replaces occurrences of OldPattern. If Flags does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, StringReplace replaces all instances of OldPattern with NewPattern. If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.