I'm sorry for asking such a simple question, but I can't an haven't found a reference to my problem. Its fairly simple, and I don't think it will require much change over-all (I hope anyway).

By the way: Its a plugin designed for an human interaction program designed for games etc., so thus the game references.

ERROR: Compiler requests a colon after "public" keyword, but when I [b]do[/b] actually put it there it gives me another error. Ehh...?

{
    This file is part of SCAR (Shi*e Compared To AutoRune) Resource Library
    Copyright (c) 2007 by alias R0b0t1

    Player Information Routines

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}
{$MODE Delphi}
{$DEFINE Ver0.1}
{$M+}
unit UsersInc;

interface

uses Windows;

type
  TRS2Player = class
    private
//---------------------------------------------------------
    protected
//---------------------------------------------------------
    public
      IsMem: Boolean;
      UName: String;
      UPass: String;
      UNick: String;
      UBool: Array of Boolean;
      UInts: Array of Integer;
      UStrings: Array of String;
      UExtendeds: Array of Extended;
      constructor Create(IsMem: Boolean; UName, UPass, UNick: String;
                         BoolL, IntsL, ExtendedsL, StringsL: Integer); overload;
      constructor Create(IsMem: Boolean; UName, UPass, UNick: String); overload;
      constructor Create; overload;
      function SetMemb(NewValu: Boolean): Boolean;
      function SetName(NewName: String): String;
      function SetPass(NewPass: String): String;
      function SetNick(NewNick: String): String;
      procedure SetBooleanArr(NewLengthB: Integer);
      procedure SetExtendedArr(NewLengthE: Integer);
      procedure SetIntegerArr(NewLengthI: Integer);
      procedure SetStringArr(NewLengthS: Integer);
//---------------------------------------------------------
    published
      property Member: Boolean;
        read isMem;
      property Name: String;
        read UName;
      property Pass: String;
        read UPass;
      property Nick: String;
        read UNick;
  end;


implementation

constructor TRS2Player.Create;
begin
end;

constructor TRS2Player.Create(IsMem: Boolean; UName, UPass, UNick: String;
                         BoolL, IntsL, ExtendedsL, StringsL: Integer);
begin
  Try
    self.IsMem:= IsMem;
    self.UName:= UName;
    self.UPass:= UPass;
    self.UNick:= UNick;
  Except
    on E: Exception do
    begin
      Write(E.ClassName+': '+E.Message);
      Write('Lay Speak: You messed up the types! (Ints as Strings etc.)');
    end;
  Try
    SetLength(UBool, BoolL);
    SetLength(UInts, IntsL);
    SetLength(UExtendeds, ExtendedsL);
    SetLength(UStrings, Strings:);
  Except
    on E: Exception do
    begin
      Write(E.ClassName+': '+E.Message);
      Write('Lay Speak: Bad array length(s)! (0 and up is O.K.)');
    end;
end;

constructor TRS2Player.Create(IsMem: Boolean; UName, UPass, UNick: String);
begin
  Try
    self.IsMem:= IsMem;
    self.UName:= UName;
    self.UPass:= UPass;
    self.UNick:= UNick;
  Except
    on E: Exception do
    begin
      Write(E.ClassName+': '+E.Message);
      Write('Lay Speak: You messed up the types!');
    end;
end;

function TRS2Player.SetMemb(NewValu: Boolean): Boolean;
begin
  self.IsMem:= NewValu;
  Result:= NewValu;
end;

function TRS2Player.SetName(NewName: String): String;
begin
  self.UName:= NewName;
  Result:= NewName;
end;

function TRS2Player.SetPass(NewPass: String): String;
begin
  self.UPass:= NewPass;
  Result:= NewPass;
end;

function TRS2Player.SetNick(NewNick: String): String;
begin
  self.UNick:= NewNick;
  Result:= NewNick;
end;

procedure TRS2Player.SetBooleanArr(NewLengthB: Integer);
begin;
  SetLength(UBool, NewLenghtB);
end;

procedure TRS2Player.SetExtendedArr(NewLengthE: Integer);
begin;
  SetLength(UExtendeds, NewLenghtE);
end;

procedure TRS2Player.SetIntegerArr(NewLengthI: Integer);
begin;
  SetLength(UInts, NewLenghtI);
end;

procedure TRS2Player.SetStringArr(NewLengthS: Integer);
begin;
  SetLength(UStrings, NewLenghtS);
end;

end.

Recommended Answers

All 3 Replies

Try

type
TNewClass = class( TObject )
etc....

every class has to derive from some other base class;

hence

type
TBigButton = class( TButton )
etc.....

Actually just
type
tsomething = class

should be equivalent to

type
tsomething = object(TObject)

but i think that is only for later versions of Delphi so it depends what version of delphi you are using.

You can get away with just writing

type TMyObject = class

as you have done but it is not really the way Pascal and Delphi are supposed to be written. You are better of specifying

type TMyObject = class(TObject)

However, that is not the source of your problem. Actually, I am not sure what is. It would help to know which version of Delphi you are using.

I do have a few other comments on what I see here

a. Not sure why you have functions named Set... . Surely, Get would make more sense.

b. Not sure why your various Set# functions & procedures are public. I presume you have defined them with a view to providing access to properties - of which I don't see any.

c. Is there any reason why the strings passed to your Set methods cannot be passed as constants, I mean SetName(const Value:String)?

d. Self is quite redundant. There can be times when you need to use the Self reference but there is nothing in your code that warrants it.

e. When you do need to have multiple refernces to Self, or indeed any other object it is better to use with... . Caution though - when you want to use Self since there can be quite subtle errors that creep in

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.