Results 1 to 4 of 4

Thread: My own class procedure problem

  1. #1

    My own class procedure problem

    Hi again guys. Well I was try to create my class but I've got a problem. I don't know what's wrong with it, I can't find any answer too... So I post my problem here... You, experienced pascal programmers should know what's wrong, because it's stopping me... Ok, I end of bullshit, now - to the main thing. There's my Lazarus (freepascal) code:

    [pascal]
    program myclass;

    {$mode objfpc}{$H+}


    //CLASS TMYCLASS
    type
    TMyClass = class
    private
    Started : boolean;
    Paused : boolean;

    public
    constructor Create;
    procedure Start;

    end;

    //TMYCLASS PROCEDURES
    constructor TMyClass.Create;
    begin
    Started := false;
    Paused := false;
    end;

    procedure TMyClass.Start;
    begin
    Started := true;
    Paused := false;
    end;

    //-----------------------------------
    var
    Example : TMyClass;

    begin
    Example.Create;
    Example.Start;
    ReadLn;
    end.
    [/pascal]

    Problem's in TMyClass.Start procedure. When I copy all TMyClass.Start code to TMyClass.Create everything's ok. But what's wrong with it? Anyway, thanks for any replies ;-) Happy pascal coding!

  2. #2

    My own class procedure problem

    [pascal]
    ...
    Example := TMyClass.Create;
    Example.Start;
    ReadLn;
    [/pascal]

    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  3. #3

    My own class procedure problem

    Hello, the normal syntax is this:

    Code:
    var
       Example : TMyClass;
    begin
       Example := TMyClass.Create;  //create the object
       Example.Start;  //do something with it
       Example.Free;   //release it when done
    end.
    ZGameEditor - Develop 64kb games for Windows.
    Thrust for Vectrex - ROM-file and 6809 source code.

  4. #4

    My own class procedure problem

    Dammit! Forgot... I start learning C++ and it's making water from my brain... Thanks a lot guys!

Bookmarks

Posting Permissions

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