On 30.11.2011, at 23:43, Richard Sanders wrote:

> for(loop = 0; loop < entries; ++loop)
> {
>   sprintf(name, "%d", loop);
>    if(!preference->entryExists(name))
>      exit(2); // should not get to this but loop will have a value of
> 15 at this point

Well, you are looking for an entry that is named "15", but that is not in your 
list. You could be checking for an entry named "duck", and you won't find that 
either. This is the API to look for entries by name.

The API to look for entries by index is Fl_Preferences::entry(int ix); which 
then corresponds to Fl_Preferences::entries(); . An annotation in an 
FL_Preferences database is the same as an entry with a name (the annotation 
itself), but no value.

Fl_Preferences has no real concept of an index. There is no guarantee that 
entries will remain  in a specific order, although in reality, they will. 
That's why you won;t find any "insert" style calls.

There is a nifty helper class that will save you from using sprintf. The above 
lines can be written:


> for(loop = 0; loop < entries; ++loop)
> {
>    if(!preference->entryExists(Fl_Preferences::Name(loop))) ...

Or for more complex labels:

> for(loop = 0; loop < entries; ++loop)
> {
>    if(!preference->entryExists(Fl_Preferences::Name("menu_%d", loop))) ...

 - Matthias
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to