delphi - 如何清除[DCC错误]:E2035实际参数不足

标签 delphi

我是Delphi学习者。我正在寻找一些代码来转换色相,饱和度和值中的基本颜色。我已经在this forum中得到了它,并且已经实现了:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Math;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure HSVToRGB(Const H, S, V: Real; Out R, G, B: Real);
const
  SectionSize = 60/360;
var
  F: real;
  P, Q, T: real;
  Section: real;
  SectionIndex: integer;
begin
  if H < 0 then
    begin
      R:= V;
      G:= R;
      B:= R;
    end
  else
    begin
      Section:= H/SectionSize;
      SectionIndex:= Floor(Section);
      F:= Section - SectionIndex;
      P:= V * ( 1 - S );
      Q:= V * ( 1 - S * F );
      T:= V * ( 1 - S * ( 1 - F ) );
      case SectionIndex of
        0:
          begin
            R:= V;
            G:= T;
            B:= P;
          end;
        1:
          begin
            R:= Q;
            G:= V;
            B:= P;
          end;
        2:
          begin
            R:= P;
            G:= V;
            B:= T;
          end;
        3:
          begin
            R:= P;
            G:= Q;
            B:= V;
          end;
        4:
          begin
            R:= T;
            G:= P;
            B:= V;
          end;
        else
          begin
            R:= V;
            G:= P;
            B:= Q;
          end;
      end;
    end;
end;


procedure RGBToHSV(Const R, G, B: Real; Out H, S, V: Real);
var
  Range: real;
  RGB: array[0..2] of real;
  MinIndex, MaxIndex: integer;
begin
  RGB[0]:= R;
  RGB[1]:= G;
  RGB[2]:= B;

  MinIndex:= 0;
  if G < R then MinIndex:= 1;
  if B < RGB[MinIndex] then MinIndex:= 2;

  MaxIndex:= 0;
  if G > R then MaxIndex:= 1;
  if B > RGB[MaxIndex] then MaxIndex:= 2;

  Range:= RGB[MaxIndex] - RGB[MinIndex];

  if Range = 0 then
    begin
      H:= -1;
      S:= 0;
      V:= R;
    end
    else
      begin
        case MaxIndex of
          0:
            begin
              H:= (G-B)/Range;
            end;
          1:
            begin
              H:= 2 + (B-R)/Range;
            end;
          2:
            begin
              H:= 4 + (R-G)/Range;
            end;
        end;
        S:= Range/RGB[MaxIndex];
        V:= RGB[MaxIndex];
        H:= H * (1/6);
        if H < 0 then H:= 1 + H;
      end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Hue, Saturation, Value: real;
  Red, Green, Blue: integer;
begin
  Red := GetRValue(Label1.Font.Color);
  Green := GetGValue(Label1.Font.Color);
  Blue := GetBValue(Label1.Font.Color);
  Hue := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
  Saturation := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
  Value := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));
  ShowMessage (FloatToStr(Hue) +','+ FloatToStr(Saturation)+',' + FloatToStr(Value));
end;

end.


在编译时,Delphi抛出3 Error as
[DCC错误] Unit1.pas(150):E2035实际参数不足。
在下面的行中:

Hue := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));

Saturation := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));

Value := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), GetBValue(Label1.Font.Color));

如何清除错误?

最佳答案

我将尝试引导您逐步解决自己的问题。

步骤1:找出编译器错误的含义

坦白说,这个错误是不言而喻的。


实际参数不足


好吧,您没有传递足够的参数。但是,如果不是很明显,请在您喜欢的搜索引擎中输入错误消息文本和错误代码E2035(在这种情况下)。这将导致您进入documentation for the compiler error,其中说:


当对过程或函数的调用提供的参数少于过程或函数声明中指定的参数时,会出现此错误消息。


并且有一些示例来演示它如何发生。这些都是有用的信息。花一些时间仔细阅读它。

步骤2:确定导致错误的代码行

共有三个实例,如下所示:

Hue := RGBToHSV(GetRValue(Label1.Font.Color), GetGValue(Label1.Font.Color), 
  GetBValue(Label1.Font.Color));


步骤3:将我们在步骤1中学到的内容应用于失败的代码行

有4个函数/过程调用。检查每个参数。根据调用时传递的参数(即实际参数)检查函数的声明。

对于三个内部函数,参数计数匹配。但是请看对RGBToHSV的调用。该函数有六个参数,但是您仅传递了三个。



上面是遇到不了解的编译器错误时要采用的一般过程。遇到其他不同的编译器错误时,您将可以应用此技术。

关于delphi - 如何清除[DCC错误]:E2035实际参数不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17820793/

相关文章:

delphi - delphi 中的补丁例程调用

delphi - 为什么 "i := i + 1"不会给出整数和更大类型的范围检查错误?

delphi - 获取Windows ‘ShFileOperation’ API以在Delphi中递归删除文件

delphi - 使用 FastMM 了解内存分配位置

multithreading - 使用同步时出现问题

delphi - Delphi Prism/VS 2008:一键式从代码切换到设计?

delphi - 为什么我的 D2009 exe 会生成带有名为 ATTnnnnn.DAT 的附件的电子邮件

delphi - 如何识别 Delphi 程序中的命令行参数?

delphi - 如何更改 Delphi 应用程序中数字键的小数分隔符?

c# - 如何在 C# 中解密在 Delphi 中加密的字符串