LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string specifiers

   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

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 5
(245 Views)

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.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(191 Views)

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.

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 5
(112 Views)

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.

0 Kudos
Message 4 of 5
(109 Views)

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.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 5 of 5
(54 Views)