【字符串函数大全】
首部function AnsiResemblesText(const AText, AOther: string): Boolean;
$[StrUtils.pas
功能返回两个字符串是否相似
说明ANSI(American National Standards Institute)美国国家标准协会;不区分大小写参考function StrUtils.SoundexProc; var StrUtils.AnsiResemblesProc
例子CheckBox1.Checked := AnsiResemblesText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiContainsText(const AText, ASubText: string): Boolean;
$[StrUtils.pas
功能返回字符串AText是否包含子串ASubText
说明不区分大小写
参考function StrUtils.AnsiUppercase; function StrUtils.AnsiPos
例子CheckBox1.Checked := AnsiContainsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiStartsText(const ASubText, AText: string): Boolean;
$[StrUtils.pas
功能返回字符串AText是否以子串ASubText开头
说明不区分大小写
参考function https://www.doczj.com/doc/262342304.html,pareString
例子CheckBox1.Checked := AnsiStartsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiEndsText(const ASubText, AText: string): Boolean;
$[StrUtils.pas
功能返回字符串AText是否以子串ASubText结尾
说明不区分大小写
参考function https://www.doczj.com/doc/262342304.html,pareString
例子CheckBox1.Checked := AnsiEndsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiReplaceText(const AText, AFromText, AToText: string):
string; $[StrUtils.pas
功能返回字符串AText中用子串AFromText替换成子串AToText的结果
说明不区分大小写
参考function SysUtils.StringReplace; type SysUtils.TReplaceFlags
例子Edit4.Text := AnsiReplaceText(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiMatchText(const AText: string; const AValues: array of string): Boolean; $[StrUtils.pas
功能返回字符串数组AValues中是否包含字符串AText
说明不区分大小写
参考function StrUtils.AnsiIndexText
例子CheckBox1.Checked := AnsiMatchText(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiIndexText(const AText: string; const AValues: array of string): Integer; $[StrUtils.pas
功能返回字符串AText在字符串数组AValues中的位置
说明不区分大小写;如果不包含则返回-1
参考function SysUtils.AnsiSameText
例子SpinEdit1.Value := AnsiIndexText(Edit1.Text, ['a1', 'a2', 'a3', 'a4']); ━━━━━━━━━━━━━━━━━━━━━
首部function AnsiContainsStr(const AText, ASubText: string): Boolean; $[StrUtils.pas
功能返回字符串AText是否包含子串ASubText
说明区分大小写
参考function StrUtils.AnsiPos
例子CheckBox1.Checked := AnsiContainsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiStartsStr(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能返回字符串AText是否以子串ASubText开头
说明区分大小写
参考function SysUtils.AnsiSameStr
例子CheckBox1.Checked := AnsiStartsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiEndsStr(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能返回字符串AText是否以子串ASubText结尾
说明区分大小写
参考function SysUtils.AnsiSameStr
例子CheckBox1.Checked := AnsiEndsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiReplaceStr(const AText, AFromText, AToText: string): string; $[StrUtils.pas
功能返回字符串AText中用子串AFromText替换成子串AToText的结果说明区分大小写
参考function SysUtils.StringReplace; type SysUtils.TReplaceFlags
例子Edit4.Text := AnsiReplaceStr(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiMatchStr(const AText: string; const AValues: array of string): Boolean; $[StrUtils.pas
功能返回字符串数组AValues中是否包含字符串AText
说明区分大小写
参考function StrUtils.AnsiIndexStr
例子CheckBox1.Checked := AnsiMatchStr(Edit1.Text, ['a1', 'a2', 'a3',
'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部function AnsiIndexStr(const AText: string; const AValues: array of string): Integer; $[StrUtils.pas
功能返回字符串AText在字符串数组AValues中的位置
说明区分大小写
参考function SysUtils.AnsiSameStr
例子SpinEdit1.Value := AnsiIndexStr(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部function DupeString(const AText: string; ACount: Integer): string;
$[StrUtils.pas
功能返回字符串AText的ACount个复本
说明当ACount为0时返回''
参考function System.SetLength
例子Edit3.Text := DupeString(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function ReverseString(const AText: string): string; $[StrUtils.pas 功能返回字符串AText的反序
说明ReverseString('1234') = '4321'
参考function System.SetLength
例子Edit3.Text := ReverseString(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function StuffString(const AText: string; AStart, ALength: Cardinal;
const ASubText: string): string; $[StrUtils.pas
功能返回嵌套字符串
说明AStart:嵌套开始位置;ALength:嵌套长度;StuffString('abcd', 2, 0, '12') = 'a12bcd' 参考function System.Copy
例子Edit3.Text := StuffString(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value,
Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function RandomFrom(const AValues: array of string): string; overload; $[StrUtils.pas
功能随机返回字符串数组AValues中的一个元素
说明之前建议执行Randomize
参考function System.Random
例子Randomize; Edit3.Text := RandomFrom(['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部function IfThen(AValue: Boolean; const ATrue: string; AFalse: string =
''): string; overload; $[StrUtils.pas
功能返回指定的逻辑字符串
说明IfThen(True, '是', '否') = '是';IfThen(False, '是', '否') = '否'
参考
例子Edit3.Text := IfThen(CheckBox1.Checked, Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function LeftStr(const AText: string; const ACount: Integer): string; $[StrUtils.pas
功能返回字符串AText左边的ACount个字符
说明LeftStr('123456', 3) = '123'
参考function System.Copy
例子Edit3.Text := LeftStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function RightStr(const AText: string; const ACount: Integer): string; $[StrUtils.pas
功能返回字符串AText右边的ACount个字符
说明RightStr('123456', 3) = '456'
参考function System.Copy
例子Edit3.Text := RightStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function MidStr(const AText: string; const AStart, ACount: Integer): string; $[StrUtils.pas
功能返回字符串AText从AStart开始的ACount个字符
说明其实就是Copy
参考function System.Copy
例子Edit3.Text := MidStr(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SearchBuf(Buf: PChar; BufLen: Integer; SelStart, SelLength: Integer; SearchString: String; Options: TStringSearchOptions = [soDown]): PChar; $[StrUtils.pas
功能返回第一个搜索到的指针位置
说明这函数常用于文本中搜索字符串
参考
例子
///////Begin SearchBuf
function SearchEdit(EditControl: TCustomEdit; const SearchString: String; SearchOptions: TStringSearchOptions; FindFirst: Boolean = False): Boolean; var
Buffer, P: PChar;
Size: Word;
begin
Result := False;
if (Length(SearchString) = 0) then Exit;
Size := EditControl.GetTextLen;
if (Size = 0) then Exit;
Buffer := StrAlloc(Size + 1);
try
EditControl.GetTextBuf(Buffer, Size + 1);
P := SearchBuf(Buffer, Size, EditControl.SelStart, EditControl.SelLength, SearchString, SearchOptions);
if P <> nil then begin
EditControl.SelStart := P - Buffer;
EditControl.SelLength := Length(SearchString);
Result := True;
end;
finally
StrDispose(Buffer);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SearchOptions: TStringSearchOptions;
begin
SearchOptions := [];
if CheckBox1.Checked then
Include(SearchOptions, soDown);
if CheckBox2.Checked then
Include(SearchOptions, soMatchCase);
if CheckBox3.Checked then
Include(SearchOptions, soWholeWord);
SearchEdit(Memo1, Edit1.Text, SearchOptions);
Memo1.SetFocus;
end;
///////End SearchBuf
━━━━━━━━━━━━━━━━━━━━━
首部function Soundex(const AText: string; ALength: TSoundexLength = 4): string; $[StrUtils.pas
功能返回探测字符串
说明根据探测法(Soundex)可以找到相进的字符
串;https://www.doczj.com/doc/262342304.html,/genealogy/coding.html
参考
例子Edit2.Text := Soundex(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexInt(const AText: string; ALength: TSoundexIntLength =
4): Integer; $[StrUtils.pas
功能返回探测整数
说明ALength的值越大解码准确率越高
参考
例子SpinEdit2.Value := SoundexInt(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function DecodeSoundexInt(AValue: Integer): string; $[StrUtils.pas
功能返回探测整数的解码
说明DecodeSoundexInt(SoundexInt('hello')) 相当于Soundex('hello')
参考
例子Edit2.Text := DecodeSoundexInt(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexWord(const AText: string): Word; $[StrUtils.pas
功能返回探测文字数值
说明没有参数ALength已经固定为4
参考
例子SpinEdit2.Value := SoundexWord(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function DecodeSoundexWord(AValue: Word): string; $[StrUtils.pas
功能返回探测文字数值的解码
说明DecodeSoundexWord(SoundexWord('hello')) 相当于Soundex('hello') 参考
例子Edit2.Text := DecodeSoundexWord(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexSimilar(const AText, AOther: string; ALength: TSoundexLength = 4): Boolean; $[StrUtils.pas
功能返回两个字符串的探测字符串是否相同
说明Result := Soundex(AText, ALength) = Soundex(AOther, ALength)
参考
例子CheckBox1.Checked := SoundexSimilar(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexCompare(const AText, AOther: string; ALength: TSoundexLength = 4): Integer; $[StrUtils.pas
功能返回比较两个字符串的探测字符串的结果
说明Result := AnsiCompareStr(Soundex(AText, ALength), Soundex(AOther, ALength))
参考function SysUtils.AnsiCompareStr
例子SpinEdit2.Value := SoundexCompare(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexProc(const AText, AOther: string): Boolean; $[StrUtils.pas
功能调用SoundexSimilar返回两个字符串的探测字符串是否相同
说明系统变量AnsiResemblesProc的默认值
参考function StrUtils.AnsiResemblesText
例子[var AnsiResemblesProc: TCompareTextProc = SoundexProc;]
━━━━━━━━━━━━━━━━━━━━━
首部function NewStr(const S: string): PString; deprecated; $[SysUtils.pas 功能返回一个新的字符串指针地址
说明字符串S为空时返回NullStr
参考procedure System.New
例子
////////Begin NewStr,DisposeStr
procedure TForm1.Button1Click(Sender: TObject);
var
P: PString;
begin
P := NewStr(Edit1.Text);
Edit2.Text := P^;
DisposeStr(P);
end;
////////End NewStr,DisposeStr
━━━━━━━━━━━━━━━━━━━━━
首部procedure DisposeStr(P: PString); deprecated; $[SysUtils.pas
功能释放字符串指针P资源
说明配合函数NewStr使用
参考procedure System.Dispose
例子<如上参见,如下参见>
━━━━━━━━━━━━━━━━━━━━━
首部procedure AssignStr(var P: PString; const S: string); deprecated; $[SysUtils.pas
功能将字符串S更新给字符串指针P
说明更新值时会释放以前字符串指针的资源
参考function SysUtils.NewStr;function SysUtils.DisposeStr
例子
////////Begin AssignStr
procedure TForm1.Button1Click(Sender: TObject);
var
P: PString;
begin
P := nil;
AssignStr(P, Edit1.Text);
Edit2.Text := P^;
DisposeStr(P);
end;
////////End AssignStr
━━━━━━━━━━━━━━━━━━━━━
首部procedure AppendStr(var Dest: string; const S: string); deprecated; $[SysUtils.pas
功能在字符串Dest后追加字符串S
说明相当于Dest := Dest + S;Delphi6已经不建议使用
参考
例子
////////Begin AppendStr
procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
begin
S := Edit2.Text;
AppendStr(S, Edit1.Text);
Edit2.Text := S;
end;
////////End AppendStr
━━━━━━━━━━━━━━━━━━━━━
首部function UpperCase(const S: string): string; $[SysUtils.pas
功能返回字符串S的大写形式
说明非小写字符不处理
参考procedure System.SetLength
例子Edit2.Text := UpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function LowerCase(const S: string): string; $[SysUtils.pas
功能返回字符串S的小写形式
说明非大写字符不处理
参考procedure System.SetLength
例子Edit2.Text := LowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function CompareStr(const S1, S2: string): Integer; $[SysUtils.pas
功能返回比较两个字符
说明当S1>S2返回值>0;当S1 参考 例子SpinEdit1.Value := CompareStr(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function CompareMem(P1, P2: Pointer; Length: Integer): Boolean; assembler; $[SysUtils.pas 功能返回比较两个内存指针 说明CompareMem(PChar('12a'), PChar('12c'), 2)=True;CompareMem(PChar('12a'), PChar('12c'), 3)=False 参考 例子CheckBox1.Checked := CompareMem(Self, Form1, 8); ━━━━━━━━━━━━━━━━━━━━━ 首部function CompareText(const S1, S2: string): Integer; $[SysUtils.pas 功能返回比较两个字符串 说明不区分大小写 参考 例子SpinEdit1.Value := CompareText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function SameText(const S1, S2: string): Boolean; $[SysUtils.pas 功能返回两个字符串是否相等 说明不区分大小写 参考 例子CheckBox1.Checked := SameText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiUpperCase(const S: string): string; $[SysUtils.pas 功能返回字符串S的大写形式 说明ANSI(American National Standards Institute)美国国家标准协会;非小写的字符不变 参考function Windows.CharUpperBuff 例子Edit2.Text := AnsiUpperCase(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiLowerCase(const S: string): string; $[SysUtils.pas 功能返回字符串S的小写形式 说明非大写字符不处理 参考function Windows.CharLowerBuff 例子Edit2.Text := AnsiLowerCase(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiCompareStr(const S1, S2: string): Integer; $[SysUtils.pas 功能反回比较两个字符串 说明当S1>S2返回值>0;当S1 参考function https://www.doczj.com/doc/262342304.html,pareString 例子SpinEdit1.Value := AnsiCompareStr(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiSameStr(const S1, S2: string): Boolean; $[SysUtils.pas 功能返回两个字符串是否相等 说明区分大小写 参考function SysUtils.AnsiCompareStr 例子CheckBox1.Checked := AnsiSameStr(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiCompareText(const S1, S2: string): Integer; $[SysUtils.pas 功能反回比较两个字符串 说明当S1>S2返回值>0;当S1 参考function https://www.doczj.com/doc/262342304.html,pareString 例子SpinEdit1.Value := AnsiCompareText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiSameText(const S1, S2: string): Boolean; $[SysUtils.pas 功能返回两个字符串是否相等 说明不区分大小写 参考function SysUtils.AnsiCompareText 例子CheckBox1.Checked := AnsiSameText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrComp(S1, S2: PChar): Integer; $[SysUtils.pas 功能返回比较两个指针字符串 说明当S1>S2返回值>0;当S1 例子SpinEdit1.Value := AnsiStrComp(PChar(Edit1.Text), PChar(Edit2.Text)) ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrIComp(S1, S2: PChar): Integer; $[SysUtils.pas 功能返回比较两个指针字符串 说明当S1>S2返回值>0;当S1 参考function https://www.doczj.com/doc/262342304.html,pareString 例子SpinEdit1.Value := AnsiStrIComp(PChar(Edit1.Text), PChar(Edit2.Text)) ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer; $[SysUtils.pas 功能返回比较两个指针字符串指定长度 说明当S1>S2返回值>0;当S1 参考function https://www.doczj.com/doc/262342304.html,pareString 例子SpinEdit1.Value := AnsiStrLComp(PChar(Edit1.Text), PChar(Edit2.Text), SpinEdit2.Value) ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer; $[SysUtils.pas 功能返回比较两个指针字符串指定长度 说明当S1>S2返回值>0;当S1 例子SpinEdit1.Value := AnsiStrLIComp(PChar(Edit1.Text), PChar(Edit2.Text), SpinEdit2.Value) ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrLower(Str: PChar): PChar; $[SysUtils.pas 功能返回指针字符串小写形式 说明非大写字符不处理 参考function Windows.CharLower 例子Edit2.Text := AnsiStrLower(PChar(Edit1.Text)); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrUpper(Str: PChar): PChar; $[SysUtils.pas 功能返回指针字符串大写形式 说明非小写字符不处理 参考function Windows.CharUpper 例子Edit2.Text := AnsiStrUpper(PChar(Edit1.Text)); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiLastChar(const S: string): PChar; $[SysUtils.pas 功能返回字符串S的最后一个指针字符 说明当字符串S为空串则返回空指针 参考function SysUtils.ByteType 例子Edit2.Text := AnsiLastChar(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiStrLastChar(P: PChar): PChar; $[SysUtils.pas 功能返回指针字符串P的最后一个指针字符 说明当字符串P为空空指针则返回空指针 参考function SysUtils.ByteType 例子Edit2.Text := AnsiLastChar(PChar(Edit1.Text)); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideUpperCase(const S: WideString): WideString; $[SysUtils.pas 功能返回双字节字符串的大写形式 说明WideChar双字节字符 参考function Windows.CharUpperBuffW 例子Edit2.Text := WideUpperCase(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideLowerCase(const S: WideString): WideString; $[SysUtils.pas 功能返回双字节字符串的小写形式 说明我怎么就测试不出来呢 参考function Windows.CharLowerBuffW 例子Edit2.Text := WideLowerCase(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideCompareStr(const S1, S2: WideString): Integer; $[SysUtils.pas 功能返回比较两个双字节字符串 说明当S1>S2返回值>0;当S1 例子SpinEdit1.Value := WideCompareStr(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideSameStr(const S1, S2: WideString): Boolean; $[SysUtils.pas 功能返回两个双字节字符串是否相同 说明区分大小写 参考function SysUtils.WideCompareStr 例子CheckBox1.Checked := WideSameStr(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideCompareText(const S1, S2: WideString): Integer; $[SysUtils.pas 功能返回比较两个双字节字符串 说明当S1>S2返回值>0;当S1 例子SpinEdit1.Value := WideCompareText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function WideSameText(const S1, S2: WideString): Boolean; $[SysUtils.pas 功能返回两个双字节字符串是否相同 说明不区分大小写 参考function SysUtils.WideCompareText 例子CheckBox1.Checked := WideSameText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function Trim(const S: string): string; overload; $[SysUtils.pas 首部function Trim(const S: WideString): WideString; overload; $[SysUtils.pas 功能返回除去字符串S左右不可见字符 说明小于#32的字符看作不可见字符 参考function System.Copy 例子Edit2.Text := Trim(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function TrimLeft(const S: string): string; overload; $[SysUtils.pas 首部function TrimLeft(const S: WideString): WideString; overload; $[SysUtils.pas 功能返回除去字符串S左边不可见字符 说明小于#32的字符看作不可见字符 参考function System.Copy 例子Edit2.Text := TrimLeft(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function TrimRight(const S: string): string; overload; $[SysUtils.pas 首部function TrimRight(const S: WideString): WideString; overload; $[SysUtils.pas 功能返回除去字符串S右边不可见字符 说明小于#32的字符看作不可见字符 参考function System.Copy 例子Edit2.Text := TrimRight(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function QuotedStr(const S: string): string; $[SysUtils.pas 功能返回字符串S在pascal中的表现形式 说明单引号中的一个单引号将转成两个 参考procedure System.Insert 例子Edit2.Text := QuotedStr(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiQuotedStr(const S: string; Quote: Char): string; $[SysUtils.pas 功能返回字符串S以字符Quote为引号的表现形式 说明AnsiQuotedStr('hello"world', '@')='@hello"world@';AnsiQuotedStr('hello"world', '"')='"hello""world"' 参考function SysUtils.AnsiStrScan 例子Edit2.Text := AnsiQuotedStr(Edit1.Text, '"'); ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string; $[SysUtils.pas 功能返回以字符Quote为引号的表现形式原形 说明表现形式非法时Src不变否则为空 参考function SysUtils.AnsiStrScan 例子 ///////Begin AnsiExtractQuotedStr procedure TForm1.Button1Click(Sender: TObject); var P: PChar; begin P := PChar(Edit1.Text); Edit2.Text := AnsiExtractQuotedStr(P, '"'); Edit3.Text := P; end; ///////End AnsiExtractQuotedStr ━━━━━━━━━━━━━━━━━━━━━ 首部function AnsiDequotedStr(const S: string; AQuote: Char): string; $[SysUtils.pas 功能返回以字符AQuote为引号的表现形式原形 说明表现形式非法时则返回S 参考function SysUtils.AnsiExtractQuotedStr 例子Edit2.Text := AnsiDequotedStr(Edit1.Text, '"'); ━━━━━━━━━━━━━━━━━━━━━ 首部function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle = {$IFDEF LINUX} tlbsLF {$ENDIF} {$IFDEF MSWINDOWS} tlbsCRLF {$ENDIF}): string; $[SysUtils.pas 功能返回将给定字符串的行分隔符调整为CR/LF序列 说明 AdjustLineBreaks('1'#13'2'#13)='1'#13#10'2'#13#10;AdjustLineBreaks('1'#10'2'#10)=' 1'#13#10'2'#13#10 参考function SysUtils.StrNextChar 例子 ━━━━━━━━━━━━━━━━━━━━━ 首部function IsValidIdent(const Ident: string): Boolean; $[SysUtils.pas 功能返回字符串Ident是否是正确的标识符 说明标识符::字母|下划线[字母|下划线|数字]... 参考 例子CheckBox1.Checked := IsValidIdent(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function IntToStr(Value: Integer): string; overload; $[SysUtils.pas 首部function IntToStr(Value: Int64): string; overload; $[SysUtils.pas 功能返回整数Value转换成字符串 说明Format('%d', [Value]) 参考function SysUtils.FmtStr 例子Edit2.Text := IntToStr(SpinEdit1.Value); ━━━━━━━━━━━━━━━━━━━━━ 首部function IntToHex(Value: Integer; Digits: Integer): string; overload; $[SysUtils.pas 首部function IntToHex(Value: Int64; Digits: Integer): string; overload; $[SysUtils.pas 功能返回整数Value转换成十六进制表现结果;Format('%.*x', [Digits, Value]) 说明参数Digits指定字符最小宽度;最小宽度不足时将用0填充 参考function SysUtils.FmtStr 例子Edit2.Text := IntToHex(SpinEdit1.Value, SpinEdit2.Value); ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToInt(const S: string): Integer; $[SysUtils.pas 功能返回字符串S转换成整数 说明字符串非整数表达时将引起异常 参考procedure System.Val 例子SpinEdit1.Value := StrToInt(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToIntDef(const S: string; Default: Integer): Integer; $[SysUtils.pas 功能返回字符串S转换成整数 说明字符串非整数表达时则返回默认值Default 参考procedure System.Val 例子SpinEdit1.Value := StrToIntDef(Edit1.Text, 0); ━━━━━━━━━━━━━━━━━━━━━ 首部function TryStrToInt(const S: string; out Value: Integer): Boolean; $[SysUtils.pas 功能返回字符串S转换成整数Value是否成功 说明字符串非整数表达时返回False并且Value将输出为0 参考procedure System.Val 例子 ///////Begin TryStrToInt procedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin CheckBox1.Checked := TryStrToInt(Edit1.Text, I); SpinEdit1.Value := I; end; ///////End TryStrToInt ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToInt64(const S: string): Int64; $[SysUtils.pas 功能返回字符串S转换成六十四位整数 说明字符串非六十四位整数表达时将引起异常 参考procedure System.Val 例子SpinEdit1.Value := StrToInt64(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToInt64Def(const S: string; const Default: Int64): Int64; $[SysUtils.pas 功能返回字符串S转换成六十四位整数 说明字符串非六十四位整数表达时则返回默认值Default 参考procedure System.Val 例子SpinEdit1.Value := StrToInt64Def(Edit1.Text, 0); ━━━━━━━━━━━━━━━━━━━━━ 首部function TryStrToInt64(const S: string; out Value: Int64): Boolean; $[SysUtils.pas 功能返回字符串S转换成六十四位整数Value是否成功 说明字符串非六十四位整数表达时返回False并且Value将输出为0 参考procedure System.Val 例子 ///////Begin TryStrToInt64 procedure TForm1.Button1Click(Sender: TObject); var I: Int64; begin CheckBox1.Checked := TryStrToInt64(Edit1.Text, I); SpinEdit1.Value := I; end; ///////End TryStrToInt64 ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToBool(const S: string): Boolean; $[SysUtils.pas 功能返回字符串S转换成逻辑值 说明字符非逻辑表达时将引起异常 参考function SysUtils.TryStrToBool 例子CheckBox1.Checked := StrToBool(Edit1.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部function StrToBoolDef(const S: string; const Default: Boolean): Boolean; $[SysUtils.pas 功能返回字符串S转换成逻辑值 说明字符非逻辑表达时则返回默认值Default 参考function SysUtils.TryStrToBool 例子CheckBox1.Checked := StrToBoolDef(Edit1.Text, False); ━━━━━━━━━━━━━━━━━━━━━ 首部function TryStrToBool(const S: string; out Value: Boolean): Boolean; $[SysUtils.pas 功能返回字符串S转换成逻辑值Value是否成功 说明[注意]0为假非0为真;不是'True'和'False';Delphi6 Bug 如下修正 参考function SysUtils.AnsiSameText;var SysUtils.TrueBoolStrs;var SysUtils.FalseBoolStrs 例子 ///////Begin TryStrToBool procedure TForm1.Button1Click(Sender: TObject); var B: Boolean; begin SetLength(TrueBoolStrs, 2); SetLength(FalseBoolStrs, 2); TrueBoolStrs[0] := 'True'; FalseBoolStrs[0] := 'False'; TrueBoolStrs[1] := 'Yes'; FalseBoolStrs[1] := 'No'; CheckBox1.Checked := TryStrToBool(Edit1.Text, B); CheckBox2.Checked := B; end; ///////End TryStrToBool 附加 ///////Begin TryStrToBool function TryStrToBool(const S: string; out Value: Boolean): Boolean; function CompareWith(const aArray: array of string): Boolean; var I: Integer; begin Result := False; for I := Low(aArray) to High(aArray) do if AnsiSameText(S, aArray[I]) then begin Result := True; Break; end; end; var LResult: Extended; begin Result := TryStrToFloat(S, LResult); if Result then Value := LResult <> 0 else begin Result := True; //修正处 VerifyBoolStrArray; if CompareWith(TrueBoolStrs) then Value := True else if CompareWith(FalseBoolStrs) then Value := False else Result := False; end; end; 课程设计报告 课程设计题目:研究生初试录取 学生姓名:李俊 专业:计算机应用技术 班级: 1140302 指导教师:宋文琳 2012年 06 月 23日 目录 一)实验题目 (3) 二)实验目的 (3) 三)实验要求 (3) 四)实验思路 (4) 五)实验过程 (6) 六)实验调试和结果 (9) 七)实验小结 (13) 实验题目 字符串处理 (1)不使用系统库函数,编写多个函数实现; (2)定义字符数组存放字符串,从键盘输入; (3)调用不同的函数,实现字符串的连接、拷贝、比较、求字符串长度、对字符串内字符进行排序、查找字符串中某个字符是否存在; (4)分别输出以上字符串处理的结果。 二)实验目的 本次课程设计的主要目的是综合运用所学的C语言知识解决一个比较实际的简单问题,侧重对数组、函数、指针、结构体等相关内容的综合应用,使学生能进一步熟悉掌握C语言的基本语法,进一步提升编程能力并逐步培养编程思维,进而不断提高学生解决问题的能力,并为以后的语言学习打下良好的基础。三)实验要求 1. 学生独立完成课程设计的主要内容; 2. 按照实验课表安排进行,不得无故旷课; 3.按照选题规则确定课程设计题目,不可随意更换,但可在完成规定的任务之后,根据 个人兴趣选做其它题目; 4.严格按照报告格式撰写课程设计报告; 5.程序实现方式可以自选,可采用指针、数组或其任意组合方式完成。 四)实验思路1)整体思路 五)实验过程 代码: #include strcpy(char destination[], const char source[]); strcpy:将字符串source拷贝到字符串destination中。 strcpy函数应用举例 原型:strcpy(char destination[], const char source[]); 功能:将字符串source拷贝到字符串destination中 例程: #include function ArcCos(const X : Extended) : Extended; overload; function ArcCos(const X : Double) : Double; overload; function ArcCos(const X : Single) : Single; overload; function ArcSin(const X : Extended) : Extended; overload; function ArcSin(const X : Double) : Double; overload; function ArcSin(const X : Single) : Single; overload; function ArcTan2(const Y, X: Extended): Extended; procedure SinCos(const Theta: Extended; var Sin, Cos: Extended) register; function Tan(const X: Extended): Extended; function Cotan(const X: Extended): Extended; { 1 / tan(X), X <> 0 } function Secant(const X: Extended): Extended; { 1 / cos(X) } function Cosecant(const X: Extended): Extended; { 1 / sin(X) } function Hypot(const X, Y: Extended): Extended; { Sqrt(X**2 + Y**2) } function RadToDeg(const Radians: Extended): Extended; inline; { Degrees := Radians * 180 / PI } function RadToGrad(const Radians: Extended): Extended; inline; { Grads := Radians * 200 / PI } function RadToCycle(const Radians: Extended): Extended; inline; { Cycles := Radians / 2PI } function DegToRad(const Degrees: Extended): Extended; inline; { Radians := Degrees * PI / 180} function DegToGrad(const Degrees: Extended): Extended; function DegToCycle(const Degrees: Extended): Extended; function GradToRad(const Grads: Extended): Extended; inline; { Radians := Grads * PI / 200 } function GradToDeg(const Grads: Extended): Extended; function GradToCycle(const Grads: Extended): Extended; function CycleToRad(const Cycles: Extended): Extended; inline; { Radians := Cycles * 2PI } function CycleToDeg(const Cycles: Extended): Extended; function CycleToGrad(const Cycles: Extended): Extended; { Hyperbolic functions and inverses } function Cot(const X: Extended): Extended; inline; { alias for Cotan } function Sec(const X: Extended): Extended; inline; { alias for Secant } function Csc(const X: Extended): Extended; inline; { alias for Cosecant } function Cosh(const X: Extended): Extended; function Sinh(const X: Extended): Extended; function Tanh(const X: Extended): Extended; function CotH(const X: Extended): Extended; inline; function SecH(const X: Extended): Extended; inline; function CscH(const X: Extended): Extended; inline; function ArcCot(const X: Extended): Extended; { IN: X <> 0 } function ArcSec(const X: Extended): Extended; { IN: X <> 0 } function ArcCsc(const X: Extended): Extended; { IN: X <> 0 } function ArcCosh(const X: Extended): Extended; { IN: X >= 1 } function ArcSinh(const X: Extended): Extended; 一个windows自带的画图工具是无论如何也不能满足我们的画图需要的,很多效果都需要我们在另外的工具中来实现。这些高级的功能是如何实现的呢,如何操纵一些基本的属性和函数,让它们最终能作出我们想要的效果呢?这里我们以绘制统计图来说明这些问题。 解决思路―― 这里,我们暂且先撇开具体的问题,综合地一下讨论画图的问题。 画图工具是基本元素的具体实现,对于我们初学者来说,还是有很好的参考价值的,在delphi 5中有一个自带的工程例子“……Borland\Delphi5\Demos\Doc\Graphex”,这个例子可以实现一些基本的绘图功能。对这个例子多加修改,一定会有所收获的。这里就不列出它的详细代码了,有心的读者可以自己找到这个例子。我这里只是想综合地讨论这方面的问题。使用DELPHI编写绘图软件的灵魂就在于操作画布,画笔和刷子,尽可能地挖掘它们的属性和相关参数的设置。 (一)画布 画布,画笔和刷子之间的关系很明了.其实,画笔和刷子都是画布的一个属性.而画布也只是TForm,TImage,TShape等组件对象的一个属性,专门负责与图象相关的信息打交道.它的主要作用可以概括如下几点: 1.指定使用画笔,刷子和字体的使用类型; 2.绘制和填充指定形状的线或图形; 3.修饰和改变图象; 画布的主要属性有: Brush--指定填充图形和背景的样式 CanvasOrientation--指定画布的定位类型,有coLeftToRight, coRightToLeft两个属性; ClipRect--指定剪切矩形的边界; CopyMode--指定图形图象的复制模式; Font--指定画布上使用的字体; Handle--为画布指定窗口GDI对象的设备描述表; LockCount--指定画布被别的线程锁定的次数; Pen--指定画布上使用的画笔,具体见下面描述; PenPos--指定画笔当前的位置; Pixels--指定当前剪切矩形的象素颜色; TextFlags--指定字体在画布上的显示方式,有ETO_CLIPPED,ETO_OPAQUE,ETO_RTLREADING,ETO_GL YPH_INDEX,ETO_IGNORELANGUAGE,ETO_NUMERICSLOCALETO_NUMERIC SLATIN等值可选; 画布相关的API函数及其注释如下: Arc--按指定方式画一条弧; BrushCopy--把位图复制到指定的画布的矩形中,用画布刷子颜色替换位图的颜色; Chord--按指定方式画弦; CopyRect--从一个矩形区域复制部分图象到另一个矩形区域; Draw--用指定参数在指定位置画图; DrawFocusRect--按指定焦点风格,通过异或操作来绘制一焦点矩形; Ellipse--按指定参数画一椭圆; FillRect--按指定的刷子填充一矩形; FloodFill--使用当前选定的刷子填充指定设备描述表中的一块区域; 一、数据类型转换函数1 在我们编写程序当中,根据不同情况,会使用到多种数据类型。当要对不同的类型进行操作时,必须要将不同的类型转换成同样的类型。因此熟练地掌握数据类型的转换是非常重要的。 1.FloatToStr 功能说明:该函数用于将“浮点型”转换成“字符型”。 参考实例: Edit1.Text := FloatToStr(1.981); 2.IntToStr 功能说明:该函数用于将“整数型”转换成“字符型”。 参考实例: S := IntToStr(10);(注:S为String类型变量。) 3.IntToHex 功能说明:该函数用于将“十进制”转换成“十进制”。该函数有二个参数1。第一个参数为要转换的十进制数据,第二个参数是指定使用多少位来显示十六进制数据。 参考实例: Edit1.Text := IntToHex('100', 2); 执行结果,Edit1.Text等于64。 注意:Delphi没有提供专门的“十六进制”转换为“十进制”的函数。使用StrToInt函数可以实现这个功能。具体代码是:I := StrToInt('S\' + '64'); 这时I等于100。加上一个'S\'即可将“十六进制”转换为“十进制”。 4.StrToInt 功能说明:该函数用于将“字符型”转换成“整数型”。 参考实例: I := StrToInt('100'); 注意:不能转换如StrToInt('ab')或StrToInt('好')这样的类型,因为他们并不存在数字型。 5.StrToFloat 功能说明:该函数用于将“字符型”转换成“浮点型”。 参考实例: N := StrToFloat(Edit1.Text); 注意:Edit1.Text中的内容为1.981(凡在Edit 控件中显示的文本均为字符串)。N为Double类型,用于保存转换后的浮点型数据。 C 语言中处理字符串的各种自定义函数 关于 strcpy,strcmp,strcat,strlen 的自定义函数,它是为了避免调用库函数对代码兼容的局限性。要注意如下一些问题: 1. 检查输入的两个指针是否有效; 2. 检查两个字符串是否以 NULL 结尾; 3. 检查目标指针的空间是否大于等于原字符串的空间。 一. strcpy 自定义 char * sef_strcpy(char *str1,char *str2 { If( (NULL==str1||(NULL==str2 { printf(“ invalid argument(s” ; return; } char *strcopy=str1; while(… \0? != *str1++=*str2++ ; *str1=? \0? ; return strcopy; } 二. strcmp 的自定义 int sef_strcpy(char *str1,char *str2 { If( (NULL==str1||(NULL==str2 { printf(“ 输入参数错误,值为 NULL ! \n” ; return -1; } while(*str1&&*str2&&( *str1++==*str2++ ; return str1-str2; } 三. strcat 的自定义 char * sef_strcat(char *str1,char *str2 { If( (NULL==str1||(NULL==str2 { printf(“ 输入参数错误! ” ; return; } char *strcopy=str1; while(… \0? !=*str1 {str++;} while(… \0? != (*str1++=*str2++ ; *str1=? \0? ; return strcopy; } 四. strlen 的自定义函数 int sef_strlen(char *str { if(NULL==str { printf(“ 输入参数错误,值为NULL ! ” ; char *p=str; while(… \0? !=*str++ ; return str-p-1; 示例 1.字符串输出示例。 程序: #include int x,y; x=strlen(a); y=strlen("abc13"); printf("%d\n%d\n\n",x,y); } 结果: 4.字符串连接函数的使用。 程序: #include Delphi函数大全 首部function Languages: TLanguages; $[ 功能返回系统语言对象 说明通过此函数可以得到系统的语言环境 参考type 例子 12a12c12a12c. 参考 C语言字符串的输入和输出 字符串的输入和输出 %c人为加入\0进行输入输出 %s直接输入输出 *输入输出字符串时字符数组应有足够的存储空间,指针变量作为输入项时,指针必须已经指向确切的、足够大的存储空间 %s的使用 scanf("%s",地址值) 地址值:字符数组名、字符指针、字符数组元素的地址 例:char str[15]; scanf("%s",str); abc123 1.不读入空格和回车,从空格处结束 2.输入字符串长度超过字符数组元素个数,不报错 3.当输入项为字符指针时,指针必须已指向确定的有足够空间的连续 存储单元 4.当为数组元素地址时,从此元素地址开始存放 2.printf("%s",地址值) 输出时遇到第一个'\0'为止 3.gets和puts函数 开头必须stdio.h #include"stdio.h" 1.gets(地址值) 地址值:字符数组名、字符指针、字符数组元素的地址 4.当为数组元素地址时,从此元素地址开始存放 5.printf("%s",地址值) 输出时遇到第一个'\0'为止 6.gets和puts函数 开头必须stdio.h #include"stdio.h" 1.gets(地址值) 地址值:字符数组名、字符指针、字符数组元素的地址 7.例: char str[10]; gets(str); 包括空格符 8. 2.puts(字符串起始地址) 遇第一个'\0'结束,自动加入换行符 9.字符串数组:数组中每个元素都是一个存放字符串的数组 可以将一个二维数组看作是字符串数组 10.char ca[3][5]={"A","BB","CCC"}; A\0 B B\0 C C C\0 字符型指针数组 char*pa[3]={"a","bb","ccc"}; pa[0]pa[1]pa[2] 可以重新赋值gets(pa[2]); VB常用字符串操作函数2009/11/25 18:321. ASC(X,Chr(X:转换字符字符码[格式]: P=Asc(X 返回字符串X的第一个字符的字符码 P=Chr(X 返回字符码等于X的字符 [范例]:(1P=Chr(65 ‘ 输出字符A,因为A的ASCII码等于65 (2P=Asc(“A” ‘ 输出65 2. Len(X:计算字符串X的长度 [格式]: P=Len(X [说明]:空字符串长度为0,空格符也算一个字符,一个中文字虽然占用2 Bytes,但也算 一个字符。 [范例]: (1 令X=”” (空字符串 Len(X 输出结果为0 (2 令X=”abcd” Len(X 输出结果为4 (3 令X=”VB教程” Len(X 输出结果为4 3. Mid(X函数:读取字符串X中间的字符 [格式]: P=Mid(X,n 由X的第n个字符读起,读取后面的所有字符。 P=Mid(X,n,m 由X的第n个字符读起,读取后面的m个字符。 [范例]: (1 X=”abcdefg” P=Mid(X,5 结果为:P=”efg” (2 X=”abcdefg” P=Mid(X,2,4 结果为 P=”bcde” 4. R eplace: 将字符串中的某些特定字符串替换为其他字符串 [格式]: P=Replace(X,S,R [说明]:将字符串X中的字符串S替换为字符串R,然后返回。[范例]:X=”VB is very good” P=Replace(X,good,nice 输出结果为:P=”VB is very nice” 5. StrReverse:反转字符串 [格式]: P=StrReverse(X [说明]:返回X参数反转后的字符串 [范例]:(1)X=”abc” P=StrReverse(X 输出结果:P=”cba” 6. Ucase(X,Lcase(X:转换英文字母的大小写 [格式]:P=Lcase(X ‘ 将X字符串中的大写字母转换成小写P=Ucase(X ‘ 将X字符串中的小写字母转换成大写 [说明]:除了英文字母外,其他字符或中文字都不会受到影响。 [范例]:(1)令X=”VB and VC” 则Lcase(X的结果为”vb and vc”,Ucase(X的结果为”VB AND VC” 7. InStr函数:寻找字符串 [格式]: P=InStr(X,Y 从X第一个字符起找出Y出现的位置 P=InStr(n,X,Y 从X第n个字符起找出Y出现的位置 [说明]:(1)若在X中找到Y,则返回值是Y第一个字符出现在X中的位置。(2) InStr(X,Y相当于 InStr(1,X,Y。(3)若字符串长度,或X为空字符串,或在X中找不到Y,则都 返回0。(4)若Y为空字符串,则返回0。 ---------------------------------------------------------------------------------------------- mid(字符串,从第几个开始,长度 ByRef 在[字符串]中[从第几个开始]取出[长度个字符串] 例如 mid("小欣无敌",1,3 则返回 "小欣无" instr(从第几个开始,字符串1,字符串2 ByVal 从规定的位置开始查找,返回字符 C语言字符串操作总结大全(超详细) 1)字符串操作 strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat(p, p1) 附加字符串 strncat(p, p1, n) 附加指定长度字符串 strlen(p) 取字符串长度 strcmp(p, p1) 比较字符串 strcasecmp忽略大小写比较字符串 strncmp(p, p1, n) 比较指定长度字符串 strchr(p, c) 在字符串中查找指定字符 strrchr(p, c) 在字符串中反向查找 strstr(p, p1) 查找字符串 strpbrk(p, p1) 以目标字符串的所有字符作为集合,在当前字符串查找该集合的任一元素strspn(p, p1) 以目标字符串的所有字符作为集合,在当前字符串查找不属于该集合的任一元素的偏移 strcspn(p, p1) 以目标字符串的所有字符作为集合,在当前字符串查找属于该集合的任一元素的偏移 * 具有指定长度的字符串处理函数在已处理的字符串之后填补零结尾符 2)字符串到数值类型的转换 strtod(p, ppend) 从字符串p 中转换double 类型数值,并将后续的字符串指针存储到ppend 指向的char* 类型存储。 strtol(p, ppend, base) 从字符串p 中转换long 类型整型数值,base 显式设置转换的整型进制,设置为0 以根据特定格式判断所用进制,0x, 0X 前缀以解释为十六进制格式整型,0 前缀以解释为八进制格式整型 atoi(p) 字符串转换到int 整型 atof(p) 字符串转换到double 符点数 atol(p) 字符串转换到long 整型 3)字符检查 isalpha() 检查是否为字母字符 isupper() 检查是否为大写字母字符 islower() 检查是否为小写字母字符 isdigit() 检查是否为数字 isxdigit() 检查是否为十六进制数字表示的有效字符 isspace() 检查是否为空格类型字符 iscntrl() 检查是否为控制字符 ispunct() 检查是否为标点符号 isalnum() 检查是否为字母和数字 isprint() 检查是否是可打印字符 isgraph() 检查是否是图形字符,等效于isalnum() | ispunct() Delphi常用组件的使用 目录 1.按钮类组件 1.1Button组件 Button组件位于Standard页。 Button组件的常用属性表 属性描述 Cation用于在按钮上显示文本内容 Cancel用来指定按钮是否为取消按钮 Default用于指定按钮是否为默认按钮,在按Enter键时也选中命令按钮Hint设置鼠标在组件上短暂停时在组件旁显示的提示小窗口的内容ShowHint确定是否显示提示文本,默认值是FALSE 1.2Bitbtn组件 Bitbtn组件(位图组件)位于Additional,与Button很相似,只是多了一个位图符号在按钮上(如带有对号的OK,问好的Help等),其某些属性与Button类似,下表为其独有的的特性。(注:此组件不需编写代码) Bitbtn组件的常用属性表 属性描述 Kind Kind属性的值就是位图按钮上显示的图标。Kind属性后的下拉列表中有一组默认图标的属性值,有bkCancel(取消)、bkAbort(终止)、bkAll(所有)、 bkClose(关闭)等。 Glyph用于在位图按钮上显示加载后的位图图形 NumGlyphs用于指明位图按钮所能使用位图的个数。在delphi中,最多允许向一个位图按钮提供4个图像文件,用于表示4中不停状态 Layout用于指出位图图形在位图组件上的放置位置 1.3SpeedButton组件 SpeedButton组件(加速按钮)位于Additional,常放置在Panel组件上,用于设计工具栏。它与Bitbtn相似,也可以显示图像和文本,但通常只用于显示图像。 SpeedButton组件的常用属性表 属性描述 AllowAllUp用于设置同一组的加速按钮是否具有同时弹起的状态。若设置为FALSE,则当同一组加速按钮中的一个被按下时,其他加速按钮都处于弹起状态,即这 组按钮必须有且只有一个处于按下状态 Down用于设置该加速按钮是否处于按下状态,若设置为TRUE,则表示按钮处于按下状态 Flat用于设置在鼠标移动到该按钮上时,按钮是否显示三维效果。为FLASE则不出现 GroupIndex用于将数个加速按钮设置成一组,只需将其值设置成不等于0的数值即可1.4RadioButton组件 sstrstr与strchar用法 原型:extern char *strstr(char *haystack, char *needle); 用法:#include (DELPHI)API函数大全 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接WNetAddConnection2 创建同一个网络资源的连接WNetAddConnection3 创建同一个网络资源的连接WNetCancelConnection 结束一个网络连接 WNetCancelConnection2 结束一个网络连接 WNetCloseEnum 结束一次枚举操作 WNetConnectionDialog 启动一个标准对话框,以便建立同网络资源的连接WNetDisconnectDialog 启动一个标准对话框,以便断开同网络资源的连接WNetEnumResource 枚举网络资源 WNetGetConnection 获取本地或已连接的一个资源的网络名称WNetGetLastError 获取网络错误的扩展错误信息WNetGetUniversalName 获取网络中一个文件的远程名称以及/或者UNC (统一命名规范)名称 WNetGetUser 获取一个网络资源用以连接的名字 WNetOpenEnum 启动对网络资源进行枚举的过程 2. API之消息函数 BroadcastSystemMessage 将一条系统消息广播给系统中所有的顶级窗口GetMessagePos 取得消息队列中上一条消息处理完毕时的鼠标指针屏幕位置GetMessageTime 取得消息队列中上一条消息处理完毕时的时间PostMessage 将一条消息投递到指定窗口的消息队列PostThreadMessage 将一条消息投递给应用程序RegisterWindowMessage 获取分配给一个字串标识符的消息编号ReplyMessage 答复一个消息 SendMessage 调用一个窗口的窗口函数,将一条消息发给那个窗口SendMessageCallback 将一条消息发给窗口 SendMessageTimeout 向窗口发送一条消息 SendNotifyMessage 向窗口发送一条消息 3. API之文件处理函数 CloseHandle 关闭一个内核对象。其中包括文件、文件映射、进程、线程、安全和同步对象等 CompareFileTime 对比两个文件的时间 CopyFile 复制文件 CreateDirectory 创建一个新目录 CreateFile 打开和创建文件、管道、邮槽、通信服务、设备以及控制台CreateFileMapping 创建一个新的文件映射对象 DeleteFile 删除指定文件 Linux下常用C语言字符串操作函数 stroul, strdup snprintf() atio C中常用字符串操作函数 #include javascript字符串处理函数汇总 虽然JavaScript 有很多用处,但是处理字符串是其中最流行的一个。下面让我们深入地分析一下使用JavaScript 操作字符串。 在JavaScript 中,String 是对象。String 对象并不是以字符数组的方式存储的,所以我们必须使用内建函数来操纵它们的值。这些内建函数提供了不同的方法来访问字符串变量的内容。下面我们详细看一下这些函数。 操作字符串的值是一般的开发人员必须面临的家常便饭。操作字符串的具体方式有很多,比如说从一个字符串是提取出一部分内容来,或者确定一个字符串是否包含一个特定的字符。下面的JavaScript 函数为开发人员提供了他们所需要的所有功能: ? concat() –将两个或多个字符的文本组合起来,返回一个新的字符串。 ? indexOf() –返回字符串中一个子串第一处出现的索引。如果没有匹配项,返回-1 。 ? charA T() –返回指定位置的字符。 ? lastIndexOf() –返回字符串中一个子串最后一处出现的索引,如果没有匹配项,返回 -1 。 ? match() –检查一个字符串是否匹配一个正则表达式。 ? substring() –返回字符串的一个子串。传入参数是起始位置和结束位置。 ? replace() –用来查找匹配一个正则表达式的字符串,然后使用新字符串代替匹配的字符串。 ? search() –执行一个正则表达式匹配查找。如果查找成功,返回字符串中匹配的索引值。否则返回-1 。 ? slice() –提取字符串的一部分,并返回一个新字符串。 ? split() –通过将字符串划分成子串,将一个字符串做成一个字符串数组。 delphi常用函数大全(转) Abort函数引起放弃的意外处理 Abs函数绝对值函数 AddExitProc函数将一过程添加到运行时库的结束过程表中 Addr函数返回指定对象的地址 AdjustLineBreaks函数将给定字符串的行分隔符调整为CR/LF序列Align属性使控件位于窗口某部分 Alignment属性控件标签的文字位置 AllocMem函数在堆栈上分配给定大小的块 AllowGrayed属性允许一个灰度选择 AnsiCompareStr函数比较字符串(区分大小写) AnsiCompareText函数比较字符串(不区分大小写) AnsiLowerCase函数将字符转换为小写 AnsiUpperCase函数将字符转换为大写 Append函数以附加的方式打开已有的文件 ArcTan函数余切函数 AssignFile函数给文件变量赋一外部文件名 Assigned函数测试函数或过程变量是否为空 AutoSize属性自动控制标签的大小 BackgroundColor属性背景色 BeginThread函数以适当的方式建立用于内存管理的线程 BevelInner属性控件方框的内框方式 BevelOuter属性控件方框的外框方式 BevelWidth属性控件方框的外框宽度 BlockRead函数读一个或多个记录到变量中 BlockWrite函数从变量中写一个或多个记录 BorderStyle属性边界类型 BorderWidth属性边界宽度 Break命令终止for、while、repeat循环语句 Brush属性画刷 Caption属性标签文字的内容 ChangeFileExt函数改变文件的后缀 ChDir函数改变当前目录 Checked属性确定复选框选中状态 Chr函数返回指定序数的字符 CloseFile命令关闭打开的文件 Color属性标签的颜色 Columns属性显示的列数 CompareStr函数比较字符串(区分大小写) Concat函数合并字符串 Continue命令继续for、while、repeat的下一个循环 Copy函数返回一字符串的子串 Cos函数余弦函数 Ctl3D属性是否具有3D效果 Cursor属性鼠标指针移入后的形状 Date函数返回当前的日期 DateTimeToFileDate函数将DELPHI的日期格式转换为DOS的日期格式DateTimeToStr函数将日期时间格式转换为字符串DateTimeToString函数将日期时间格式转换为字符串 DateToStr函数将日期格式转换为字符串C语言课程设计报告 - 字符串处理
C字符串处理函数全
delphi数学模块函数、过程大全
Delphi如何使用基本的绘图函数绘制统计图
DELPHI常用函数说明
C语言中处理字符串的各种自定义函数(精)
各种字符串处理函数示例(基本)
Delphi函数大全
C语言字符串的输入和输出
VB常用字符串操作函数解读
C语言字符串操作总结大全(超详细)
DELPHI常用组件
acm常用字符串处理函数
(DELPHI)API函数大全
Linux下常用C语言字符串操作函数
javascript字符串处理函数汇总
delphi常用函数大全