Results 1 to 4 of 4

Thread: Unknown Procedure Error With An Array

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Unknown Procedure Error With An Array

    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.

    Simba Code:
    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
    Simba Code:
    MakePottery(ChoosePottery)

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

    Thanks in advance.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    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.

  3. #3
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    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?

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by VastlySuperior View Post
    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.
    Simba Code:
    procedure MakePottery(c: integer);
    begin
      DoAction(c);
    end;
    to
    Simba Code:
    procedure MakePottery;
    begin
      DoAction(ChoosePottery);
    end;
    Basically directly transferring the parameter to within the procedure itself.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •