Like Tree4Likes
  • 1 Post By AndiPersti
  • 1 Post By jimblumberg
  • 1 Post By c99tutorial
  • 1 Post By c99tutorial

A problem with cursor

This is a discussion on A problem with cursor within the C Programming forums, part of the General Programming Boards category; Hi! First of all excuse me if my english is bad or very formal! I have a problem with programing ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    4

    Question A problem with cursor

    Hi!
    First of all excuse me if my english is bad or very formal!
    I have a problem with programing a program. It have some functions such as a table, a countdown timer and a function containing two inputs.
    When I want to call the functions, until the user have not entered inputs the timer don't be shown.
    On the other hand, until the timer have not been zero, the cursor is under control of the timer.
    I want while the timer is running, the user can enter the inputs. What's your suggestion?

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    What OS are you on?

    If I understand your problem, you need a library to control the terminal (like curses).

    Bye, Andreas
    yusif likes this.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,804
    Without seeing your code we can only guess. But normally, unless using something like threads, a program executes code in sequence. So if your timer function doesn't return until it times out you will have problems.

    Jim
    yusif likes this.

  4. #4
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Thanks Andreas and Jim
    I use Windows XP and my compiler is Borland c++ 5.02
    An idea came on my mind but I don't know how to program it:
    If the cursor is controlled one millisecond by timer function and during remained 999 milliseconds controlled by other function, may I reach to my target. But as I said I don't know how!

    Joseph

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    2,804
    You need to show your code. Without seeing your code there is no way I can help.

    Jim

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    1,194
    Quote Originally Posted by yusif View Post
    An idea came on my mind but I don't know how to program it:
    If the cursor is controlled one millisecond by timer function and during remained 999 milliseconds controlled by other function, may I reach to my target.
    This is the idea of the curses "halfdelay" mode. You give the halfdelay function a value in "tenths of seconds" (1 for this value suffices). If there is no input after that time, the input routine aborts with return value ERR and you are free to do whatever you want before you try input again

    You can read my example in another post here:
    I need time remaining program?

  7. #7
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Thanks c99tutorial!
    I saw your example but I have the same problem that shansajid had. I couldn't find <curses.h> library. Do you have it for borland c++? I couldn't find it on the web by searching.

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    1,194
    If you use PDCurses, then you can download all needed files from the PDCurses homepage - PDCurses - Public Domain Curses
    The binary distribution (pdc34dllw.zip) has the headers, lib file (in COFF format) and dll. Or get the source and compile it from scratch.

    If you use the binary, you must convert the included lib file from COFF to OMF format using the Borland C++'s coff2omf tool:
    Code:
    ren pdcurses.lib pdold.lib
    coff2omf pdold.lib pdcurses.lib
    Place the .lib and .h files in appropriate places where they can be found by your compiler. Place the .dll file in your PATH or in the same directory as the executable.

    Then compile as normal
    Code:
    bcc32 timeoutexample.c pdcurses.lib
    I tried this and confirmed it works with Borland's freeware compiler. However, it is outdated. Why are you using it? If you really want to use it, you'll have to adjust the code to ANSI89 standards (e.g. all declarations must be at the top of each block, define your own bool type or just use int and change true to 1 and false to 0, etc)

  9. #9
    Registered User
    Join Date
    Dec 2012
    Posts
    4
    Thanks of all!
    Happy new year!
    Have good holiday!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lseek. Positioning cursor at end of file problem
    By bos1234 in forum C Programming
    Replies: 4
    Last Post: 04-01-2012, 12:09 PM
  2. Problem with text cursor in C
    By sureshkumarct in forum C Programming
    Replies: 3
    Last Post: 12-21-2006, 11:17 PM
  3. problem with cursor position
    By guevara in forum C Programming
    Replies: 2
    Last Post: 05-18-2004, 04:35 PM
  4. set the cursor position problem
    By SuperNewbie in forum C Programming
    Replies: 2
    Last Post: 04-08-2004, 02:09 PM
  5. Context Menu cursor problem
    By dWorkVan in forum Windows Programming
    Replies: 4
    Last Post: 07-14-2003, 11:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21