bud_wis_er_420
2013-04-01 19:06:36
Oh man here we go, this is hard to explain….:duh:
I'm trying to make a procedure that will take an IntegerArray, stored with either 1 or 2 variables and transfer that info to a type integer to be used later. All in one line!!
I keep getting an error: Variable Expected at line 78
I'm assuming it has something to do with trying to pass a variable back threw the procedure into a type variable.
This is the line I want to call…
'CopperOre.Amount' and 'TinOre.Amount' I want to both equal 14 after the above line is called(If it worked that is).
Another example with the array only having a length of one…
All I'm trying to do is set at least 2 type variables to different numbers each all on one line.
Here is the script I made to show you what I'm trying to do.
I'm trying to make a procedure that will take an IntegerArray, stored with either 1 or 2 variables and transfer that info to a type integer to be used later. All in one line!!
I keep getting an error: Variable Expected at line 78
I'm assuming it has something to do with trying to pass a variable back threw the procedure into a type variable.
This is the line I want to call…
LoadItems(['CopperOre', 'TinOre'], [CopperOre.Amount, TinOre.Amount], [14, 14]); 'CopperOre.Amount' and 'TinOre.Amount' I want to both equal 14 after the above line is called(If it worked that is).
Another example with the array only having a length of one…
LoadItems(['GoldOre'], [GoldOre.Amount], [28]); 'GoldOre.Amount' I want to equal 28 after the above line is called(If it worked that is).All I'm trying to do is set at least 2 type variables to different numbers each all on one line.
Here is the script I made to show you what I'm trying to do.
program new;
type
Item = record
Color, Tol, Bmp, Dtm, Amount, BankLoc: Integer;
Hue, Sat: Extended;
UpText: TStringArray;
end;
var
ItemsNeed: TStringArray;
CopperOre, TinOre : Item;
procedure LoadType;
begin
with CopperOre do
begin
color := 3367856;
Tol := 8;
Hue := 0.02;
Sat := 0.26;
UpText := ['Copper ore', 'pper or', 'per ore'];
Bmp := BitmapFromString(7, 8, 'meJzTsvVlYmAwNjYGkhreLfqRc40T' +
'VurY+8MFtfy7IYK6joFwQZ3gyRBBfZcwuKBe2AzDmEUmSWsN3SLgg' +
'gZR84HKzNI2m/knwwUNY5cYJ642Td1k6psIEdQxtgIyjOJXmCSvM/' +
'GORxaEIABTwyQ6');
Dtm := DTMFromString('78DA634C656060106664000108C9C0B03ED99' +
'44109CAFF0F048CB9408624449605979A28843930354E262A0C32' +
'48E632E603093E026A1281842C7E350004CF0F73');
SetBitmapName(CopperOre.Bmp, 'CopperOre.Bmp');
SetDTMName(CopperOre.Dtm, 'CopperOre.Dtm');
Amount := 0;
end;
with TinOre do
begin
color := 5921374;
Tol := 6;
Hue := 0.56;
Sat := 0.09;
UpText := ['Tin ore', 'in ore'];
Bmp := BitmapFromString(9, 9, 'meJxNzmsKwjAQBODiabSo/RFfRVot' +
'ESum6YsQQoi2pfT+V3BgYRGGJezHsIkzvU5fqygSQmDmedG2xlpvj' +
'Nvems1VMUn5JPJ+2BVdnGmmslRE4TNd2gVFpqpqmE7NvJeGqa47XH' +
'EufIf5qKfkYZn63mKPyjguIISJKiC0DmpAiJLzHQ/6HpF4h3+ioPg' +
'Dn+g1tw==');
Dtm := DTMFromString('78DA634C656060106664000108C9C0101715C' +
'52009E5FF0702C65C20431222CB824B4D14C21C981A2713150619' +
'247319F381041F013589404216BF1A00BFBE0EF7');
SetBitmapName(TinOre.Bmp, 'TinOre.Bmp');
SetDTMName(TinOre.Dtm, 'TinOre.Dtm');
Amount := 0;
end;
end;
// Procedure I'm trying to get working
procedure LoadItems(Name: TStringArray; var ItemAmt: TIntegerArray; amt: TIntegerArray);
var
i: Integer;
begin
SetArrayLength(ItemsNeed, High(Name) + 1);
SetArrayLength(ItemAmt, High(Name) + 1);
for i := 0 to High(Name) do
begin
ItemsNeed[i] := Name[i];
ItemAmt[i] := amt[i];
end;
end;
var
TIA: TIntegerArray;
i: Integer;
begin
LoadType;
writeln('Copper Start: ' + IntToStr(CopperOre.Amount));
writeln('Tin Start: ' + IntToStr(TinOre.Amount));
{1 line}
//This is the line I want to call to get the results down below in 1 line
LoadItems(['CopperOre', 'TinOre'], [CopperOre.Amount, TinOre.Amount], [14, 14]);
{3 lines}
//This is only way I can get it to work in 3 lines
{
LoadItems(['CopperOre', 'TinOre'], TIA, [14, 14]);
CopperOre.Amount := TIA[0];
TinOre.Amount := TIA[1];
}
//This will be my results: Should output 14, 14
writeln('Copper End: ' + IntToStr(CopperOre.Amount));
writeln('Tin End: ' + IntToStr(TinOre.Amount));
end.