LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to simplify the code for generating custom error codes and messages

Solved!
Go to solution

i have designed a vi which generates error when any data entry is missing, it is working correctly, but the problem is that i want to simplify it, as it is a part of main program and it's block diagram is very large to use as such(i had tried to use this vi as subvi in main program but that is not working correctly) so i want help in simplifying the code or if there is any other better way to generate the error message.

0 Kudos
Message 1 of 4
(2,235 Views)
Solution
Accepted by topic author RChoudhary

Hi

 

As shown in a previous example, for a different question of yours, it is always good to reduce having huge block diagrams with repeated code.

 

when you a same functionality beign repeated multiple times, put it in a loop and execute it, than having 4 or 5 repetitions of the same code.

 

this will be scalable in future.

 

attached is the modified vi for you.

 

Note: when you want to simplify your program, segregate your code into functions, put each funciton inside a sub vi.

in your case, you can have the check for empty string for all the strings inside a subvi. build an array of strings and pass to the sub vi. check inside the sub vi is the strings are empty.

 

output an error boolean array. build your error string in another sub vi. wire them together.

 

 

Regards
Freelance_LV
TestAutomation Consultant
Message 2 of 4
(2,226 Views)

To Freelance LV

Thankyou

your code is excellent, it has simplified my block diagram and has solved my problem,although i am doing programming in labview since last year, but i am weak in managing the code,i always end up writing spaghetti code thankyou for your tip for simplifying the block diagram. now i am also upgrading my main program as you said by dividing each block into function and then making subvi for each function, i will soon post it into new forum and wolud look forward to seek your suggestion in that also for further improvement in that code.

0 Kudos
Message 3 of 4
(2,211 Views)

You will improve only by practice.

 

When you start developing your application, split them into modules and develop the sub modules first.

design the architecture first, decide your sub modules and then start coding. that will help you in making a clearner and better performing code.

 

good luck

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 4 of 4
(2,209 Views)