> Hi all,
>
> I am experiencing the problem described in article:
> http://www.fltk.org/articles.php?L744
>
> you can see a screen of the actual error here:
> http://img249.imageshack.us/i/iconerror.png/
>
> i am developing for windows only and have tested on 2000,xp,7
> same problem occurs with all.
>
> on double clicking one of my apps files i get:
> Error
> options are:
> -bg2 color
> ...
> -to[oltips]
>
> This is most frustrating as it has only occured
> since i started using an icon file with multiple sizes..
I can't answer why this would suddenly kick in when you added an icon
file, but just to help you understand how to use the FLTK args handler
I add some incomplete code from one of my applications to help you.
It took me a little while to work it out from the test/* files, and
it doesn't quite process trailing arguments in the same way as getopt
but this might clarify usage.
Cheers
D.
/* ... #includes and lots of stuff cut ... */
/*
* global flags and option strings!
*/
int helpFlag = 0;
int debugFlag = 0;
const char* optionInner = 0;
const char* optionOuter = 0;
const char* optionNodes1 = 0;
const char* optionNodes2 = 0;
const char* optionNbase = 0;
const char* optionMinMax = 0;
int arg(int argc, char **argv, int &i)
{
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
helpFlag = 1;
i += 1;
return 1;
}
if (strcmp("-d", argv[i]) == 0 || strcmp("--debug", argv[i]) == 0) {
debugFlag = 1;
i += 1;
return 1;
}
if (strcmp("-i", argv[i]) == 0 || strcmp("--inner", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionInner = argv[i+1];
i += 2;
return 2;
}
}
if (strcmp("-o", argv[i]) == 0 || strcmp("--outer", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionOuter = argv[i+1];
i += 2;
return 2;
}
}
if (strcmp("-1", argv[i]) == 0 || strcmp("--nodes1", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionNodes1 = argv[i+1];
i += 2;
return 2;
}
}
if (strcmp("-2", argv[i]) == 0 || strcmp("--nodes2", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionNodes2 = argv[i+1];
i += 2;
return 2;
}
}
if (strcmp("-b", argv[i]) == 0 || strcmp("--nbase", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionNbase = argv[i+1];
i += 2;
return 2;
}
}
if (strcmp("-m", argv[i]) == 0 || strcmp("--minmax", argv[i]) == 0) {
if (i < argc-1 && argv[i+1] != 0) {
optionMinMax = argv[i+1];
i += 2;
return 2;
}
}
return 0;
}
int extractInt(const char* text)
{
int n, bytes = 0, value = 0;
n = sscanf(text, "%d%n", &value, &bytes);
assert(n == 1 && bytes == strlen(text));
return value;
}
double extractDbl(const char* text)
{
int n, bytes = 0;
double value = 0.0;
n = sscanf(text, "%lf%n", &value, &bytes);
assert(n == 1 && bytes == strlen(text));
return value;
}
int main(int argc, char* argv[])
{
int i = 1;
if (Fl::args(argc, argv, i, arg) < argc && strcmp("--", argv[i]) != 0)
Fl::fatal( "error: unknown option: %s\n"
"usage: %s [options] -- fileName.dat\n"
" -h | --help : print extended help message\n"
" -i | --inner # : radius of inner disc
[default=0.7377]\n"
" -o | --outer # : radius of outer discs [default=2.7]\n"
" -1 | --nodes1 # : number of sectors [default=4]\n"
" -2 | --nodes2 # : number of rings [default=3]\n"
" -b | --nbase # : base node number [default=20000]\n"
" plus standard fltk options\n",
argv[i], argv[0]);
if (helpFlag)
Fl::fatal( "usage: %s [options] -- fileName.dat\n"
" -h | --help : print extended help message\n"
" -i | --inner # : radius of inner disc
[default=0.7377]\n"
" -o | --outer # : radius of outer discs [default=2.7]\n"
" -1 | --nodes1 # : number of sectors [default=4]\n"
" -2 | --nodes2 # : number of rings [default=3]\n"
" -b | --nbase # : base node number [default=20000]\n"
" plus standard fltk options:\n"
"%s\n",
argv[0], Fl::help);
Fl_Window* w = new Fl_Window(400, 430);
Box* b = new Box(5, 5, 390, 390);
LightButtons* lbs = new LightButtons(0, 400, 400, 30);
lbs->bx = b;
w->end();
b->debug = debugFlag;
if (optionInner != 0)
b->innerRadius = extractDbl(optionInner);
if (optionOuter != 0)
b->outerRadius = extractDbl(optionOuter);
if (optionNodes1 != 0)
b->nodes1 = extractInt(optionNodes1);
if (optionNodes2 != 0)
b->nodes2 = extractInt(optionNodes2);
if (optionNbase != 0)
b->nbase = extractInt(optionNbase);
if (optionMinMax != 0) {
MinMaxReader mmr;
mmr.readFile(optionMinMax);
}
if (argc > 1)
b->readFile(argv[argc-1]);
w->show(argc, argv);
Fl::run();
return(0);
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk