lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Forms based options (patch)


From: Bela Lubkin
Subject: Re: lynx-dev Forms based options (patch)
Date: Fri, 31 Jul 1998 15:21:04 -0700

Mike Castle wrote:

> Yes.  This code is quite convoluted here.
> Part of the problem is, every field in the form is getting processed, even
> if the user didn't change it.  So if the form is pre-filled with raw mode
> off, and they don't explicitly change it, it will stay raw mode off.

You can easily change the code so that fields which aren't being changed
will actually be recognized as not being changed.  Let's look at an
example:

    fprintf(fp0,"<select name=\"%s\">\n", ftp_sort_string);
    fprintf(fp0,"<option %s value=\"%s\">By Name</option>\n",
            (HTfileSortMethod == FILE_BY_NAME)?selected_string:empty_string,
            ftp_by_name_string);

That second fprintf() could be replaced by a utility function something
like this (completely untested...):

static char * nochange_string = "_NO_CHANGE_";

    option_value(FILE *fp, char *optname, char *optval, int selected)
    {
      fprintf(fp, "<option %s value=\"%s\">%s</option>\n",
              selected ? selected_string : empty_string,
              selected ? nochange_string : optval,
              optname);
    }

    ...
    option_value(fp0, "By Name", ftp_by_name_string,
                 (HTfileSortMethod == FILE_BY_NAME));

Then postoptions() checks for nochange_string, and makes no change.
Actually, in most (?all?) cases, that doesn't need to be checked at all:

        /*
         * ftp sort
         */
        if (!strcmp(data[i].tag, ftp_sort_string)) {
            if (!strcmp(data[i].value, ftp_by_name_string)) {
                HTfileSortMethod = FILE_BY_NAME;
            } else if (!strcmp(data[i].value, ftp_by_type_string)) {
                HTfileSortMethod = FILE_BY_TYPE;
            } else if (!strcmp(data[i].value, ftp_by_size_string)) {
                HTfileSortMethod = FILE_BY_SIZE;
            } else if (!strcmp(data[i].value, ftp_by_date_string)) {
                HTfileSortMethod = FILE_BY_DATE;
/* doesn't actually need to be coded:
 *          } else if (!strcmp(data[i].value, nochange_string)) {
 *              don't change HTfileSortMethod!
 */
            }
        }

>Bela<

reply via email to

[Prev in Thread] Current Thread [Next in Thread]