How to define a 2D array of type String in delphi

Updated on technology 2024-03-18
5 answers
  1. Anonymous users2024-02-06

    procedure : tobject);

    vararr:array of array of string;

    beginsetlength(arr,2,3);

    arr[1,2]:='this is a test';

    setlength(arr,0,0);

    setlength(arr,4,5);

    showmessage(arr[1,2]);

    end;The way to declare a two-dimensional array is to use the array of array of types, which is very close to the way people think. In the same way, you can declaring a three-dimensional array as array of array of array of types.

    The setlength function is still used to adjust the size of the two-dimensional array, the first parameter is the name of the array, the second parameter is the size of the dimension closest to the name of the array, the third parameter is the size of the dimension away from the name of the array, and so on.

  2. Anonymous users2024-02-05

    Doubly linked lists.

    Two-dimensional arrays. data: array[0..2,0..2] of integer;Static.

    data: array of array of integer;Dynamic.

  3. Anonymous users2024-02-04

    This should be done with struct arrays.

    type tuseinfo=reocrd

    usname: string[20];

    uspsw: string[20];

    end;var

    userlist: array[1..10] of tuserinfo;

  4. Anonymous users2024-02-03

    In delphi (object pascal language), the array keyword is used for array definition.

    If you need to define a two-dimensional array, you can take the following definition:

    1. Definition of static arrays.

    A static array definition, usually used when the number of array elements is determined. It is defined in the following form:

    Example: type

    Define the 2D array type.

    tmultiarr = array[1..3,1..3] of string;

    varmultiarr: tmultiarr;

    Define an integer array of row 12 x column 12.

    intarr: array[1..12] of array[1..12] of integer;

    Define a string array of rows5*columns5.

    strarr: array[1..5,1..5] of string;

    2. Definition of dynamic arrays.

    Dynamic arrays are often used when the number of elements in the array is uncertain, and is defined in the following form:

    samarr: array of array of integer;Define a two-dimensional array, the elements of the array are indeterminate.

    type tmessagegrid = array of array of string;Define a two-dimensional array type, the array elements are indeterminate.

    var msgs: tmessagegrid;Declare a two-dimensional array-type variable.

    The number of elements in a two-dimensional dynamic array can be dynamically specified by setlenth, as shown below

    procedure : tobject);

    type tmultiarr = array of array of string;

    vara: tmultiarr;

    i, j: integer;

    s: string;

    beginsetlength(a, 10);

    for i := low(a) to high(a) do

    beginsetlength(a[i], i);

    for j := low(a[i]) to high(a[i]) do

    a[i, j] := inttostr(i) +',' + inttostr(j) +' ';

    end;for i := low(a) to high(a) do

    begins := '';

    for j := low(a[i]) to high(a[i]) do

    s := s + ' ' + a[i, j];

    end;end;

    **Running Screenshot:

  5. Anonymous users2024-02-02

    Choose one of two forms, for example:

    amatrix : array[1..10] of array[1..50] of real;

    bmatrix : array[1..10, 1..50] of real;

Related questions
14 answers2024-03-18

function getsqlserverlist(strings:tstrings):boolean;

The function is implemented as follows: >>>More

14 answers2024-03-18

After reading your **, let's explain the problem in your ** to you. >>>More

23 answers2024-03-18

Please modify it yourself as needed.

procedure addlink; >>>More

13 answers2024-03-18

1. For us, CAD does not display line width by default, which means that when we use CAD drawing, the thickness of the drawn lines is the same. First, we click on Format above the toolbar. >>>More

10 answers2024-03-18

Random numbers in pascal.

Random numbers refer to a series of numbers that theoretically have no rules to follow, have an equal probability of each number appearing within a specified range, and cannot be used to follow the previous number. The basic principle of a general random number generator is: first, initialize a random seed, the initial value of which can be an arbitrary integer; Every time a random number is obtained, a special operation is performed based on the random seed, a random number is obtained and returned, and then some operation is performed on the random seed to change the value of the random seed. >>>More