SRL Archive - OSR Help

Unknown Procedure Error With An Array


VastlySuperior

2012-08-12 09:24:50

Hi

Need some help here. I have changed a procedure in my script so that it will execute better and be more steamlined. Now whenever I execute this procedure where a procedure is called that passes on an interger value, I get this error. I`m certain it has to do with the delclaration of the array as it is declared as a String. My question is, what else can I declare this array as so that it will execute correctly?

Here it the code I use.

procedure Activity(Choice:Integer);             // Choose Activity to Implement
var
I: Integer;
Param: TVariantArray;
ArrayOfActivity: TStringArray;
ArrayOfChoices: TVariantArray;
Begin
If(not(loggedin))then
Exit;
Disguise('Setting Activity To Do');
WriteLn('Setting Activity To Do');
Case Choice of
0: Begin // mine clay and bank it
Disguise('mine clay and bank it');
WriteLn('Clay Loads = ' + IntToStr(TotalLoads));
ArrayOfActivity := ['DepositItems', 'WalkToMine', 'MineClay', 'BankFromMine'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
1: Begin // mine clay and soften it then bank it
Disguise('mine clay and soften it then bank it');
ArrayOfActivity := ['DepositItems', 'WalkToMine', 'MineClay', 'WalkToWater', 'SoftenClay', 'WalkToTheBank'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
2: Begin // get soft clay from bank and craft it then bank it
DisGuise('Get Soft Clay From Bank And Craft It Then Bank It');
ArrayOfActivity := ['DepositItems', 'WithdrawItems', 'WalkPottery', 'MakePottery(ChoosePottery)', 'BankFromPottery'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
3: Begin // get soft clay from bank and craft it and drop it
Disguise('get soft clay from bank and craft it and drop it');
ArrayOfActivity := ['DepositItems', 'WithdrawItems', 'WalkPottery', 'MakePottery(ChoosePottery)', 'DropItems', 'Proggy', 'BankFromPottery'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
4: Begin // mine clay,soften it,craft it,bank it
Disguise('mine clay,soften it,craft it,bank it');
ArrayOfActivity := ['DepositItems', 'WalkToMine', 'MineClay', 'WalkToWater', 'SoftenClay', 'CraftFromPump', 'MakePottery(ChoosePottery)', 'FireOven(ChoosePottery)', 'BankFromPottery'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
5: Begin // fire softpots,urns,bowls and bank it
Disguise('fire softpots,urns,bowls and bank it');

End;
6: Begin // fire softpots,urns,bowls and drop it
Disguise('fire softpots,urns,bowls and drop it');

End;
7: Begin // get clay from bank,soften it bank it
Disguise('get clay from bank,soften it bank it');
ArrayOfActivity := ['DepositItems', 'WithdrawItems', 'BankToWater', 'SoftenClay', 'WalkToTheBank'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
8: Begin // get soft clay from bank and craft it Fire It then bank it
DisGuise('Get Soft Clay From Bank And Craft It Then Bank It');
ArrayOfActivity := ['DepositItems', 'WithdrawItems', 'WalkPottery', 'MakePottery(ChoosePottery)', 'FireOven(ChoosePottery)', 'BankFromPottery'];
SetLength(ArrayOfChoices, Length(ArrayOfActivity));
If (TotalLoads = LoadsToDo) Then
Begin
FindNormalRandoms;
DepositItems;
Proggy;
LogOut;
TerminateScript;
End else
Begin
For I := 0 To High(ArrayOfActivity) Do
Begin
ArrayOfChoices[I] := CallProc(ArrayOfActivity[I], Param);
If LostMyWay then
Begin
Exit;
End
End;
End;
End;
End;
End;

I get this error on Case selection 2,4 and 8. All of them has a procedure that passes on a integer value. Like
MakePottery(ChoosePottery)

As what can I declare this array so that it will execute?

Thanks in advance.

riwu

2012-08-12 09:47:42

Hmm interesting problem…AFAIK CallProc doesn't support parameters…
There is nothing wrong with the way u declare it, it's still a string. I guess you have to change ur procedures and abandon the parameters or find another way around it.

VastlySuperior

2012-08-12 10:07:30

Ok, I can`t abandon the parameters as it is user selected what the script should do.

So even if I change the Case type, instead of using an integer to make the choice rather use a string, it will still fail as it passes on a parameter and it is not supported?

How else will I be able to do the same thing that I wanted to accomplish here, check for a boolean value if not true continue with the next procedure?

Nebula suggested I use a try except statement but I have looked for more information on that, but either I use the wrong search terms but I can`t find any information here about it or examples I can look at.

Any Ideas where I can look?

riwu

2012-08-12 10:13:50

From: VastlySuperior
Ok, I can`t abandon the parameters as it is user selected what the script should do.

So even if I change the Case type, instead of using an integer to make the choice rather use a string, it will still fail as it passes on a parameter and it is not supported?

How else will I be able to do the same thing that I wanted to accomplish here, check for a boolean value if not true continue with the next procedure?

Nebula suggested I use a try except statement but I have looked for more information on that, but either I use the wrong search terms but I can`t find any information here about it or examples I can look at.

Any Ideas where I can look?

You can always make the Const (user-set) to be 'configured' within the procedure.
Eg.
procedure MakePottery(c: integer);
begin
DoAction(c);
end;
to
procedure MakePottery;
begin
DoAction(ChoosePottery);
end;
Basically directly transferring the parameter to within the procedure itself.