Actually, I lie: looking at my code, what I actually seem to do (most of
the time!) is even simpler...


Here's an actual snippet...

int main(int argc, char **argv)
{
        int opts_fltk_used;

        Fl::args(argc, argv, opts_fltk_used);

        // did we use up all the args?
        if (opts_fltk_used < argc){
                my_arg = argv[opts_fltk_used];
        }
        else {
            // no more options passed
                puts("no more options");
        }

--------------------------------------
Here's another: same mechanism, but I seem to have coded this in a
different way (why?)

int main(int argc, char *argv[]) {

    int res, args = Fl::args(argc, argv, res);

    fl_register_images();

        if (res < argc) {
                load_file(argv[res]);
                datap = img->data()[0];
        }
    else {
        puts("File to load?");
        return -1;
    }

--------------------------------------
And here's the last "style":

int main(int argc, char **argv) {
  int i;

#if !defined(WIN32) && !defined(__APPLE__)
  Fl_File_Icon::load_system_icons();
#endif
  Fl::scheme("gtk+");

  if (!Fl::args(argc, argv, i)) Fl::fatal(Fl::help);

  char* fname = (i < argc) ? argv[i] : 0;

--------------------------------------
So, as far as I can see, I've used one or other of these three styles in
many bits of code (isn't cut'n'paste good?) but why I've used three
slightly different takes on the same thing I do not know...

Anyway, the take-away from this is that if you only want to let fltk eat
its usual options, then add a few filenames or whatever, you do not even
need to provide an args handler, you can just let the stock fltk args
handler do its thing, then read whatever else is left on the command
line.

If you want to create extra command line options, then you do need to
add an args handler and parse them properly, I think - see Duncan's
code.

Anyway - to the OP - I think we've probably answered your question?

Cheers,
-- 
Ian





SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to