LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scan string problem

Hi everyone!

 

I am relatively new to labview programming and have got stuck to resolve to the follwing issue.

 

I have got a an alarm panel, which has a default output in the following format (in case of no alarm)

 

$IIARL,,000,V,A,*38 [default value]

 

The 000 porion shows the address of the alarm and the last two digits represent a particular code, so I am only interested in these two values.

I tried the follwing string format to scan only the requisite paramters.

 

$IIARL,,%3d,V,A,*%2d

match characters ($IIARL,,) ----- scan 3 places of decimal value (%3d) ----- match characters (,V,A,*) ----- scan 2 posiitons of decimal values (%2d)

 

After running the VI, I got the following values

adress = 0

code = 38

remaining string value = empty

 

This is nice and accpetable.

 

But when an alarm event occurs the address and code changes to lets suppose 000 > 013 and 38 > 84.

In this case output becomes

adress = 13

code = 0

remianing string value = V,A,*84

 

where, ideally I am looking for the following results

adress = 13 or 013

code = 84

remaining string value = empty

 

Best Regards

Shabbir

0 Kudos
Message 1 of 7
(2,868 Views)

It would help to debug if you attached your VI with your test cases.  That way we can see if there's a problem with the way things are being wired or if there's something more to it than just that.

0 Kudos
Message 2 of 7
(2,864 Views)

Use %d instead of %3d and %2d.  This way you can have any number of characters for the address.

 

Also, am I seeing that a comma is missing in the error message (right after the address)?  Or was that a typo?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(2,837 Views)

I would recommend to use "spreadsheet string to array", with the comma as separator. Then you can acces the fields via array index.

 

scan string problem.png

Greets, Dave
0 Kudos
Message 4 of 7
(2,829 Views)

I did exactly what you say you did, and got the expected answers of 13, 84, and an empty Remaining String.

 

Bob Schor

0 Kudos
Message 5 of 7
(2,808 Views)

@crossrulz, I think, I have tried this randomly but don't excatly remember the results

0 Kudos
Message 6 of 7
(2,782 Views)

@daveTW

 

will defintely give it a try tomorrow morning and will reprt back here

0 Kudos
Message 7 of 7
(2,777 Views)