Dialogue aftermath.

This is what happens after you call the dialog_run(). Here's the entire code, including the parts mentioned before:

    int  result;

    sprint f(inp_buffer,"%s\n%s\ns\n%s\nOK\nCancel\n",
                        "First string field",
			"password",
			"Yes",
			"on");

    result = dialog_run ("foo", FOOVT, FOOLT, inp_buffer);

    if (result!=0) {
            error_log("Unable to run data entry subsystem");
	    return;
    }

    dialog_parse(inp_buffer);

    if (sameas(margv[6],"OK") || sameas (margv[4],margv[6])) {
            print ("String field 1 has value \"%s\"\n",margv[0]);
            print ("String field 2 has value \"%s\"\n",margv[1]);
	    print ("Toggle has value         \"%s\"\n",margv[2]);
	    print ("List has value           \"%s\"\n",margv[3]);
    } else print ("Cancel button pressed.\n");

    

This is where using inp_buffer shows its advantages: you can parse the entire result string with a single call to dialog_parse(), which is virtually the same function we use to parse a user's input. I like re-using code!

The rest should be pretty obvious. The last datum returned by dialog_run() is the label of one of three things:

Since our dialogue only has two buttons, OK and Cancel, we check for the `OK' shortcut and an actual button `press'. The latter is done by comparing the label of the OK button (whatever it is) against the label of the button that ended the dialogue.

Alphabetic index



This page was generated with the help of DOC++.