Delphi self-study series _ 2_delphi Basics

Source: Internet
Author: User
Tags call by reference integer division

Through yesterday's learning and today's learning, I feel that the basic object PASAL of Delphi is much more complicated than C, especially

Is some object-oriented concepts, for example, the string type is more complex.

I don't know what's going on. It's hard to remember some things when I read a book, but I still need to practice some things to remember. Some basic things I saw yesterday

The content is basically forgotten today. I still have a superficial understanding of D7 and hope to get started with it.

Program typetest; {$ apptype console} uses sysutils; {defines the definition form of constant variable constants: const // defines the start of a definition using the const keyword to define constant symbols = constant values; // note that the = symbol is used instead of the: = symbol, or you can define it as follows: const constant Symbol: constant type = constant value;} // expconst Pi: double = 3.1415926; // circumference rate, constant appname: String = 'typetest '; // constant age of the string type: integer = 10; // integer variable // or use the following definition method rate = 0.98; {variable definition form: var // variable definition uses keywords to represent the variable name: variable type. You can assign an initial value to a global variable when defining a variable. However, you cannot use the VaR keyword to define the initial value of a function or local variable in the process. The name of the global variable VAR for the initial value: variable type = initial value; Delphi automatically assigns the initial value to the variable when defining the variable; integer Initialization is 0; floating point Initialization is 0.0 string Initialization is empty string, pointer Initialization is null;} // Exp: defines the variable VAR inum1: integer; // no initial value inum2: integer = 10; // chvar: Char; STR: string; area: Double; sum: integer; inctest: integer = 100; {the defined function and the process function have returned values. The function parameters that do not return values in a process can be called by passing values, it can also be called by reference, and the call by value is the default method. The call by reference is indicated by the keyword var, and the function parameters can have default values, the parameter with the default value must be the last parameter to define the function and the process. Remember that there must be no fewer semicolons after the function prototype; otherwise, an error is reported during compilation .} // Custom addition/subtraction operation process // function I is a reference call, and Function J is the default Parameter Function incmodify (var I: integer; J: integer = 0): integer; begin if J = 0 then I: = I + 1 else I: = I + J; end; // process I is a reference transfer call, J is the parameter procedure decmodify (var I: integer; J: integer = 0); begin if J = 0 then I: = I-1 else I: = I-j; end; begin {todo-ouser-cconsole main: insert code here} {operator value assignment operator: = using the value assignment operator to make an object have a value} // Exp: inum1: = age; {operator comparison operator = comparison operator compares two calculation objects and compares them to determine whether they are equal. If they are equal, the calculation result is logical true; otherwise, the result is logical false ;} // Exp: If inum1 = inum2 then writeln ('You age is ', inum1); readln (STR ); {comparison operators greater than or less than <greater than or equal to> = less than or equal to <= not equal to <> specific examples of these comparison operators are not listed one by one} // Exp: if 100> inum2 then writeln (100, 'biger then inum2'); readln (STR); {logical operators include three logical operators: And or not and: returns the logic and result of two expressions. If the values of both expressions are true, true is returned for the logic and operation. Otherwise, false or is returned for the logic or result of the two expressions, if the values of both expressions are false, the logic or operation returns the logical false; otherwise, the true logic is true. Not: the logical non-Results of the expression are returned. If the expression value is false, the logical truth is returned, if the expression value is true, a logical false tip is returned: When performing a logical operation, the expression is best to use () for processing, otherwise it is easy to compile the error} // exp if (100> inum2) and (STR = '') Then writeln ('two exp return ture '); readln (STR); If (100> inum2) or (STR = 'not null ') then writeln ('one of the exp return ture '); readln (STR); if not (100 <inum2) Then writeln ('100 not then inum2 '); readln (STR ); {addition of arithmetic operators + return the sum and subtraction of two operands-return the difference multiplication of two operands * return the product floating point division of two operands/return the quotient integer division Div of two floating point numbers return the quotient of two integers moD returns the remainder of two integers} // Exp: sum: = inum1 + age; inum1: = iNum1-100; inum2: = 3*10; Area: = PI/5.6; inum2: = 10 mod 5; inum2: = 10 Div 4; {bitwise operation in Delphi also provides the bitwise operation mechanism. bitwise AND and return the bitwise and result of the two operands. bitwise or return the bitwise or result of the two operands. return result of bitwise return result of two operands return result of bitwise return result of shifts SHL return result of shift right shift SHR return result tip after shift: the bitwise operation must be an integer.} // Exp: inum2: = 10 and 10; writeln (inttostr (inum2); readln (STR); inum2: = 10 SHL 3; // equivalent to 10*2 ^ 3; that is, 10 multiplied by the 3rd power of 2 writeln (inttostr (inum2); readln (STR ); {the addition and subtraction operation does not provide auto-increment and auto-increment operators in Delphi, but the addition and subtraction operation process included in the system is provided. The add and subtract operation process Inc Plus process dec subtraction process} // Exp: Inc (inum2, 100); // inum2: = inum2 + 100 Dec (inum1, 24); // inum1: = inum1-24 incmodify (inctest); writeln (inctest); decmodify (inctest, 30); writeln (inctest); readln (STR); end.

I don't know whether there are many people who use Delphi, or whether Delphi will be supported by development. I have always had such a good development tool.

I have read some books. Although I do not know much about it, I found that the functions of Delphi do not have to be poor in VC, or you can use APIs for development.

Xi ...... hope to stick to it, you can get started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.