Results 1 to 2 of 2

Thread: A couple of more minor questions for FreePascal.

  1. #1

    A couple of more minor questions for FreePascal.

    1. Ok so in QuickBasic, the variable TIMER would return the number version(or double) of TIME type of variable.. Which would be very helpful.

    In FreePascal, how can this be done without Lazarus?

    2. Does FreePascal contain a "Lists" feature that C++ and C# have? It could be somewhat helpful.

  2. #2

    Re: A couple of more minor questions for FreePascal.

    1. If I understand you correctly, you want define an own type for your timer variable?
    The simplest way would be:
    [pascal]
    type
    TTime = Integer; // or Double...

    ...

    var
    Timer: TTime;

    ...

    Timer := 60;
    WriteLn(Format('Time = %d', [Timer]));
    [/pascal]

    or if you want a more complex solution which also allows you set or get an integer or a double value for your timer:

    [pascal]
    type
    Time = class
    private
    fTime: Double;
    public
    function getTime(): Double; Overload;
    function getTime(): Integer; Overload;

    procedure setTime(Value: Double); Overload;
    procedure setTime(Value: Integer); Overload;
    end;

    ...

    var
    Timer: TTime;

    ...

    function TTime.getTime(): Double;
    begin
    Result := fTime;
    end;

    function TTime.getTime(): Integer;
    begin
    Result := Trunc(fTime);
    end;

    procedure TTime.setTime(Value: Double);
    begin
    fTime := Value;
    end;

    procedure TTime.setTime(Value: Integer);
    begin
    fTime := Double(Value);
    end;

    ...

    Timer := TTime.Create;
    Timer.setTime(20);
    WriteLn(IntToStr(Timer.getTime()));
    Timer.setTime(30.0);
    WriteLn(FloatToStr(Timer.getTime()));
    [/pascal]


    2. Take a look at TList and this example: http://www.delphibasics.co.uk/RTL.asp?Name=TList
    Works the same way if you use -Mobjfpc or -Mdelphi compiler switch. Since you are obviously using Lazarus, you don't need to worry about the compiler switch.
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

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
  •