Results 1 to 5 of 5

Thread: Minor SDL translation question (no hablo C muy bien)

  1. #1

    Minor SDL translation question (no hablo C muy bien)

    I'm trying to translate [urlhttp://www.gameprogrammer.com/fastevents/fastevents2.html]an SDL add-on library[/url] to Object Pascal, but I'm running up against some very strange syntax.

    while (0 >= (val = SDL_PollEvent(event)))

    I have no idea what this conditional is supposed to be evaluating. It looks like it's checking the numeric result of an assignment operation? ("val" is declared as an integer.)

    Any idea what's going on here?

  2. #2

    Minor SDL translation question (no hablo C muy bien)

    Yes, in C (val = SDL_PollEvent(event)) is evaluated as val after the assigment is executed. You can translate it as:

    val := SDL_PollEvent(event);

    while 0 >= val do
    // do something, probably uses val here again
    val := SDL_PollEvent(event);
    end;

    val is assigned before entering the while and at the end of the while, because val is assigned in the C statement for every iteration.

  3. #3

    Minor SDL translation question (no hablo C muy bien)

    I see! And looking through the code, and the headers, it appears that the function only returns 1 or 0, and the only other thing "val" is used for is to provide the return value. Therefore, I can eliminate the variable altogether, test the function's result directly in the loop, and simply end with "result := 1".

    Thanks!

  4. #4

    Minor SDL translation question (no hablo C muy bien)

    This has already been done

    I just haven't had time to commit the source to the JEDI-SDL library.

    I'll try and get round to it this weekend
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  5. #5

    Minor SDL translation question (no hablo C muy bien)

    Well, I just finished it at my end. Problem is, I can't get it to work. Any help?

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
  •