-2

I have a procedure that I'm using to display some UI elements, but this error occurs. From what I could gather, this error could occur when a procedure with the same name exists, but I was not able to identify it.

What could I do to fix the problem?

procedure CashAcceptorFormTwoButtonsSplitFiveButtons(Titlu1:string; Titlu2:String;
    InfoText1, InfoText2, InfoText3:string;
    Buton1Visible:boolean; Buton1activ:boolean; Buton1titlu:string; Buton1Detaliu:string; Buton1Color:TColor;
    Buton2Visible:boolean; Buton2activ:boolean; Buton2titlu:string; Buton2Detaliu:string; Buton2Color:TColor;
    Buton3Visible:boolean; Buton3activ:boolean; Buton3titlu:string; Buton3Detaliu:string; Buton3Color:TColor;
    Buton4Visible:boolean; Buton4activ:boolean; Buton4titlu:string; Buton4Detaliu:string; Buton4Color:TColor;
    Buton5Visible:boolean; Buton5activ:boolean; Buton5titlu:string; Buton5Detaliu:string; Buton5Color:TColor;
    Buton6Visible:boolean; Buton6activ:boolean; Buton6titlu:string; Buton6Detaliu:string; Buton6Color:TColor;
    Buton7Visible:boolean; Buton7activ:boolean; Buton7titlu:string; Buton7Detaliu:string; Buton7Color:TColor
    );
    

CashAcceptorFormTwoButtonsSplitFiveButtons(
         '1. ' + IfThen(CashAcceptorCashActive,'Test text0 ', IfThen(CashEnabled,'Test text 2, ','')) + 'Test text 3',
         '2. ' + ifthen(StareStatie=1, 'Test text 4', 'Test text 5'),
         'Test text 6',
         IfThen(CodBare<>'','Test text 7' ,CurrToStr(CashAcceptorTotalCash[0]+CashAcceptorTotalVoucher[0]+CashAcceptorTotalPOS[0]+CashAcceptorTotalCartelaClienti[0])+' Test text 8'),
         CashAcceptorCIF[0],
         FrmMain.EquipNo > 0,
         active and (StareStatie=1) and (CashAcceptorPompaStateAccepting[1] or (CashAcceptorBonSecventa[1] > 0)),
         CashAcceptorPumpName[1],
         CashAcceptorPumpStateText(active, 1),
         CashAcceptorDecodePrescriereColor(1), //10
         FrmMain.EquipNo > 1,
         active and (StareStatie=1) and (CashAcceptorPompaStateAccepting[2] or (CashAcceptorBonSecventa[2] > 0)),
         CashAcceptorPumpName[2],
         CashAcceptorPumpStateText(active, 2),
         CashAcceptorDecodePrescriereColor(2),
         FrmMain.EquipNo > 2,
         active and (StareStatie=1) and (CashAcceptorPompaStateAccepting[3] or (CashAcceptorBonSecventa[3] > 0)),
         CashAcceptorPumpName[3],
         CashAcceptorPumpStateText(active, 3),
         CashAcceptorDecodePrescriereColor(3),
         FrmMain.EquipNo > 3,
         active and (StareStatie=1) and (CashAcceptorPompaStateAccepting[4] or (CashAcceptorBonSecventa[4] > 0)),
         CashAcceptorPumpName[4],
         CashAcceptorPumpStateText(active, 4),
         CashAcceptorDecodePrescriereColor(4),
         FrmMain.EquipNo > 4,
         active and (StareStatie=1) and (CashAcceptorPompaStateAccepting[5] or (CashAcceptorBonSecventa[5] > 0)),
         CashAcceptorPumpName[5],
         CashAcceptorPumpStateText(active, 5),
         CashAcceptorDecodePrescriereColor(5),
         POSEnabled,
         active and (StareStatie=1) and CashAcceptorPOSActive and (codbare = ''),
         'Test text 9',
         'Test text 10',
         clBtnFace,
         true,
         active and (StareStatie=1) and (codbare = ''),
         'Test text 11',
         'Test text 12',
         clBtnFace,
         );
Swagraffe
  • 27
  • 5
  • 2
    That extra `,` in the caller at the end of the parameter list can't be helping any. – Brian Sep 23 '20 at 12:10
  • 3
    There is only one thing that can save that code - `Ctrl+A`, `DEL`. This makes hoarders look neat and organized. At some point when you're building a hardware store you have to invest in things like boxes and shelves. You can't just make a building and dump buckets of unpackaged nuts and bolts all over the floor. This code kind of looks like that. – J... Sep 23 '20 at 12:47
  • This is ugly, ugly code. If I were you, I'd throw it all out like a bucket of dirty dishwater and start over. Learn about record types and multi-dimensional arrays. – Ken White Sep 23 '20 at 12:53
  • 3
    The code pattern is pretty common in old web forms based code where everything is passed as url parameters. Not at all a good fit for Object Pascal / Delphi but I don't think it is a reason to try and drive off a new user. – Brian Sep 23 '20 at 13:32
  • 1
    @Brian Anyone producing code that looks like this in 2020 needs to seriously consider their future in software development. This is simply unacceptable code almost anywhere. I would probably fire someone who wrote code like this. If someone is maintaining this code then it still has utility, and refactoring it out of this insane anti-pattern should be on the very top of the priority list. We're here to improve, after all, and this is a prime example of a codebase that could use some serious time in the intensive care unit. – J... Sep 23 '20 at 14:08
  • 2
    @j Not defending the code just the question asker. It was a good question - gave the actual error, some things they tried/looked at and included the actual source that contains the error so the problem could be identified. Down voting or attacking the poster for the odd code pattern exhibited in the posted source is something I don't agree with. It seems overly hostile especially to any new users and any thinking of posting their own question. – Brian Sep 23 '20 at 14:26
  • @J While trivial it is still a source of `E2034 Too many actual parameters` errors not directly covered by other questions and answers on this site. – Brian Sep 23 '20 at 17:45
  • This code was made around 2005 and I am trying to update and clean it up. This is one of the better looking parts of it. You would want to see the rest, believe me. – Swagraffe Sep 24 '20 at 08:07
  • @Swagraffe Unless there's 200,000 lines of this stuff, it's almost worth just starting over. If you're even halfway capable of writing reasonably clear and coherent code it will be faster than trying to rescue whatever it is that you've inherited. – J... Sep 24 '20 at 13:17

2 Answers2

3

If you have an extra comma at the end of the parameter list in the caller it will produce that error message. For example if you try and call:

procedure Sleep(milliseconds: Cardinal); stdcall;

with:

  Sleep(10,);

It will give a compile time error:

[dcc32 Error] Unit1.pas(28): E2034 Too many actual parameters
Brian
  • 6,717
  • 2
  • 23
  • 31
3

I checked your code with Delphi 10.4.1, adding declarations you don't showed in your question. It compile fine provided your remove the extra , before the closing ) where you call CashAcceptorFormTwoButtonsSplitFiveButtons.

fpiette
  • 11,983
  • 1
  • 24
  • 46