블로그 이미지
자료에 문제가 있을 경우, 확인하는대로 삭제처리 하겠습니다. 즐거운 하루 되시길...
05-04 06:48
Total
Today
Yesterday

카테고리

분류 전체보기 (199)
이야기방 (20)
공부방 (173)
개발노트&관련잡다구니 (6)

'델파이'에 해당되는 글 21건

  1. 2010.05.18 [델파이] 문자열 관련 함수
  2. 2010.05.13 [델파이] POS
  3. 2010.05.11 [델파이] FindFirst

AnsiCompareText SysUtils Unit
문법 : function AnsiCompareStr(const S1,S2:string):Integer;

두 개의 문자열 S1과 S2를 비교하되 대소문자를 구분하지 않고 비교한다. 
S1과 S2문자열이 같으면 0을 리턴하며 S1면 음수의 값을 리턴하며 S1>S2이면 양수를 리턴한다. 
문자열끼리의 비교는 문자열을 이루는 각 문자의 문자 코드를 비교하여 수행된다.

 

AnsiLowerCase SysUtils Unit
문법 : function AnsiLowerCase(const S: string): string;

문자열 내부의 대문자를 모두 소문자로 바꾼다. 
영문자 이외의 글자는 영향을 받지 않는다. 
문자 변환은 현재 설치된 언어 드라이버의 영향을 받는다.

 

AnsiUpperCase SysUtils Unit
문법 : function AnsiUpperCase(const S: string): string;

문자열 내부의 소문자를 모두 대문자로 바꾼다. 
영문자 이외의 글자는 영향을 받지 않는다. 
문자 변환은 현재 설치된 언어 드라이버의 영향을 받는다.

 

AppendStr SysUtils Unit
문법 : procedure AppendStr(var Dest: string; const S: string);

두 개의 문자열을 결합한다. Dest 문자열 뒷부분에 Src 문자열이 추가된다. 
Dest:=Dest+S와 문법적으로 동일한 기능을 한다.

Src:='Apple';
Dest:='Orange';
AppendStr(Dest,Src);
Dest 문자열은 OrangeApple가 된다.

 

CompareStr system Unit
문법 : function CompareStr(const S1, S2: string): Integer;

두 개의 문자열 S1과 S2를 비교하되 대소문자를 구분하여 비교한다. S1과 S2 문자열이 같으면 0을 리턴하며 S1음수의 값을 리턴하며 S1>S2이면 양수를 리턴한다. 
문자열끼리의 비교는 문자열을 이루는 각 문자의 문자 코드를 비교하여 수행되며 
현재 설치된 언어 드라이버에는 영향을 받지않는다.

 

CompareText system Unit
문법 : function CompareText(const S1, S2: string): Integer;

두 개의 문자열 S1과 S2를 비교하되 대소문자를 구분하지 않고 비교한다. S1과 S2 문자열이 같으면 0을 리턴하며 S1이면 음수의 값을 리턴하며 S1>S2이면 양수를 리턴한다. 문자열끼리의 비교는 문자열을 이루는 각 문자의 문자 코드를 비교하여 수행된다. "Apple"와 "APPLE"를 CompareText 함수로 비교하면 결과는 0이며 두 문자열이 같은 것으로 비교되지만 CompareStr 함수로 비교하면 결과는 두 문자열이 서로 다른 것으로 비교된다.

 

Copy system Unit
문법 : procedure Copy(S:String; Index, Count:Integer):String;

한 문자열의 부분 문자열을 추출해 낸다. S 문자열의 Index 위치에서부터 Count 문자분의 부분 문자열이 추출된다. Index가 문자열의 전체 길이보다 길 경우 빈 문자열을 리턴하며 Count가 문자열의 남은 부분보다 클 경우 문자열의 끝까지 추출해 낸다. 
Dest 문자열이 'Orange'일 경우 Copy(Dest,2,3)은 Dest 문자열의 두 번째 문자에서부터 3문자분의 부분 문자열인 'ran'을 추출해낸다.

 

DayOfWeek system Unit
문법 : function DayOfWeek(Date: TDateTime): Integer;

특정 날짜의 요일을 계산한다. 리턴되는 값은 1~7까지의 정수이며 1이 일요일, 7이 토요일이다. 리턴되는 값이 정수형이므로 월, 화, 수, 목 등의 실제 요일 이름으로 바꾸어 주어야 한다. 다음 예는 요일 이름을 레이블로 출력한다. 다음 예는
오늘이 무슨 요일인지 조사해서 요일 이름을 레이블로 출력해준다.


var
YO:string;
ONUL:TDateTime;
begin
ONUL:=Now;
case DayOfWeek(ONUL) of
1:YO:='일';
2:YO:='월';
3:YO:='화';
4:YO:='수';
5:YO:='목';
6:YO:='금';
7:YO:='토';
end;
label1.caption:='오늘은 '+YO+'요일입니다.';
end;

 

DecodeDate system Unit
문법 : procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);

날짜를 담는 TDateTime형의 변수에서 년, 월, 일의 값을 분리 시킨다. 분리된 값들은 각각 Year, Month, Day 등의 정수형 변수에 대입된다. 날짜값은 DateToStr 함수로, 문자열로 바꾼 후 한꺼번에 출력할 수 있지만 개별적인 요소를 가공한 후 출력하고자 할 경우는 이 함수를 사용한다. 이 함수의 반대 함수는 EncodeDate 함수이다. 다음 예는 오늘 날짜와 현재 시간을 조사한 후 문자열 조립을 통해 말로 시간과 날짜를 알려 준다.


var
부록 3 함수 레퍼런스 923
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := '오늘은' + IntToStr(Year) + '년'+ IntToStr(Month) + '
월' + IntToStr(Day)+'일입니다.';
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := '지금은' + IntToStr(Hour) + '시'+ IntToStr(Min)+'분입
니다.';
end;

 

Delete system Unit
문법 : procedure Delete (var S:String; Index, Count:Integer);

한 문자열에서 부분 문자열을 삭제한다. S 문자열의 Index 위치에서부터 Count 문자분의 부분 문자열이 삭제된다. Index가문자열의 전체 길이보다 길 경우 삭제는 이루어지지 않으며 Count가 문자열의 남은 부분보다 클 경우 문자열이 끝까지 삭제한다. Dest 문자열이 'Orange'일 경우 Delete(Dest,2,3)은 Dest 문자열의 두 번째 문자에서부터 3문자분의 부분 문자열인 'ran'을 삭제하며 Dest 문자열은 'Oge'가 된다.

 

Insert system Unit
문법 : procedure Insert(Source:String;var S:String;Index:Integer);

한 문자열의 중간에 다른 문자열을 삽입한다. 삽입되는 위치는 Index 인수가 지정하는 위치이다. 문자열을 삽입한 후의문자열 길이가 255자를 넘을 경우 255문자 이후의 문자는 잘려진다. Dest 문자열이 'Orange'이고 Src 문자열이 'Apple'인 경우 Insert(Src,Dest,3);는 Dest 문자열의 3번째 문자인 a위치에 Src 문자열을 삽입하며 Dest 문자열은 'OrAppleange'가 된다.

var
S: String;
begin
S := 'abcdefghijkl';
Insert(' hotdog ', S, 5);
label1.caption:=S;
end;
이 예를 실행시키면 레이블로 abcd hotdog efghijkl 문자열이출력된다.

 

Length system Unit
문법 : function Length(S:String):Integer;

주어진 문자열의 길이를 구한다. Length('Kora')는 5의 값을 리턴한다.

 

Pos system Unit
문법 : function Pos(Substr:String; S:String);Byte;

문자열 내의 부분 문자열을 검색한다. 부분 문자열이 검색된위치를 리턴해준다. 만약 부분 문자열이 발견되지 않으면 리턴값은 0이다.

 

StrComp SysUtils Unit
문법 : function StrIComp(Str1, Str2:PChar): Integer;

두 개의 문자열을 비교한다. S1과 S2 문자열이 같으면 0을 리턴하며 S1S2이면 양수를리턴한다. 문자열끼리의 비교는 문자열을 이루는 각 문자의 문자 코드를 비교하여 수행된다.

 

StrIComp SysUtils Unit
문법 : function StrLComp(Str1, Str2: PChar; MaxLen: Word):Integer;

두 개의 문자열을 비교하되 대문자와 소문자를 구분하지 않는다. S1과 S2 문자열이 같으면 0을 리턴하며 S1수의 값을 리턴하며 S1>S2이면 양수를 리턴한다. 문자열끼리의 비교는 문자열을 이루는 각 문자의 문자 코드를 비교하여 수행된다.



원본 출처 : http://redtears9.egloos.com/891882

'공부방 > Delphi' 카테고리의 다른 글

[델파이] Case 문법  (0) 2010.07.14
[델파이] 기본 컴포넌트  (0) 2010.07.14
[델파이] POS  (0) 2010.05.13
[델파이] FindFirst  (0) 2010.05.11
[델파이] 델파이7 Quick Report 설치하기 (TQRChart 도~)  (0) 2010.05.08
Posted by 래채
, |

[델파이] POS

공부방/Delphi / 2010. 5. 13. 16:03
 function Pos ( const Needle, HayStack : string ) : Integer;


Description
The Pos function finds the position of one string Needle within another HayStack
 
If the string is not found, 0 is returned. 
 
The search is case sensitive.
Notes
Warning : you should ideally use AnsiPos instead of Pos since the former supports wide character sets.
Posted by 래채
, |
 function FindFirst 
const FileMask : string; Attributes : Integer; var SearchResult : TSearchRec ) : Integer;


Description
The FindFirst function searches for files matching aFileMask and Attributes, returning the first match (if found) in SearchResult
 
The Attributes define files to search for in addition to regular files. 
 
If a match is found, then the return value is 0, otherwise, it is negative (and the result record is not filled in). 
 
The FileMask may contain a path, as well as a file name. The file name may contain wild cards: 
 
: Match any one character
: Match 0, 1 or more characters

 
The Attributes may be set as follows: 
 
faAnyFile  : Any file
faReadOnly  : Read-only files
faHidden  : Hidden files
faSysFile  : System files
faVolumeID  : Volume ID files
faDirectory  : Directory files
faArchive  : Archive files

 
You may set Attributes from one or more of the above by concatenating them. 
 
The SearchResult record comprises many fields. Some are used by subsequent calls to FindNext. Others are available to your program : 
 
Name  : Of the long name of the file found
Size  : The size of the file in bytes
Time  : Last modified date/time of the file
Attr  : The file attributes (as above)

Notes
Warning : you must call FindClose after a successfulFindFirst when you have finished searching (finished callingFindNext). This frees up resources held by the find process (such as the SearchResult record).

If the FileMask contains no path information, then the search is in the current directory.

Because the Attributes parameter defines additional file types to search for, you should filter the results Attr value to select only the desired file types.

Example code : Find all Unit1.d* regular files in the current directory
var
  searchResult : TSearchRec;

begin
  // Try to find regular files matching Unit1.d* in the current dir
  if FindFirst('Unit1.d*', faAnyFile, searchResult) = 0 then
  begin
    repeat
      ShowMessage('File name = '+searchResult.Name);
      ShowMessage('File size = '+IntToStr(searchResult.Size));
    until FindNext(searchResult) <> 0;

    // Must free up resources used by these successful finds
    FindClose(searchResult);
  end;
end;
Show full unit code
   File name = Unit1.dcu
   File size = 4382
   File name = Uni1.dfm
   File size = 524
   File name = Uni1.ddp
   File size = 51
   
 
Example code : Find all directories above and including the current one
var
  searchResult : TSearchRec;

begin
  // Try to find directories above the current directory
  SetCurrentDir('..');

  if FindFirst('*', faDirectory, searchResult) = 0 then
  begin
    repeat
      // Only show directories
      if (searchResult.attr and faDirectory) = faDirectory
      then ShowMessage('Directory = '+searchResult.Name);
    until FindNext(searchResult) <> 0;

    // Must free up resources used by these successful finds
    FindClose(searchResult);
  end;
end;
Show full unit code
   Directory = .
   Directory = ..
   Directory = Bin
   Directory = Help
   Directory = Projects
   Directory = Demos
   Directory = Lib
   Directory = Objrepos
   Directory = MergeModules
   Directory = Imports
   Directory = Source
   Directory = Rave5
   Directory = Ocx
 



Posted by 래채
, |