regex - Elegant way to distinct Path or Entry key -
I have an application to load CAD data (custom format), either from the local file system, Or specifies a precise path to a database.
Database access is realized through a library function, which leads to the image identifier as a parameter.
The identifier's format ABC 01234T56-T
while my path is a specific Windows path (like x: \ data \ cadfiles \ cadfile001.bin
).
I would like to take a string as an argument to write a cover function which can be either a path or an identifier which calls appropriate functions to load my data.
Like this:
function codLoader (name or pash: string): tcdata;
My question: How can I decode your string beautifully is the path of an idnetifier or a file? Use a regexp? Or search for '\' and ':', which are not visible in identifiers?
Try this one
function codLoader (name or path: string) : Tcdata; If FileExists (nameOrPath) then & lt; Load from file & gt; Second & lt; Load from database & gt; End;
Comments
Post a Comment