Hello, this is JNCR and I am in a bit of a tricky situation. I have created the below as a rough representation of what I need. Don't even ask why my functions and variables are called what they are. I just made this up on the spot
.
In the procedure JNCR I want all of the Hi's available to have fun1 as Happy, and fun2 as Sad.
Example:
Since the array length is 5 (HowManyToDo const), I want the following:
Hi[0].Happy := Fun1;
Hi[0].Sad := Fun2;
Hi[1].Happy := Fun1;
Hi[1].Sad := Fun2;
Hi[2].Happy := Fun1;
Hi[2].Sad := Fun2;
Hi[3].Happy := Fun1;
Hi[3].Sad := Fun2;
Hi[4].Happy := Fun1;
Hi[4].Sad := Fun2;
The tricky thing is that this needs to be dynamic. If the user types 188 as
HowManyToDo then I want all of the Hi's Happy's and Sad's to be Fun1 and Fun2.
SCAR Code:
program NeedHelpWithArrays;
Type
Joe = Record
Happy : String;
Sad : String;
end;
Var
i, RandomCase : Integer;
Hi: array of Joe;
Const
HowManyToDo = 5;
Function Fun1: String;
begin
RandomCase := Random(5);
Case RandomCase of
0: Result := 'age'
1: Result := 'air'
2: Result := 'anger'
3: Result := 'animal'
4: Result := 'answer'
5: Result := 'apple'
end;
end;
Function Fun2: String;
begin
RandomCase := Random(5);
Case RandomCase of
0: Result := 'car'
1: Result := 'plane'
2: Result := 'foot'
3: Result := 'cheese'
4: Result := 'querty'
5: Result := 'cow'
end;
end;
Procedure JNCR;
begin
SetArrayLength(Hi,HowManyToDo);
{
In here I want all of the Hi's available to have fun1 as Happy, and fun2 as Sad.
Example:
Since the array length is 5 (HowManyToDo const), I want the following:
Hi[0].Happy := Fun1;
Hi[0].Sad := Fun2;
Hi[1].Happy := Fun1;
Hi[1].Sad := Fun2;
Hi[2].Happy := Fun1;
Hi[2].Sad := Fun2;
Hi[3].Happy := Fun1;
Hi[3].Sad := Fun2;
Hi[4].Happy := Fun1;
Hi[4].Sad := Fun2;
The tricky thing is that this needs to be dynamic. If the user types 188 as
HowManyToDo then I want all of the Hi's Happy's and Sad's to be Fun1 and Fun2.
}
end;
begin
JNCR;
end.
Any help would greatly be appreciated.
~JNCR