Results 1 to 4 of 4

Thread: Exiting Readln Statement...

  1. #1

    Exiting Readln Statement...

    Hey guys... Yet another question...
    I want to make a main program loop that constantly checks the time, date, and day (date and day will only be checked when the time hits 12:00am) to trigger a timer, but it will accept input at the end of each repeat. Now, my problem, is that as long as nobody types anything, the loop sticks where it is at the readln(); statement until someone hits enter...

    How would I fix this? Is there any way to make one program executing 2 commands at the same time? (I'm thinking multi-threaded, but I'm really not sure...)
    --MagicRPG--

  2. #2

    Exiting Readln Statement...

    Grr, I used to know how to do this. Honestly Delphi isn't made for console applications, you're better off with FPC for that.

    Read/ReadLn do not exit until input, and the latter requires an EOL character/input for completion. I used to have a sort of "GetKey" statement that let me wait around until there was a key pressed, and then read the key from the buffer. But I can't remember, sorry. I also can't find anything helpful via Google.

    I think you're out on a limb here unless someone has a personal method or something special. I highly advise against going multithreaded in a console application unless you intend to write methods to "lock" the read/write statements. Otherwise you'll make your own nasty can of worms.

  3. #3

    Exiting Readln Statement...

    I'm not using Delphi, I'm using FPC.
    --MagicRPG--

  4. #4

    Exiting Readln Statement...

    ...You never said that in your original post. That kind of stuff helps, as I don't read every other post on the forum. Don't have the time anymore.

    RTL.pdf, pages 373-374


    Code:
    while not exit do begin
      if KeyPressed then
        exit := ReadKey in [' ',#13,#10];
    
      // ... Date stuff
    end;

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
  •