LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Show once in case statement logic error

celogic.png

 

Hi , hope all is good. I've been looking at adding a dynamic enum and that looks to be ok, but as i was adding on to it and using a dialog box that i was in the right areas i noticed that as here that when the dialog box is triggered in the case statement it constantly opens after the set time, ive been trying various latches and catches but cant seem to get the box to trigger once then trigger again if a new true is chosen.

ive setup a folder with text files a b c being false and x y z being true.

when x for example is true it should flag then do nothing until for example  y is chosen then should open the box again.

 

any help on this would be appreciated

 

regards

0 Kudos
Message 1 of 5
(220 Views)

Your code makes absolutely no sense. Once the inner case gets called with a TRUE, the code stops because the "first call? is always TRIUE. 

 

Please explain how you are running this. There is no toplevel loop, so I assume you are using the "continuous run" mode (This is a debugging tool which basically restarts the VI after completion, not a valid way to run a program)

 

Please take a step back and explain the various states of the program, how the user interacts, and what should happen as a result of the interaction. After that you should be able to design a proper state machine that does exactly what you want it to do.

 

To get better help, you should also include a set of typical input files. (I also don't have openG  tools installed, but the same functionality is included in plain LabVIEW already. No need for toolkits)

0 Kudos
Message 2 of 5
(204 Views)

Thanks for the reply, this is just code i was playing around with initially it was just to get an enum that read from a folder of text files and allowed  user to pick from.

the next stage i added was to have x y z when true pop up a dialog box to indicate if it was true

then the opposite for a b c to indicate false.

i was just trying to stop the dialog box repeating and only appear once when selected.

it is a crude bit of code as i was just trying something out and wondered if there was a way without going into a state machine with some kind of latch logic.

the text files were just empty just named a.txt b.txt to allow to be called to the enum

0 Kudos
Message 3 of 5
(186 Views)

I'm not going to write down LabVIEW "code", but I will try to "walk you through" what you are trying to do, pointing out some really important features of LabVIEW that you should have gotten in the first few exposures to this Language, but which you don't seem to have realized.

  • :LabVIEW is a Data Flow language.  See those colored "lines" in your Block Diagram?  T,hose are called "wires", and data flows through them.  The color of the wire is determined by the type of data (integers are blue, floats are orange, strings are pink, and "pattern" of the wire can distinguish between a single element, a 1-D Array, or a multi-dimension Array.
  • .  Data (carried on wires) can go into and out of functions (little boxes that do things like add data from two inputs and output the sum of the (presumed numeric) inputs) and structures (While loop, Case statement).
  • A Structure or Function doesn't start until all of its inputs have data.
  • A Structure or Function doesn't exit until all of its outputs have data.
  • The common convention in LabVIEW is data flows (in a wire) from left to right.  A corollary of this convention is that inputs to a Structure or Function are on the left, and outputs are on the right.

You can learn a lot about LabVIEW Functions by right-clicking them (on the Block Diagram) and choosing "Help".  Your first function is "List Folder".  You have a Path variable (on the Front Panel) and a constant string ("*.txt").  Use "Help" to find out what to expect in the output (which you call "filenames").  

 

You pass this Array of Filenames through an OpenG "Strip Path Extension" functions.  [How did you find OpenG functions when you seem to know almost nothing about basic LabVIEW functions?].  Can you predict (without running the code) what the contents of the string array "extensions" will be?  [All the elements should be "txt" -- why is that useful to know, if you can predict it without running the code?]

 

Your code has a Control called "Ring", which is used to "select" a "True" or "False" based on the Ring value when the program begins, and put this on a Wire going into the Case Statement.  Depending on that wire, you will run either the True or False element of the Case.  The Case will run once (why?) and its inner While loop will do goodness-knows-what (depending on the value of "Ring" when you start the program, possibly ending in a "Quit after at least 5 seconds" or "run forever until the user pushes the "Abort" ("Stop") button.

 

Can you see this code makes no sense?

 

Take pencil (or pen) and paper and write down what you want to do.  Don't worry about "how" to do it yet.  Think "When" do you want input, and "how often" (as it stands, your code never lets you set the input -- it uses what ever is set in the Front Panel when you push the "Run" button).

 

There are books, tutorials, classes, LabVIEW users who might be willing to "mentor" someone interested in learning to use this wonderful (and powerful) language for creating code on an "Engineering Workbench" (note the capitalized letters -- see if you can guess what "LabVI" means).

 

Bob Schor

0 Kudos
Message 4 of 5
(159 Views)

@Chizzy42 wrote:

i was just trying to stop the dialog box repeating and only appear once when selected.


As I explained, your code stops after the dialog appears because a TRUE goes to the while loop condition when it happens and your code stops. The only way it can appear again is after you start the program again by pressing the run button OR if you are using continuous run mode (you should not!!!). In "continuous run" it simply starts the program again from scratch every time it completes and "first call?" is therefore always TRUE if  the case with the dialog is encountered

 

You need to prevent the program from continuously restarting by using a proper architecture with a toplevel loop. Don't use "continuous run"!

0 Kudos
Message 5 of 5
(140 Views)