I want the ultimate robust float input routine

garth kidd garth_kidd at f813.n680.fido.oz
Sun Feb 25 03:50:00 AEST 1990


Original to: dmocsny
 > While I'm shamelessly begging, how about a nicely
 > implemented
 > method to provide context-sensitive on-line help? My
 > current
 > method is unspeakably hideous, but easy to implement.

I had a help() routine that you called if the user asked for 
help. It was used in a lot of my routines, most importantly 
the routine listMgr() that handled scrolling lists of 
information...

help() looked at the global variable (char **)curHelp for 
the information to display. So, for each major area of the 
program, I'd...


/* outside the routine */

char **fooHelp = {
  "Line 1",
  "Line 2",
  "Line 3",
  NULL };

/* and inside */

curHelp=fooHelp;



Worked a treat! The help() routine used listMgr() to display 
the help, so I had to do some workarounds... a static 
variable in help() called helpLevel, and this workaround in 
help():

  if(helpLevel==2)
    return;
  helpLevel++;
  oldHelp=curHelp;
  curHelp=helpOnHelp;

  /* ... code to call listMgr, etc */

  curHelp=oldHelp;
  helpLevel--;
  return;

So, if I asked for help whilst somewhere, helpLevel would 
become 1, curHelp would be helpOnHelp, and listMgr() would 
be invoked. If help was asked for again from within listMgr 
(the user hit ?), helpLevel would become 2, and the help on 
help would be displayed via listMgr(). Any further attempts 
to get help on help on help would be ignored until the user 
dropped back...

Hope this help()ed. :-)


gk

--- FD 1.99b
 * Origin: JC's UnderWater BBS - You want tech? You got it! (3:680/813)



More information about the Comp.lang.c mailing list