LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CASE structure limits - dynamic?

Hello everybody
Is this possible, and if, then how, to make the CASE structure
condition dependent on variable in my program.
Egsample: I have integer and the value of this is changing during
program running, and I need from some reasons, to make the CASE
structure sensitive for the values of this integer. How I can do
this?
I know there is always way around, but I am interested in this
solution.
thanks in advance

regards
PP
0 Kudos
Message 1 of 9
(3,047 Views)
Use a shift register to strore the interger if you are using a loop.

Otherwise a global (LV2) could be used.

Either way, wire it to a case and you are running.

Is this what you were asking for?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 9
(3,047 Views)
Hi Pawel,

Ben already has given the right answer - but your question looks so funny - here are two egg-samples using shift register - in general nearly equal.

regards
wha
Download All
0 Kudos
Message 3 of 9
(3,047 Views)
You will just have to add new cases for every case you expect to see
and have a good catchall default case. If this results in too many
cases to be practical, then try to think of a way to programmatically
handle the number without using cases at all.

Douglas De Clue
ddeclue@bellsouth.net

Pawel Pocwiardowski wrote in message news:<3D3FC76C.B0276547@poczta.onet.pl>...
> Hello everybody
> Is this possible, and if, then how, to make the CASE structure
> condition dependent on variable in my program.
> Egsample: I have integer and the value of this is changing during
> program running, and I need from some reasons, to make the CASE
> structure sensitive for the values of this integer. How I can do
> this?
> I know there is al
ways way around, but I am interested in this
> solution.
> thanks in advance
>
> regards
> PP
0 Kudos
Message 4 of 9
(3,047 Views)
Hello
I am not sure I have explained it clearly, therefore I enclose
picture.
There are two integers and one CASE structure. I want to have the
CASE limits dependent "dynamically" (could be changed during
program run) on Numeric 2.
Maybe you gave me the answer, but I need it more clearly 🙂

best regards
PP


Ben wrote:
>
> Use a shift register to strore the interger if you are using a loop.
>
> Otherwise a global (LV2) could be used.
>
> Either way, wire it to a case and you are running.
>
> Is this what you were asking for?
>
> Ben
0 Kudos
Message 5 of 9
(3,047 Views)
Hi
I understand, but this is not I was asking about. I have
explained myself more clearly in post above.
Could tou please read the one post above, my answer to Ben, so we
will continue one thread.
thanks
best regards
PP


"wha@atmel" wrote:
>
> Hi Pawel,
>
> Ben already has given the right answer - but your question looks so
> funny - here are two egg-samples using shift register - in general
> nearly equal.
>
> regards
> wha
>
> -----------------------------------------------------------------
> Name: state_machine_test_sequencer.llb
> state_machine_test_sequencer.llb Type: LabVIEW VI Library (application/x-unknown-content-type-LabVIEWLibrary)
> Encodi
ng: base64
> Description: state machine
>
> Name: Test_Sequencer.llb
> Test_Sequencer.llb Type: LabVIEW VI Library (application/x-unknown-content-type-LabVIEWLibrary)
> Encoding: base64
> Description: testsequencer
0 Kudos
Message 6 of 9
(3,047 Views)
Hi Pawel,

I am starting a new thread because I think I know what you are asking for.

First of all, you can not change the values of the case structure itself BUT,
there is a way.

What I suggest is the following;

1) Code your second case as normal. Pretend it has 3 cases 0,1 &2.

2) Code the first case (just example) such that is has two cases A&B.

3)Have the first case state A return an array of (3)strings that is "Good", "Bad", and "Ugly".

4)Have the first case state B return an array of (3) strings that is "Bad", "Ugly", and "Good".

Feed the above mentioned arrays into a serach 1-d array function. Use the retuned index to select the proper case of "the second case".

If you now pass "A" to the first case structure, and "Good" to the "se
arch 1-d array" it will return an index of 0 and the second case will execute case "0".

If you pass the first case "B" and again pass "Good" to the "serach...." it will return an index of 2 and the second case will execute state "2".

So,
by manipulating the arrays returned by the first case structure, you can "dynamically" influence which of the states of the second case is called.

There are many variations on this idea that are possible. A similar approach would make it possible to select states based on wildcards and simulate "sparse enums".

Did I nail it this time?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 9
(3,047 Views)
Hi Ben
That's good advice.
I knew there are some other solutions, but since my problem is impossible to solve in the way I wanted I need to use other techniques.
thanks anyway.
regards
Pawel
0 Kudos
Message 8 of 9
(3,047 Views)
something is wrong here. I have post another letter with more
carreful explanation of what I mean, but it was done from another
computer. I see that this letter did not appear in this news
group. I shell check what happened.


Pawel Pocwiardowski
0 Kudos
Message 9 of 9
(3,047 Views)