Jump to content
dopeness

Arrays

Recommended Posts

Small example:

 

var
 fruits: TStrArray;

begin
 ClearDebug;
 fruits := ['Apple', 'Orange', 'Banana', 'Pear']; // Indexes 0, 1, 2, 3.
 WriteLn('Random fruit: ' + fruits[Random(4)]); // Random returns 0-3 with value 4.
 SetLength(fruits, 0); 
end.

 

You can also do this:

 

var
 fruits: TStrArray;

begin
 ClearDebug;    
 SetLength(fruits, 4);
 fruits[0] := 'Apple';
 fruits[1] := 'Orange';
 fruits[2] := 'Banana';
 fruits[3] := 'Pear';
 WriteLn('Random fruit: ' + fruits[Random(4)]); // Random returns 0-3 with value 4.
 SetLength(fruits, 0); 
end.

 

Also, here is couple great video tutorials for arrays (dynamic and static arrays):

 

Done with old SCAR, but using arrays works still the same way in SCAR Divi 3.35+. :)

Edited by Janilabo
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...