02-19-2024 12:47 AM
Hello, I have 10 string variables where I want to write different information on them. But if I don't have that information for a variable, I want it to write "no info". I know I can make a comparison for every variable with an empty string constant and put a case, if it's true, write "no info" on it. But I don't know what is the easiest way, because doing it with 10 variables is not a hard job, but imagine if I had 100.
Inserting all in a array it's a posibility and put a comparison inside with a case structure. Is there any other better option?
Solved! Go to Solution.
02-19-2024 12:56 AM
Hi lab,
@electronic_lab wrote:
Inserting all in a array it's a posibility and put a comparison inside with a case structure. Is there any other better option?
@electronic_lab wrote:
Hello, I have 10 string variables where I want to write different information on them. But if I don't have that information for a variable, I want it to write "no info".
What are "variables" in your context? You know in LabVIEW the wire is the variable?
You might use sets or maps in recent LabVIEW versions when you want to handle key-value pairs. You can even initialize them (sets, maps, or your "variables") with "no info" and write the "known values" to the "variables"…
02-19-2024 01:19 AM - edited 02-19-2024 01:20 AM
As mentioned, your terminology is not clear at all and it would help if you could attach a small example VI.
Since there is no such thing as a "10 string variable", can we assume this is a string array with 10 elements?
In one possible scenario, easiest would be to initialize the array of the desired size with "no info", keep it in a shift register and then replace elements with valid data as it arrives. Where does the good data come from?
If most elements are "no info", a map as already suggested would be most efficient. There is no scenario where you would really need a case structure.
02-19-2024 01:24 AM
To specify more, I want to write data in a database. This data is (for example): Name, Surname, Age, Gender, Adress... So i want that if I don't know the Adress for example, I let it empty, but when i press the OK button to insert in database, the empty adress enters as a "NO INFO" string. The problem is that I don't know how to do it in a simple way.
02-19-2024 01:26 AM
Hi lab,
@electronic_lab wrote:
This data is (for example): Name, Surname, Age, Gender, Adress...
You still don't explain hwo you organize your data...
Do you use a cluster of strings? Or an array of strings? Or just a bunch of string controls scattered over the frontpanel?
02-19-2024 01:36 AM
@electronic_lab wrote:
The problem is that I don't know how to do it in a simple way.
The term 'In a simple way" is very vague and it means different things to different people.
So, is simplicity the only problem? Can you achieve what you want in a complicated way? Why don't you show us your code and we will simplify it for you!
02-19-2024 01:45 AM
I have create a small VI of my original Vi. The part i want is where i press the OK button, there I want to write something where empty strings change to "NO INFO"
02-19-2024 01:57 AM - edited 02-19-2024 02:04 AM
Well, here's what I might do:
Some comments:
02-19-2024 05:33 AM
Thank you for the solution, I'm still learning of Labview because I´m pretty new. Answering your questions, the program I attached is a little part of a bigger program, and I just copied the part i had doubts.
Yes, i will use latch action buttons, I didn't change it yet. I have another event case to update some other variables taken from another database. And another one to open a file where there is the information name, surname and age, and it writes automatically. So as I need to use variables in those events, I just put all variables initialized in a first sequence structure.
I don't have plans for my timeout yet, so I may delete it.
I don't understand what you mean with the front panel and diagram maximized to the screen, could you explain it more?
02-19-2024 05:57 AM
Hi lab,
@electronic_lab wrote:
I don't understand what you mean with the front panel and diagram maximized to the screen, could you explain it more?
When you "maximize" a window then it covers the full screen (aka monitor). This is just annoying, especially for smaller frontpanels/block diagrams.
(In Windows there are 3 symbols in the upper right corner of the window border, to minimize/maximize/close the window. You clicked the maximize symbol...)
@electronic_lab wrote:
So as I need to use variables in those events, I just put all variables initialized in a first sequence structure.
You still use the word "variables": please use the word "data" instead - and try to THINK DATAFLOW!
In LabVIEW the wires are "variables", while frontpanel elements (controls/indicators) are used as data source/sink!