View Raw SPL
/* dispatches file association load function */
_fileafloader(fname = "")
{
        local path, name, ext, dfunc, cmd;

        if (strlen(fname) > 0)
        {
                path = fileparts(fname);

                if (strlen(path) == 0)
                {
                        /* locate if no path */
                        fname = which(fname, 0);
                }

                if (strlen(fname) > 0 && fileexists(fname))
                {
                        (path, name, ext) = fileparts(fname);

                        /* function from extension */
                        dfunc = _fileafunc(ext);

                        if (strlen(dfunc) > 0)
                        {
                                /* evaluate */
                                feval(dfunc, fname);
//                                cmd = sprintf('%s("%s")', dfunc, fname);
//                                eval(cmd);
                        }
                }
        }
}