12-14-2012 09:19 PM
I have a VI whose logic is dependent upon constants measured in the form of seconds. I am using the scan from file function to get these constants at the start up of the program. I need these constants to be changeable since I will be exporting this program to a .exe and do not wish to rewrite it every time a constant changes. This vi has multiple sub vi's each with different constants. I have come up with a code "&"(sub vi number)"@"(constant number)"#"(constant). I have a . txt file with the following data
"
&1@0#0.998179
&1@1#0.026460
&1@2#0.645750
&1@3#0.307942
&1@4#0.991657
&1@5#0.120003
&1@6#0.934801
&1@7#0.766183
&1@8#0.897112
&1@9#0.031959
&1@10#0.097164
&1@11#0.633646
&1@12#0.826897
&2@0#0.064892
&2@1#0.847461
&2@2#0.436721
&2@3#0.971313
&2@4#0.071508
&2@5#0.827739
&2@6#0.520286
&2@7#0.724258
&2@8#0.550402
&2@9#0.092968
&2@10#0.120922
&2@11#0.097988
&2@12#0.737177
&2@13#0.838561
&2@14#0.390609
&3@0#0.271659
&3@1#0.989720
&3@2#0.834901
&3@3#0.119405
&3@4#0.070721
&3@5#0.411167
&3@6#0.541920
&3@7#0.674712
&3@8#0.229441
&3@9#0.785293
&3@10#0.899647
&3@11#0.771071
&3@12#0.291683
&3@13#0.007504
&3@14#0.095374
&3@15#0.425513
&3@16#0.681549
&3@17#0.316395
&3@18#0.663496
"
(note the first character can not be the first "&" the way my code is written, found that out the hard way)
I have also attached a vi with the portion of the code I am having trouble with. The vi scans this .txt file and looks for the corresponding variable and sub vi code using loops. It works great up until it gets to vi code greater than 1 (i.e. &2@0#...). For some reason when this happens it the %[^] portion of the format string stops at &1@0#... Again. It is treating the number after the ampersand, but within the brackets, as though it is just an ambiguous numerical character instead of a specific number. This became apparent when I started playing with the much smaller version of the vi. Within the disable structure. The biggest problem with this, other than the fact that I can't get the constants I need, is that it is also treating the same characters out side of the brackets, but after the ampersand, as specific numbers ( the black is ambiguous and the red is specific %[^&2@0#]&2@0#%f). This means that it stops on the second line of my .txt document and is expecting to see "&2@#" and a number. It instead sees "&1@#" and a number which then generates error code 85 and ends my loop. If you have any questions about my code pleas feel free to ask. I am stuck and in a semi crunch for time.
12-15-2012 12:25 AM
can you also attach the "settings.txt" file?
12-15-2012 12:52 AM - edited 12-15-2012 12:54 AM
An alternative would be to use "scan strings for tokens". See attached. (I am simply genreating a 2D array, you probably would want to extend the inner code a bit.
12-15-2012 12:15 PM
Here is the .txt file.
12-15-2012 12:23 PM
@altenbach wrote:
An alternative would be to use "scan strings for tokens". See attached. (I am simply genreating a 2D array, you probably would want to extend the inner code a bit.
I had thought about scanning the string instead of the file for this program just to get it out of the door, if I could not get this to work, but I also was still curious as to what was causing the error. If nothing else so I can be more familiar with the function for future programs. As far as the 2D array I did not mind because I could feed it to all of the sub vi's and using the constants position (column number references the sub vi number and the row references the variable number).