Author: engelsman
Date: 2010-10-23 07:10:26 -0700 (Sat, 23 Oct 2010)
New Revision: 7728
Log:
examples/howto-parse-args.cxx: now with added comments and svn:keywords



Modified:
   branches/branch-1.3/examples/howto-parse-args.cxx

Modified: branches/branch-1.3/examples/howto-parse-args.cxx
===================================================================
--- branches/branch-1.3/examples/howto-parse-args.cxx   2010-10-23 13:19:37 UTC 
(rev 7727)
+++ branches/branch-1.3/examples/howto-parse-args.cxx   2010-10-23 14:10:26 UTC 
(rev 7728)
@@ -1,5 +1,5 @@
 //
-// "$Id:$"
+// "$Id$"
 //
 //     How to parse command line arguments - Duncan Gibson 2010-10-23
 //     First posted in http://www.fltk.org/newsgroups.php?gfltk.general+v:31449
@@ -7,6 +7,10 @@
 //     Shows how to decode additional command line arguments using Fl::args()
 //     on top of the "standard" options used by the toolkit itself.
 //
+//     Note that this only handles "option separateValue" rather than the
+//     usual *nix idiom of "option=value", and provides no validation nor
+//     conversion of the paramter string into ints or floats.
+//
 // Copyright 1998-2010 by Bill Spitzak and others.
 //
 // This library is free software; you can redistribute it and/or
@@ -28,15 +32,25 @@
 //
 //     http://www.fltk.org/str.php
 //
+#include <stdio.h>
+#include <string.h>
 #include <FL/Fl.H>
 #include <FL/Fl_Box.H>
 #include <FL/Fl_Window.H>
-#include "stdio.h"
-#include "string.h"
 
 int helpFlag = 0;
 char *optionString = 0;
 
+/*
+ * callback function passed to Fl::args() to parse individual argument.
+ * If there is a match, 'i' must be incremented by 2 or 1 as appropriate.
+ * If there is no match, Fl::args() will then call Fl::arg() as fallback
+ * to try to match the "standard" FLTK parameters.
+ * 
+ * Returns 2 if argv[i] matches with required parameter in argv[i+1],
+ * returns 1 if argv[i] matches on its own,
+ * returns 0 if argv[i] does not match.
+ */
 int arg(int argc, char **argv, int &i)
 {
   if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
@@ -77,10 +91,12 @@
   Fl_Box* textBox = new Fl_Box(0, 0, 300, 200);
   if (optionString != 0)
     textBox->label(optionString);
+  else
+    textBox->label("re-run with [-o|--option] text");
   mainWin->show(argc, argv);
   return Fl::run();
 }
 
 //
-// End of "$Id:$".
+// End of "$Id$".
 //


Property changes on: branches/branch-1.3/examples/howto-parse-args.cxx
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

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

Reply via email to