LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

STRING TABLE CONSTANTS

I am developing an application which will read and write strings extensively to a file.  All the words are made up from a defined vocabulary which can grow with the application.  I have to parse and modify many sentences using this vocabulary so I will be using many words as string constants throughout a bunch of VIs.  Here's where reuse would be great, Instead of dropping a string constant and typing the words over and over again I placed all the words in a combo box typedef constant and used this typedef throughout the application, now I can select the exact word from my lexicon as needed without worrying about spelling   any incorrectly or forgetting the exact word I am looking for.  This reuse promoted consistence throughout the application and makes maintaining the application simpler, or so I hoped.  When I expanded the vocabulary the new list was not updated as I was expecting (like using enums as a typedef) I switched to a strict typdef and still no luck with auto-updating.  I could use a enum and typecast it back to a string but this would make the program more complex and add many unneeded function calls.  Is there a way around this.  How can I implement such a programming technique most eloquently?  Thanks in advance,
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 1 of 5
(3,478 Views)
Tough one Paul... it made me think for awile.  As for most eloquently without adding many unneeded function calls I dont think there is, currently, a good work around.  I agree a built in string table with lookup would be useful.  For ease of programming I still prefer typedef'd enums and just access the strings associated with the items.  What helps me in some cases is to make the conversion in a SubVI using a copy of the typedef'd enum with reference.  Perhaps it would suit your needs also.  See picture for what I mean.  It has all the advantages of making constants and picking the item you want plus being able to change the enum and having the changes propigate throughout the code...
 
 

Message Edited by Chaos on 10-28-2005 09:55 AM

0 Kudos
Message 2 of 5
(3,459 Views)

Type def'd enums combined with the "format Into String" function should do the trick.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 5
(3,445 Views)
Pfff, Format into String takes an enum?
Learn something new everyday.  I agree thats much better.  New and improved Smiley Very Happy.  And to think all this time i've been using old and inferior.  Thanks for sharing!  Nice trick.
0 Kudos
Message 4 of 5
(3,439 Views)

Thanks for all the help.  I have converted all to enums and am typecasting.  Why though can I update enums as typedef automatically  (I do this all the time) but nut so with combo boxes.  I would have thought this possible an enum is just a 1:1 mapping of an int to a string while a combo box maps a string constant to its self.  The enum is much more useful but a simple combo box would have done the trick if it auto updated.  I have considered writing a program which would search and replace all instances of the control constant but it doesn't seem worth the time.  The typecast and enum does seem to be the most efficient method for my situation.  Thanks,

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 5
(3,421 Views)