Hi everyone!

I think I'll be on here allot from now on, pretty useful forum, well done!

Anyways, I'm doing a project for school and it's got me stuck.
See I didn't understand the error message the compiler gave me at first, but then I read it on ...some website, it says that the Float/Real variable types are not a valid ordinal type?

Basically what I need to do is create a program that would ask for six grade points, and then give a average and the symbol they reached.
Here is the error messages I received;

[Error] gradering.pas(49): Ordinal type required
[Error] gradering.pas(63): '.' expected but ';' found
[Fatal Error] gradering_p.dpr(5): Could not compile used unit 'gradering.pas'

I'm first focusing on the first error, then moving on to the second one, help with that would be appreciated as well.

Here is what I have so far, sorry for the language, I'm doing IT in an Afrikaans school.

unit gradering;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfrmGradering = class(TForm)
    pnlAgtergrond: TPanel;
    lblPunt: TLabel;
    lblAf_punt: TLabel;
    lblPunt2: TLabel;
    edtPunt: TEdit;
    lblAfvoer: TLabel;
    bmbRetry: TBitBtn;
    bmbClose: TBitBtn;
    btnTel: TButton;
    procedure btnTelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmGradering: TfrmGradering;
  iTeller : integer;
  rTotaal, rGemiddeld : real;
  sSimbool, sAfvoer : string;

implementation

{$R *.dfm}

procedure TfrmGradering.btnTelClick(Sender: TObject);
begin

  if iTeller < 6 then
    begin
      Inc(iTeller, 1);
      rTotaal := rTotaal + StrToInt(edtPunt.Text);
      lblAf_punt.Caption := IntToStr(iTeller);
    end
  else if iTeller = 6 then
    begin
      rGemiddeld := ((rTotaal / 6) * 100);
      case rGemiddeld of
         80..100 : sSimbool := 'A';
         70..79  : sSimbool := 'B';
         60..69  : sSimbool := 'C';
         50..59  : sSimbool := 'D';
         40..49  : sSimbool := 'E';
         30..39  : sSimbool := 'F';
         20..29  : sSimbool := 'G';
         else sSimbool := 'H';
      end
  end

end;

end;

end.

Thanks in advance guys!

I tryed to compile your unit,same problem like you,mine is delphi 7.
The case statement is waiting for an ordinal type as char or integer,or byte or boolean etc and you add a real type...it is the problem :'(
One of alternative is to round to integer,look at the modified unit
Of course to much end written by you that fixed by me... :D

unit gradering;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfrmGradering = class(TForm)
    pnlAgtergrond: TPanel;
    lblPunt: TLabel;
    lblAf_punt: TLabel;
    lblPunt2: TLabel;
    edtPunt: TEdit;
    lblAfvoer: TLabel;
    bmbRetry: TBitBtn;
    bmbClose: TBitBtn;
    btnTel: TButton;
    procedure btnTelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmGradering: TfrmGradering;
  iTeller : integer;
  rTotaal, rGemiddeld : real;
  sSimbool, sAfvoer : string;

implementation

{$R *.dfm}

procedure TfrmGradering.btnTelClick(Sender: TObject);
begin

  if iTeller < 6 then
    begin
      Inc(iTeller, 1);
      rTotaal := rTotaal + StrToInt(edtPunt.Text);
      lblAf_punt.Caption := IntToStr(iTeller);
    end {if}
  else if iTeller = 6 then
    begin
      rGemiddeld := ((rTotaal / 6) * 100);
      case Round(rGemiddeld) of
         80..100 : sSimbool := 'A';
         70..79  : sSimbool := 'B';
         60..69  : sSimbool := 'C';
         50..59  : sSimbool := 'D';
         40..49  : sSimbool := 'E';
         30..39  : sSimbool := 'F';
         20..29  : sSimbool := 'G';
         else sSimbool := 'H';
      end ;{case}
  end; {else if begin}

end;{proc}

end. {unit}

Hey... that works!
Just added my final result messages, and compiled it without an error.
Now everything works as it says in my book! ;)

Thank you. :)

You can also change your variables to ordinal types like integers...and to divide you use 'div'

var
  frmGradering: TfrmGradering;
  iTeller : integer;
  iTotaal, iGemiddeld : integer;
  sSimbool, sAfvoer : string;

implementation

{$R *.dfm}

procedure TfrmGradering.btnTelClick(Sender: TObject);
begin
  if iTeller < 6 then
  begin
  Inc(iTeller, 1);
  iTotaal := iTotaal + StrToInt(edtPunt.Text);
  lblAf_punt.Caption := IntToStr(iTeller);
  end {if}
  else if iTeller = 6 then
  begin
    iGemiddeld := ((iTotaal div 6) * 100);

    case iGemiddeld of

    80..100 : sSimbool := 'A';

    70..79 : sSimbool := 'B';

    60..69 : sSimbool := 'C';

    50..59 : sSimbool := 'D';

    40..49 : sSimbool := 'E';

    30..39 : sSimbool := 'F';

    20..29 : sSimbool := 'G';

    else sSimbool := 'H';
    end ;{case}
  end; {else if begin}
end;{proc}
end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.