PDA

View Full Version : Array Tutorial - (Old Tutorial)



XxKanexX
04-12-2006, 03:34 PM
-------------------------------------------------------------------------------------------
GUESS WHAT! I found nearly everyone of my tutorials on Flaxpicker :). Since i posted them there a while ago. So now, I'll post the ones that might help. They are a little pathetic now since i wrote them when i was only just learning.. But, i hope others learn. :)
-------------------------------------------------------------------------------------------

Heya! Since ive been writing tutorials i though about writing a tutorial about Arrays. So here it is! I know that most people dont use them alot, But they come in very good use! This will writeln the 4 arrays. Lets begin with the simple steps of declaring an array:, Now The Name Of This Array Will Be Tut:



Var
Tut : Array[1..4] Of Integer;


OK Now, Lets start of with explaining about the declaration Above. Tut Is The Name Of Our Arrays At The Moment, They Can Be Named Whatever You Want But For This we're Using 'TUT'. For array[1..4] That Is How Many Sections You Want. See Its Kind Of Like Different Strings. Can Be Anything, 1..4 , 1..8 , 1..(Your Number), Whatever you want. Of Integer Means That All 4 Of Them Will Be Integers. It Can Be Either String Or Byte aswell! OK Now We declare The A Integer



Var
Tut : Array[1..4] Of Integer;
A : Integer;


Those Vars Are All Done! Now We Begin The Script And Write In The Arrays, We Will Make Array 1 = '1', 2 = '2', 3 = '3' And 4 = '4'. Now becuase Its of integer we cant make them words. But if you do Of String You Can Make Them 'Hello' And Things Like That. Now We Make The Arrays:



Var
Tut : Array[1..4] Of Integer;
A : Integer;
Begin
Tut[1] := 1;
Tut[2] := 2;
Tut[3] := 3;
Tut[4] := 4;


There you have it, All 4 arrays (Named tut) Have been put in the script. Now, You put the name first, Then the number in brackets. ( Brackets Not Meaning '( + )', Brackets Meaning '[ + ]' ) Now for string they could be Tut[1] := 'Hello', Tut[2] := 'Goodbye', Tut[3] := 'Wo0tz', Tut[4] := 'W00tness!';.. But make sure In the declaration Its OF String;

Now we have to tell A To make It write all 4 of them:



Var
Tut : Array[1..4] Of Integer;
A : Integer;
Begin
Tut[1] := 1;
Tut[2] := 2;
Tut[3] := 3;
Tut[4] := 4;
For A := 1 to 4 Do


Now we're talking! We have so far:
1. Declared The Arrays
2. Declared The A
3. Added The Arrays Into The Script
4. Told A To Write 4 Of Them

Now We Have To Make It Writeln.



Var
Tut : Array[1..4] Of Integer;
A : Integer;
Begin
Tut[1] := 1;
Tut[2] := 2;
Tut[3] := 3;
Tut[4] := 4;
For A := 1 to 4 Do
Writeln(IntToStr(TUT[A]))
End.


There we go! Run that it will Writeln 1, 2, 3 And 4. You can also make It sendkeys/Sendkeyssilent Instead of writeln. Now if it was a string as you should know we dont need IntToStr before It. You Just Put:



writeln(Tut[a])


I have wroten a script that uses strings to Help you :



Var
Tut : Array[1..4] Of String;
A : Integer;
Begin
Tut[1] := 'Kane Rules';
Tut[2] := 'I Hope You Enjoyed!';
Tut[3] := 'PM Me For Help';
Tut[4] := 'Im Always Here :D';
For A := 1 to 4 Do
Writeln(Tut[A])
End.


This will Writeln All Of Them. I do hope this helped you with Arrays! PM Me For More Questions. Enjoy!

*Also On Kaitnieks.Com*

XxKanexX
04-12-2006, 03:36 PM
I suggest reading my new array tutorial. (It's in my sig. Red color).

This dosn't supply much information. But i posted anyway because it's shorter and simpler for the new people. ;)