C-PLOT

Scientific Graphics and Data Analysis

12.21.8. - Adding your own commands



Within this C module you can add custom subroutines callable by two-letter mnemonics you enter in response to the interactive prompt.
int     prefilter(), postfilter();
struct  user_cmds {
        char    c_one;
        char    two;
        int     (*c_func)();
} user_cmds[] = {
        {'p', 'o', postfilter},
        {'p', 'r', prefilter},
        0,
};
prefilter() {
}
postfilter() {
}
Simply add the letters you intend to use and the name of the function in the initialization of the structure user_cmds. Also, declare your function name as a function returning an integer as is done for postfilter() and prefilter() above (although no return value is required). These two subroutines are simply illustrative of the method and can be removed from your C-module or be replaced by your own subroutines.

If the mnemonic you choose conflicts with any of the built-in fit program commands, you will be informed when the program starts and your subroutines will be inaccessible.

If you are interested in the entire line that the user has typed in response to the interactive prompt, the function
char *get_cmdbuf()
returns a pointer to a buffer containing those characters. You may examine it or parse its contents as you like.