06-25-2018 12:32 AM
Hi everyone,
I just start learning Labview, how can i write a while loop to do a = a +1 and this loop will stop when ''a'' equals a certain number?
I know this is pretty silly question but i can not do it since labview is unlike other programming languages, it has numeric control and numeric indicator.
Thanks for your help
Solved! Go to Solution.
06-25-2018 12:57 AM - edited 06-25-2018 12:57 AM
Hi Joe,
how can i write a while loop to do a = a +1 and this loop will stop when ''a'' equals a certain number?
You need a WHILE loop, a shift register and a comparison function. That's it.
Basic LabVIEW stuff: you don't use "variables" like in textual programming. The wire is the variable!
What have you tried so far?
Where are you stuck?
06-25-2018 01:09 AM
Thank you for your help,
I have searched it up on internet and i'm able to perform a = a + 1 by using "Local variable" and while loop. However, i tried to stop when a == 20 by using comparison and connect that comparison straight to the loop condition button but it doesn't really work.
06-25-2018 01:15 AM
hi joenguyen0109
this vil will help you
Just create 2 numeric controls on front panel and use this in block diagram.
06-25-2018 02:15 AM
Hi Joe,
However, i tried to…
Whenever your VI does not work like intended you should attach that VI instead of writing some words on the required behaviour!
How should we tell you where you did wrong? How do you want to learn from your errors if you don't know them?
06-25-2018 03:23 AM
@kartiknattar wrote:
hi joenguyen0109
this vil will help you
Just create 2 numeric controls on front panel and use this in block diagram.
I guess you just solved his homework problem.
06-25-2018 04:10 AM
06-25-2018 05:47 AM
Hi everyone, thank you for you guys's advice. I'm in the first year of uni and this is nothing to do with my homework. I was working on java and c but then my uncle told me to learn labView so i can be his assistant and as i learnt about for loop and while loop, i just try to write simple a programming to gain more understanding and this is what i tried to do today. Thank you for your help.
06-30-2018 01:53 AM
@Debrosse wrote:
I struggle with the balance between helping new coders understand data flow and giving them the solution flat out. When I started with labVIEW I always looked for example code to visualize the language. Was that wrong? I’d suggest the best way to help new coders would be to explain the theory/principle OR show the most efficient pattern to solve the problem. This way juniors can get the best of both worlds. It irks me to no end how we tend to pounce on our young for asking basic questions by assuming they are trying to just get their homework done. EVEN IF the OP is a student, showing the solution for a graphical language isn’t a bad thing. I’m sure I’m not the only one who’s stared at LV code and still took time to think through the data flow. Perhaps sharing efficient code could lead to a community of LV devs with less spaghetti code in the ecosystem; and a heck of a lot less refactoring for seniors.
Of course showing the solution to someone's homework is a bad thing. You learn nothing from copying the answers from the back of the book. But if you can coax the student arriving at a solution themselves by coaching them, well then they've accomplished the goal of the homework question by understanding how they arrived at the solution. Providing a solution should only be used as a forensics exercise to dissect exactly where you went wrong if you couldn't actually solve the homework problem.
What happens is you end up with a bunch of "developers" who don't think for themselves and are dependent on the forum to provide solutions to simple problems. You know the old saying about teaching a man to fish, etc., etc. Code exchanges are for seasoned developers to share code to avoid re-inventing a wheel that someone has already invented and should not be used as a substitute for developing good (LabVIEW) habits.