Other Functions



double evaluate(char *equation, int *error, double (*var)(char *name));
Helper function for evaluating arithmetic expressions, which may be useful in your programs even though it isn't really logically connected to the other functions (ie it's not a gui function). It evaluates the provided equation, returning the result, and storing a nonzero value in `error' if anything goes wrong. If the `var' function is not NULL, this will be called whenever a variable is encountered in the expression, allowing you to look up and return a suitable value for it. For more information on the expressions, see expressi.txt

double dime_evaluate(char *equation, int *error, double (*var)(char *name));
Like `evaluate()', but tweaked to fit Dime's purposes better: It silently accepts an empty string without error (being equivalent to "0"), it supports Unicode and it gives an error if the result is NaN.

void double2string(double x, char *buf);
Function for pretty-printing floating point numbers: The number gets at most 10 digits to the left of the decimal point, at most 9 to the right of it, and at most 10 totally. If the absolute value of the number is >= 10000000000 or < 0.000001, it is written in exponential form instead. Exponential form has at most 6 digits in the mantissa, so that the total number of digits never exceeds 9. Does not support Unicode.

void udouble2string(double val, char *buf)
Unicode-aware version of `double2string()'.

char *scancode_to_short_name(int scancode, char *buf)
Converts a keyboard scancode to a string. The string is exactly the text after `KEY_' in the macro name for the key (so the function returns "DELETE" if you feed it with KEY_DELETE). Returns the buffer, or NULL if the scancode didn't match any known key.

char *scancode_to_pretty_name(int scancode, char *buf)
The result from `scancode_to_short_name()' is sometimes an abbreviation and may contain underscores. You may want to use this function instead if you are going to display the result for the user: it returns more user-friendly strings.

int short_name_to_scancode(char *short_name)
Given the name for a key as a string (in the format given by `scancode_to_short_name()'), this function returns the scancode for the key, or -1 if the string doesn't represent any known scancode.




Back to Contents