Thread: Form style interface? Possible with standard libraries?

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    5

    Form style interface? Possible with standard libraries?

    I am learning C in a GE college class, and so far all we have done is standard line style input where only one variable can be assigned at a time. This is useful for beginning programming exercises, but I recently discovered that my calculator can also be programmed with C using standard libraries (and a few special ones for fooling with the display and accepting input from its function keys).

    I would like to be able to present an interface where the user is given a multi-field form to fill out, from which any of several fields can be entered. When the user is done they can press enter (or 'exe' in my case) and the program will then assign the variables correctly and continue with evaluation. This program should work basically the same at a shell prompt as it should on my calculator. So ignore the fact that I'm not working with the standard shell, as I can probably adapt your answers successfully to my intended environment

    An example of how I would like the program to act would look like this on the shell

    Code:
    $ ./a.out
    enter your variables:
    Molarity i:                                            *Note, these variable should be able to be
    Volume i  :                                            * entered in any order, using the arrow 
    Molarity f:                                            * keys to select the field and hitting 
    Volume f  :                                            * enter when done.
                          ****enter key****
    Your missing variable's value is : *output*evaluated*by*program*

    Does anybody have an idea of how I can do this using standard libraries?

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    You need to have a library that lets you write to arbitrary locations on the screen, and the standard library doesn't do that. Try pdcurses.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    5
    hmm, the pdcurses library looks useful for a standard platform, but all I have on the calculator is the standard c libraries and several others (none of which are specified to provide the interface i am trying for) Are there any hacks or tricks to get the sort of interface I want using standard libraries or am I going to be coding a whole new monster (which I'm probably incapable of doing so far) in order to get what I want?

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    The only thing you can do is figure out how to draw stuff on the calculator manually. I don't know anything about your hardware, so you're on your own with that.

  5. #5
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    You can keep the cursor on a line, by not using \n and using \r. You can make the cursor go back by using \b, which will erase the character also (backspace). I am alittle off to give an example now, sorry but do search the forum for some print percentage or progress bar or something there are some snippets...
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you have the conio.h file, you're in business!

  7. #7
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Quote Originally Posted by Adak View Post
    If you have the conio.h file, you're in business!
    It was stated that only standard headers are to be used.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    5
    Well, this makes me a little sad. I do have extensive control over the screen with the proprietary libraries, but I have yet to become masterful enough in C to effectively use those (as they are all fairly low level). I guess if I ever become good enough I will port a curses library to my calc, but until then I'll have to stick to standard uses of my calculator.

    Thanks for all the suggestions tho, and if you still have a new idea to add, I'm all ears.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by xuftugulus View Post
    It was stated that only standard headers are to be used.
    The word ONLY was never used, in fact:
    but I recently discovered that my calculator can also be programmed with C using standard libraries (and a few special ones for fooling with the display
    I believe conio.h may properly be considered as a neo-standard library. It was used, let's remember, by a major compiler and IDE for several years, and many of it's functions are nearly exactly duplicated in Windows today.

    Gotoxy(x, y) - Windows, gotoxy(x, y) - conio.h.

    It certainly might qualify as a "special library" for "fooling with a display".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Style Points
    By jason_m in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 06:15 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. OOP in C
    By lyx in forum C Programming
    Replies: 4
    Last Post: 11-23-2003, 01:12 PM
  4. New hard drive interface about to take over as a standard?
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-28-2003, 07:04 AM
  5. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM