View Raw SPL
#include 

/* format value to format string */
_fi2str(val)
{
        if (isscalar(val))
        {
                /* integer modes */
                switch (val)
                {
                        case -1:
                        default:
                                return(_formafstr);

                        case 0:
                                return(_formfnstr);

                        case 1:
                                return(_formbestr);

                        case 2:
                                return(_formfxstr);

                        case 3:
                                return(_formlestr);

                        case 4:
                                return(_formgxstr);

                        case 5:
                                return(setformat());

                        case 6:
                                return(_formhxstr);

                        case 7:
                                return(_formrtstr);
                }
        }
        else
        {
                /* string values */                                

                if (strlen(val) == 0)   return(_formafstr);

                if (strcmp(val, "E", 1) == 0) return(_formbestr);
                if (strcmp(val, "e", 1) == 0) return(_formlestr);
                if (strcmp(val, "f", 1) == 0) return(_formfnstr);
                if (strcmp(val, "g", 1) == 0) return(_formgxstr);
                if (strcmp(val, "x", 1) == 0) return(_formhxstr);
                if (strcmp(val, "r", 1) == 0) return(_formrtstr);

                return(val);
        }
}