From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I match a code with its definition using a txt file and LabVIEW?

Solved!
Go to solution

I have a long list of codes and their definition. I would like to create a VI, that whenever a code is entered by the user, the VI matches that with its definition from an external txt file and shows it to the user. Is there an easy way to do this?

Thank you for your answers in advance!

Attila

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

Code? Definition?

Are you talking about a password check?

If not, what does Code and Definition look like?

 

Loading a file is easily done using the file functions. Searching that text using string functions is also easy. Where exactly is your issue? can you provide example code?

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(2,877 Views)

Basically, I am controlling an X-Ray Source using ActiveX. The PLC that receives the commands from LabVIEW can return error codes if something goes wrong, is unavailable, is not accessible etc. With a property node I can easily display the error code, however it does not have any explanation. I do have an Excel list with all the possible codes and the corresponding explanations. I trried to create an XML file and use that as a custom error code (Tools>Advanced>Edit Custom Codes etc) but the range that is reserved for the custom error codes does not match the range of my codes. Now I was thinking that, whenever I receive the error code from the PLC, I just "LabVIEW" to go and look up that code in the external list and show me the corresponding explanation.

Sorry if first my question was unclear, I hope I managed to explain it better. The list looks like:

1 Init Init failed Restart PLC

5101 Variable Condenser not found

etc

Thanks,

Attila

 

0 Kudos
Message 3 of 7
(2,869 Views)
Solution
Accepted by topic author fg.attila

Ah, OK, i understand.

I recommend to read the file during initialization of the application. Store the information in a look up table or as variant attributes (faster!).You can store the information globally by using for instance an FGV.

If an error is returned by the interface, you can search your look up table (or variant attributes) for the error code and extract the matching error description.

Please note that standard LV error cluster (including error handling functions) use the error descriptions which are loaded when LV is starting up. The text field in the error cluster is used for describing the error source (e.g. which VI generated the error).

So for your custom error handling, you either have to "misuse" the source string in the error cluster to store error description or you have to implement a complete customized error handling strategy.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 7
(2,860 Views)

Thank you for your answer! I'll attempt your suggestions. 

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

If you are just getting error codes as numbers, you can have LabVIEW do all of the work for you.  Tool->Advanced->Edit Error Codes.  You can create your own custom error codes using that dialog.  Store it in your user.lib and LabVIEW will use it when looking up error descriptions.


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
Message 6 of 7
(2,835 Views)

You could also use the General Error handler.vi by passing the VI an array of custom error codes and an array of custom error messages.

When the VI is passed one of the error codes, it finds the corresponding error message as displays it to you.

Ashley Nunn | MEng (Hons) | CLA | CTD
Senior Technical Support Engineer, NI
0 Kudos
Message 7 of 7
(2,792 Views)