Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 
Reply

Case structure does not sarts!

Solved!
Go to Solution
Highlighted

Case structure does not sarts!

I have creared the vi but after matches the pattren the matching vale does not stars the specific case instead the default case runs please tell me whats the problem problem?is it in string?

code in put as text file is

 A X01 Y04
C X03 Y05
A X04 Y08
C X07 Y09
M30

0 Kudos
Message 1 of 9 (996 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

I have creared the vi but after matches the pattren the matching vale does not starts the specific case instead the default case runs please tell me whats the problem problem?is it in string? code in put as text file is A X01 Y04 C X03 Y05 A X04 Y08 C X07 Y09 M30

0 Kudos
Message 2 of 9 (993 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

I am not sure what you are trying to do with those little loops.  Are you just looking to see if there is an 'A' in the string at all?  Or are you looking for it in a specific location?

 

As it is now, you will always get an empty string out of the loop since it will only stop once it can no longer find a match.  And the output tunnel is set to use the last match.  Therefore, you will always run the Default case.

 

This is where probes could help you debug.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
0 Kudos
Message 3 of 9 (989 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

I'm looking if 'A' comes in my text file the case a should start and then, whole code which are before matching,will be matched again to separate 'X' and 'Y' and nnumbers,which are furher in the case,numbers will give me delay to start motors which will be interfaced with Ardinuo!

0 Kudos
Message 4 of 9 (982 Views)
Reply
0 Kudos
Solution
Accepted by topic author supershaheens
‎03-18-2017 05:51 AM

Re: Case structure does not sarts!

I recommend you do something like this.  Read the entire file using the Read Lines configuration of the Read From Text File.  You can then use a FOR loop with autoindexing to process each line in the file.  You then just use a single Match Pattern (no loop) to look for the beginning of your string (A or C).  Then we can do more searching for the exact parameters.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
0 Kudos
Message 5 of 9 (978 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

There comes no value after matvh pattren and no values shows in string 2 in a=file attached

0 Kudos
Message 6 of 9 (969 Views)
Reply
0 Kudos

Re: Case structure does not sarts!


supershaheens wrote:

There comes no value after matvh pattren and no values shows in string 2 in a=file attached


Well, you still have that loop I told you to remove.  Did you even look at the example I gave you?


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
0 Kudos
Message 7 of 9 (960 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

File is attached! everything is working except the while loop stop function,it should stop and led on ardiuno should stop when M30 comes,but the LED remains turned on forever,it doesnot stops

0 Kudos
Message 8 of 9 (933 Views)
Reply
0 Kudos

Re: Case structure does not sarts!

1. Your outer loop should be a FOR loop, not a WHILE loop.  This way the loop will stop when it reaches the last line of the file.

2. You do not need a seperate read of the same file.  You can just compare the current string to "M30"

3. You should initialize your port before the main loop and close it after the loop.  You can then do all of the reading and writing inside of the loop all you want.  This will help eliminate issues of constantly opening and closing resources.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
0 Kudos
Message 9 of 9 (922 Views)
Reply
0 Kudos