I'm doing a project for college. It's not too complicated but it involves a lot of data access on a linked list. Does anyone have any tips for designing an intuitive command line gui? I'm doing things like:

while (current !=NULL)
	for (i=1;i<10;i++) 
		printf("%d *Name: %s\n",i,current->data.name);
		current=current->Next;
	switch (get_char())
		case '1' : *Access item one*
		case '2' : *Access item two*
		case '3' : *Access item three*
		...
		case '0' :
			break; //displays more items

It's a bit more complicated but you get the idea. I've seen command line tools with checkmarks and such and I think they'd be very useful but unfortunately I can't find info on those anywhere.

Recommended Answers

All 6 Replies

I would suggest you make everything else work before getting over elaborate on the user interface.

Look at what you're required to do for the assignment and make sure you do that much first. If you've got time left at the end, then you can have fun making it look better.

In this case, all I'm missing is a basic sorting mechanism AND the user interface :) They also happen to be very closely linked together.

The UI approach you posted seems fine.
A simple printf of options and reading the input for the response.

Display and UI are linked. Sorting (an underlying algorithm) is not.

The best CUIs provide maximum data display and minimum query display.

For example, your program may run something like this (bold represents user input):

% [b]a.out[/b]
Crush Yer Bones's College Project
Mr. Teacher
Algorithms, Spring 2008

Enter 'help' for help.
> [b]help[/b]

add     Add a record to the database
delete  Remove a record from the database
help    Enter 'help help' for how to use the help
list    List all records by title/sort criterion
open    Open a database file
quit    Quit
save    Save changes to the database
search  Search for a specific record
sort    Change the criterion used to sort and list the records
view    View an individual record

> [b]help help[/b]

Enter 'help' followed by the command for which you want
more specific information. For example:
  help view
displays how to use the 'view' command.

> [b]help view[/b]

View an individual record. Use it by entering
  view [OPTIONS]
where the OPTIONS are one or more of the following:
  INDEX  The integer index of the record to view
  NAME   The name of the record to view
  ...
If you fail to specify any required options you will be prompted
to enter them.

> [b]view[/b]
Enter the record index (ENTER if unknown)> [b]0[/b]
Valid record numbers are 1 to 7.
Enter the record index (ENTER if unknown)> 

> [b]list[/b]

1. Annette Johansen   5. Peter Moon
2. Billy Tsu          6. Roark Murphey
3. Miriam Leigh       7. Seanaed Murphey
4. Nuala El-Sayed

>

Etc.

The main purpose of this project is to print a list of items based on their distance to the user's position. To make it easier to locate a particular item I was hoping for easy ways to add/remove displayed parameters (like display name and distance/names only and sort by name/display name and email adress and sort by email).

I have no idea on how to do that except by using a massive amount of conditionals.

> (like display name and distance/names only and sort by name/display name and email adress and sort by email).
Sounds like a spreadsheet to me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.