08-30-2025 04:26 PM
I was just playing around with FlexLogger and noticed that the user can specify a file name using things like "(Year)" and "(Minute)", etc. so that they can create a file name that is specific to their use case but has those dynamic values (e.g. rather than having them type in the year, month day, etc. before each run.) I would like to add something like that in a LabVIEW program. It wouldn't be hard to create a parser for that, but I was wondering if anything already exists. Yes, you could ask the user to use the built in string format specifiers, but I'd obviously prefer a more intuitive set of specifiers like FlexLogger uses. Does anyone know of such a tool already made?
Thanks,
DaveT
08-31-2025 03:42 AM - edited 08-31-2025 03:43 AM
Hi Dave,
define some specifiers with your users.
Then create a VI that converts those specifiers to regular format codes for the FiematIntoString function...
As your specifiers are specific to you/your users I would recommend to implement your own conversion routine.
09-01-2025 11:18 AM
Thanks. I did that. It was quite easy, as expected. I guess I was mostly wondering if there is any standard already in place. I ended up using something very similar to FlexLogger.
09-01-2025 11:22 AM
I rolled my own- it wasn't much work. I use the "$" as my format specifier since it's not used in any internal LabVIEW ones that I know of. Curly braces would probably work well, too.
"Scan String for Tokens" was the built-in function that really made this work (IIRC). It's hard to get your head around and if memory serves you'll need to specify some of the optional inputs, but you'll get there. You can use a simple "search and replace string" if you're using static things like {Year} or {UserID} or whatever, but if you want something a little more dynamic then Scan String for Tokens will work. You can use regex for that as well, but it's more fiddly and complicated than scanning for tokens (I suspect Scan String for Tokens just makes regexes for you behind the scenes, or at least something close to that).
For example, if you want the user to be able to specify an element from an array, like "$Array[7]" (or {Array[7] etc} then the regular Search and Replace String won't work since you need a wildcard character to let the user choose the array element.
So in short, "Scan String for Tokens" is a built-in but infrequently used string function that will help, but I'm not aware of any libraries that do this for you off the top of my head. Maybe someone else knows of one.
09-02-2025 10:05 AM
Another consideration is for the time as part of the filename. You will need to replace the ':' (Colon) with either a ';' (Semi-colon) or some other acceptable character for the filename.