Results 1 to 6 of 6

Thread: Why does this not work?

  1. #1

    Why does this not work?

    Hey, just a little question:
    why does this not work?

    Code:
    if x<>xto then x += velocity*&#40; &#40;xto-x&#41;/AbsR&#40;xto-x&#41;&#41;;
    with

    Code:
    Function AbsR&#40;x&#58;real&#41;&#58;real;
    begin
         if x<0 then Result &#58;= -x;
    end;
    Cheers

    PS: btw, is tht how u return a value for a function?

  2. #2

    Why does this not work?

    There is no += operator in pascal, that's why.

  3. #3

    Why does this not work?

    Quote Originally Posted by Robert Kosek
    There is no += operator in pascal, that's why.
    no,no, I always use that. Well, maybe in strict pascal there isn't, but the compiler accepts it...

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Why does this not work?

    Because the return value of the AbsR function could be undefined.

    You are setting 'Result' if x is less than zero, but what about if x is greater than or equal to 0?

    Edit:- Just reworded this as the parser took out the less than and greater than symbols
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5

    Why does this not work?

    So what if x is not less than zero, what do you think your function will return then?
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  6. #6

    Why does this not work?

    ops: duh!
    well I'm really sorry about this! It's funny how sometimes we just don't see the obvious!
    Maybe for the fact I haven't slept more than 10h in the last 60h or so...

    Well good night, n this thread can be deleted!!! lol

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
  •