LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Core 2 - Exercise 6-1

Hi,

In the exercise book LabVIEW Core 2, there is an exercise 6-1 "Format Into String":

"You inherit an old LabVIEW application. You notice that it uses individual controls to input information into a Format Into String function. Open Format Gas Params.vi and refactor it.
- Assume you need to add a new DBL parameter (for example, Explosiveness).
- Notice that the Format Into String node needs to be expanded.
- Also notice that the format string needs to have \r\nExplosiveness:\s%f added.
Hints
- Arrays of parameter values are easily expandable to include future values.
- Some string functions can handle arrays."

 

I'm still new to LabVIEW and can't find an appropriate VI to solve this problem. Could you help me and give me a hint which functions should I use?

0 Kudos
Message 1 of 2
(2,677 Views)

I'll have to say the solution they propose is a bit weird. 

 

You'll need a way to get the values from their names. So you need a for loop, that has the Parameters and Parameter Values as non-indexing inputs. Then you need an array of names to look up. For each name to look up, use a search array, and get the found index from the Parameter Values array. Output the found values, it will become an array. Then use Index Array to get the individual results.

 

It's really a code bloat. Not sure why they'd direct students towards that. Normally you'd cluster the input variables as a solution to the growing number of inputs problem.

 

If you really want\need a names\values construction (a set basically), you should wrap all the functions for it in a library or class.

 

I'd also refactor the format into string out. Simply use a while loop to replace %parameter name% strings from a string, with the value of parameter name.

 

After the refactoring there are three places where typo's can be introduced: the set, the look up and the format into string. And no error checking.

0 Kudos
Message 2 of 2
(2,646 Views)