Conditional branch of Program Flow control (Delphi)

Source: Internet
Author: User

The if statement primarily detects a condition and executes a piece of code based on whether the condition is true or false;

1234567891011121314151617 var  I: Integer;  FileGood: Boolean;begin  FileGood := True;  ifFileGood then{ 简洁的写法,判断FileGood是否为True}    ShowMessage(‘True‘);  { 上面的写法等同于下面}  ifFileGood = Truethen ShowMessage(‘True‘);  ifI > 0then{ 如果I大于0}    DoSomething1  elseifI < 0 then{ 如果I小于0,else if块不是必须的}    DoSomething2  else{ 如果是其他条件,通常来实现默认的处理,else块也不是必须的}    DoSomething;end;

The case statement can be thought of as the development of an if statement, which allows the program to execute a block of code in multiple blocks of code based on the result of an expression, which can only be of an ordered type variable as a condition factor, and the other, such as a string, is not feasible.

1234567891011121314 var  I: Integer;begin  caseI of    1:      { 如果 I = 1}      DoSomething1;    2, 3:   { 如果 I = 2或者3,相当于if I in [2, 3]}      DoSomething2;    4..10{ 如果 I在4到10范围内(含4和10)}      DoSomething3;  else{ 如果是其他条件,通常用来实现默认处理,else块也不是必须的}    DoSomething;  end;end;

Conditional branch of Program Flow control (Delphi)

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.