float
proc_min(FL_OBJECT *obj, float min, int nstar)

{
  float max, m;
  char t[80];

  max = 0.5 * (nstar + 1) * nstar;
  m = strtod(fl_get_input(obj), NULL);
  if (m < 5.0) {
    sprintf(t, "I suggest that you enter a number between %.2f and %.2f.", 
	    CONSTMIN, 0.5 * max);
    fl_show_message("Possible wrong input", 
		  "You can enter this number if you really want to\nbut the results will be rather senseless.", t);
  }
  if (m >= max) {
    sprintf(t, "I suggest that you enter a number between %.2f and %.2f.", 
	    CONSTMIN, 0.5 * max);
    fl_show_message("You will never get any match with this value",
		  "because it is too big.", t);
    m = min;
  }
  set_minconst(m, obj);
  return m;
}
void 
logfileC(FL_OBJECT *obj, long val) 

{
  char *format = "Can't open file '%s!";
  char *mes;

  if (state.logfile && strlen(state.logfile) < strlen(fl_get_input(obj))) {
    free(state.logfile);
  }
  state.logfile = strdup((char *) fl_get_input(obj)); 
  trim_spaces(state.logfile);
  if (state.logfp != stdout) {
    fclose(state.logfp);
  }
  state.logfp = fopen(state.logfile, "a");
  if (state.logfp == NULL) {
    mes = (char *) myalloc(sizeof(char) * 
			   (strlen(state.logfile) + strlen(format) + 1),
			   "logfileC", "mes");
    sprintf(mes, format, state.logfile);
    fl_show_message(mes, "Output is redirected to stdout again.", "");
    fl_set_input(obj, "");
    free((void *) mes);
    state.logfp = stdout;
  }
}
int
proc_minbright(FL_OBJECT *obj, int minbright)

{
  int minb;

  minb = strtol(fl_get_input(obj), NULL, 10);
  if (minb > 200) {
    fl_show_message("Just to let you know that using high",
		  "values of this parameter you may lose",
		  "a lot of good stars.");
  }
  if (minb < 50 ) {
    fl_show_message("You may get a lot of false detections",
		  "if you use this value.",
		  "");
  }
  set_countminval(minb, obj);
  return minb;
}
int
proc_firstbright(FL_OBJECT *obj, int firstbright)

{
  int fb;
  fb = strtol(fl_get_input(obj), NULL, 10);
  if (fb < 10 || fb > 100) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 10 and 100");
  }
  set_initconst(fb, obj);
  return fb;
}
int
proc_gridsize(FL_OBJECT *obj, int gridsize)

{
  int gsize;

  gsize = strtol(fl_get_input(obj), NULL, 10);
  if (gsize > 100 || gsize < 10) {
    fl_show_message("Please set this value somewhere",
		  "between 10 and 100.", "");
  }
  set_gridsize(gsize, obj);
  return gsize;
}
float
proc_maxres(FL_OBJECT *obj, float maxres)

{
  float mr;
  mr = strtod(fl_get_input(obj), NULL);
  if (mr < 0.5 || mr > 3) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 0.5 and 3");
  }
  set_maxres(mr, obj);
  return mr;
}
static PyObject *
forms_show_message(PyObject *f, PyObject *args)
{
	char *a, *b, *c;

	if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL;

	Py_BEGIN_ALLOW_THREADS
	fl_show_message(a, b, c);
	Py_END_ALLOW_THREADS

	Py_INCREF(Py_None);
	return Py_None;
}
int
proc_minstar(FL_OBJECT *obj, int minstar)

{
  int mins;

  mins = strtol(fl_get_input(obj), NULL, 10);
  if (mins > 2 || mins < 1) {
    fl_show_message("You can experiment if you really want to,",
		  "but the suggested values are 1 and 2",
		  "");
  }
  set_starminsize(mins, obj);
  return mins;
}
float
proc_maxmag(FL_OBJECT *obj, float maxmag, float minmag)

{
  float max;
  max = strtod(fl_get_input(obj), NULL);
  if (minmag >= max) {
    fl_show_message("The lowest magnitude should have lower",
		  "value than the highest magnitude.",
		  "Correct this, please!");
    max = maxmag;
  }
  set_starmaxmag(max, obj);
  return max;
}
float
proc_poserrmax(FL_OBJECT *obj, float poserrmax)

{
  float pos;

  pos = strtod(fl_get_input(obj), NULL);
  if (pos < 1 || pos > 10) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 1 and 10");
  }
  set_starerror(pos, obj);
  return pos;
}
int
proc_nstar(FL_OBJECT *obj, int nstar)

{
  int ns;

  ns = strtol(fl_get_input(obj), NULL, 10);
  if (ns < 6 || ns > 15) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 6 and 15");
  }
  set_starconst(ns, obj);
  return ns;
}
float
proc_outer(FL_OBJECT *obj, float outer, float inner)

{
  float out;
  char a[40];

  out = strtod(fl_get_input(obj), NULL);
  if (out > 20.0 || out <= inner) {
    sprintf(a, "between %.1f and 50.0", inner);
    fl_show_message("Size of the outer circle radius should be", a, "");
    out = outer;
  }
  set_outer(out, obj);
  return out;
}
float
proc_inner(FL_OBJECT *obj, float inner, float outer)

{
  float inn;
  char a[40];

  inn = strtod(fl_get_input(obj), NULL);
  if (inn < 0.1 || inn >= outer) {
    sprintf(a, "between 0.1 and %.1f", outer);
    fl_show_message("Size of the inner circle radius should be", a, "");
    inn = inner;
  }
  set_inner(inn, obj);
  return inn;
}
float
proc_sg_num(FL_OBJECT *obj, float sg_num)

{
  float sg;

  sg = strtod(fl_get_input(obj), NULL);
  if (sg <= 0) {
    fl_show_message("Please type in a positive number!",
		  "Typical good values are between 2 and 5.",
		  "");
    sg = sg_num;
  }
  set_countsigma(sg, obj);
  return sg;
}
int
proc_border(FL_OBJECT *obj, int border)

{
  int b;
  int n = state.control[state.control_num];

  b = strtol(fl_get_input(obj), NULL, 10);
  if (b > frame[n].fits.width / 2 || 
      b > frame[n].fits.height / 2) {
    fl_show_message("With this value you will get",
		  "0 detections.",
		  "");
    b = border;
  }
  set_edgesize(b, obj);
  return b;
}
RNG *CreateRNG() {
  FL_OBJECT *ap = the_gui->AEntry;
  FL_OBJECT *bp = the_gui->BEntry;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  char buf[80];
  char *cdffn;
  double a;
  double b;
  int i;
  RNG *r;

  switch (fl_get_choice(cp)) {
  case Uniform:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new UniformRNG(a,b);
    break;
  case Binomial:
    a = atof(fl_get_input(ap));
    i = atoi(fl_get_input(bp));
    r = new BinomialRNG(a,i);
    break;
  case CDF:
    CDFRNG *cdfr;
    cdffn = (char *)fl_show_input("PDF File Name","wdist.dat");
    if (cdffn == NULL)
      return NULL;
    cdfr = new CDFRNG(cdffn);
    if (cdfr->bad()) {
      fl_show_message("Can't open PDF file",cdffn,"");
      return NULL;
    }
    sprintf(buf,"%f",cdfr->min());
    fl_set_input(ap,buf);
    sprintf(buf,"%f",cdfr->max());
    fl_set_input(bp,buf);
    r = cdfr;
    break;
  case Exponential:	
    r = new ExponentialRNG();
    break;
  case Gamma:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new GammaRNG(a,b);
    break;
  case LogNormal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalRNG(a,b);
    break;
  case LogNormalLog:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalLogRNG(a,b);
    break;
  case Normal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new NormalRNG(a,b);
    break;
  case Poisson:
    a = atof(fl_get_input(ap));
    r = new PoissonRNG(a);
    break;
  }
  return r;
}