Delphi_03_Delphi_Object_Pascal_기본 구문01
{
Delphi Pascal
1、
2、
3、
3、
4、
}
program Syntax;
{$APPTYPE CONSOLE}
uses
SysUtils,Windows,StrUtils;
{
1、Delphi
2、Delphi var
3、 :
var : ;
4、
var : = ;
5、
}
var
//
greetWord:string;
//
nAdd,nAddFactor:integer;
//
rad : single = 5.0 ;
//
chinaName:WideString;
//ansichar
englishName:AnsiString;
//
noInitString:string;
// win32
dirWideString:widestring;
dirString:ansistring;
{
1、Delphi
true Boolean true
false Boolean false
2、 Delphi const
3、
const : = 。
4、 , ,Delphi
, 。 ,
。
:
10 shortint
5、 , C ,
10
2.06
'Hello world'
'a'
}
const
pi:single=3.1415926;
{
1、Delphi 。
2、 :
Sizeof()
Ord()
Chr()
Trunc()
Round()
High()
Low()
, ,
}
begin
// :=
greetWord := 'Hello, Wellcome to Delphi world!';
// =
nAdd := 10;
nAddFactor := 1;
if nAdd = nAddFactor then
begin
writeln('Equal.');
end;
// <> , TRUE
if nAdd <> nAddFactor then
begin
writeln('Not Equal.');
end;
// and , Delphi
if (1 = nAdd) and (2 <> nAddFactor )then
begin
writeln('The judge is ture.');
end;
// or , Delphi
if (1 = nAdd) or (2 <> nAddFactor )then
begin
writeln('The judge is ture.');
end;
// not , Delphi
if not (1 = nAdd) then
begin
writeln('1 is not equal nAdd.');
end;
{
1、 C ,
2、mod
3、div ,
4、/ ,
}
writeln(' 3 div 2 :');
writeln(3 div 2);
writeln(' 3 / 2 :');
writeln(3 / 2);
writeln(' 3 mod 2 :');
writeln(3 mod 2);
{
1、Delphi
2、and
3、or
4、not
5、xor
6、shl
7、shr
}
writeln('2 and 5 :');
writeln(2 and 5);
writeln('2 or 5 :');
writeln(2 or 5);
writeln('not 2 :');
writeln(not 2);
writeln('2 xor 5 :');
writeln(2 xor 5);
writeln('2 shl 5 :');
writeln(2 shl 5);
writeln('2 shr 5 :');
writeln(2 shr 5);
{
1、inc
2、dec
3、 inc(a); a := a + 1
inc(a, b); a := a + b
}
writeln('nAdd is:');
writeln(nAdd);
writeln('Inc(nAdd) is:');
Inc(nAdd);
writeln(nAdd);
Dec(nAdd);
writeln('Dec(nAdd) is:');
writeln(nAdd);
{
1、 8 、16 、32 ,64
2、4 、6 、8 、10 ,64
3、1 、2
4、 、
5、NULL 、NULL
6、
7、1 、2 、4 boolean
}
//ansichar
if sizeof(char)=sizeof(ansichar) then
begin
writeln('char and ansichar have the same size.');
end;
//char widechar
if sizeof(char)=sizeof(widechar) then
begin
writeln('char and widechar have the same size.');
end;
{
1、shortstring 256 ,ansichar
2、ansistring ansichar
3、widestring widechar
4、pchar NULL , C char*
5、pansichar NULL ansichar
6、pwidechar NULL widechar
7、 string ansichar
}
(*
1、 {$H+} {$H-} string
{$H+} string ansichar
{$H-} string shortchar
2、
*)
writeln(sizeof(shortstring));
//
chinaName := ' ';
//
englishName := 'England';
writeln(chinaName);
writeln(englishName);
{ ansistring
1、string
2、 string
3、 SetLength()
4、
5、string , ,
string
6、 +
}
//
//noInitString[0] := 'a';
// , SetLength() 。
SetLength(noInitString,1);
noInitString := 'a' ;
// + ,
noInitString := noInitString + ' apple';
writeln(noInitString);
{ ansistring Win32
1、 ansistring NULL , Win32
}
SetLength(dirString,256);
//SysAllocStringLen(dirWideString,256);
// windows
//GetWindowsDirectory(PWideChar(dirWideString),256);
dirString := dirWideString;
writeln(dirString);
readln;
end.
전재를 환영합니다. 전재는 출처를 밝혀 주십시오.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.