Static array definition method

Source: Internet
Author: User
Tags array definition
// 1. Standard Method: var myarr: array [0 .. 10] of integer; // defines a static Array
  
   
 // 2. Non-0 Subscript: var myarr: array [9 .. 10] of integer can be used; // It cannot be promoted, so it is not easy to communicate with system functions.
  
   
 // 3. declare An Array Based on the predefined type: Type tmyarr = array [0 .. 10] of integer; // first define an array type var myarr: tmyarr; // then define a static Array
  
   
 // 4. In the non-process area, values can be directly assigned: var myarr: array [0 .. 2] of integer = (, 33 );
  
   
 // 5. Multi-dimensional array: var myarr: array [0 .. 2, 0 .. 2] of integer; begin // use myarr [1, 2]: = 100; end;
  
   
 // 6. Define an array according to the subinterface: Type trange = 0 .. 10; var myarr: array [trange] of integer;
  
   
 // 7. defines an Array Based on enumeration: Type tenums = (enum1, enum2, enum3); var myarr: array [tenums] of string; begin myarr [enum1]: = 'case '; showmessage (myarr [enum1]); // In case of end;
  
   
 // 8. array defined by other types: var myarr: array [byte] of char; begin myarr [255]: = #65; showmessage (myarr [255]); // aend; // try not to use the built-in type. You can create a new type: Type tnewbyte = byte; var myarr: array [tnewbyte] of char; begin myarr [255]: = #65; showmessage (myarr [255]); // aend; // You can also use the type alias: Type tchar = type char; var myarr: array [tchar] of byte; begin myarr ['C']: = 255; showmessage (inttostr (myarr ['C']); // 255end; // define the type simultaneously: Type myrec = record S: string; R: real; B: byte; end; var arr1: array [0 .. 100] of myrec; arr2: array [0 .. 100] of record S: string; R: real; B: byte; end; // you can define arr3: packed array [0 .. 100] of myrec; // compression array definition, as if there is no difference?
  
   
 

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.