bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Very interesting thing happend while creating a menu item...


From: jon wackley
Subject: Very interesting thing happend while creating a menu item...
Date: Tue, 18 Feb 2003 21:07:57 -0500

Here is the usage scenario;

1.  Prompt for a numeric string from the user.
2.  If there is a non-digit in the string, create a corresponding menu item
and display it to the user.  This is a very primitive though useful
implementation of a dialog box, I'm working in a minimal system.  Works
extremely well.  For feedback purposes the first found non-digit is also
displayed.

if the user type in "a123"

Example output centred on screen;  Non digit found: 'a'...

A new user, not used to the new system pressed ESC then enter to the get
string prompt.  The string checking determined that the escape is a
non-digit and the dialog box attempted to display.  Creating a menu item
that contains an ESCAPE causes the menu item to not be created;

        menu_items_array[counter] =
            new_item(current_specifier -> menu_item_name, "");
            assert(menu_items_array[counter] != NULL);

The assert fails when there is an ESC char contained in the string passed as
the first argument (name) to new_item.  The very quick and painless way
around this was not to include the non-digit character in the dialog prompt
screen.  Just thought you may be interested in hearing about this.  asserts
are our friend :-).

Thanks,
jonw





reply via email to

[Prev in Thread] Current Thread [Next in Thread]