
stringbykey issue

SCooil
im having trouble trying to get stringbykey to return the right line of a string for me. ideally I'd like the function to return just "18:42:05"
#pragma rtGlobals=1 // Use modern global access method. function getstringtime(inwave) wave inwave string wavenote = note(inwave) string timestring= stringbykey("TIME", wavenote, "=", ";") print itemsinlist(wavenote,";") Print timestring END
The string wavenote has the form
VERSION = 0;
DATE = 4.Sep 2015;
TIME = 18:42:05;
SCAN_MODE = EDC;
ADC0 = 0;
ADC1 = 0;
RANGE_NUM = 1;
MONO_START_1 = -1.0;
MONO_END_1 = -1.0;
MICRO_START_1 = 10.0;
MICRO_END_1 = 30.0;
POINTS_1 = 41;
DIFFERENZ = 5.0;
TIME_PERIODE = 0.0;
SCANS = 1;
X_START = 1;
X_SIZE = 1600;
Y_START = 1;
Y_SIZE = 1200;
DATA_FORMAT = 2;
INTERATION_TIME = 1000;
AVERAGES = 0;
SAVE_MODE = 2;
ROI_X_START = 1;
ROI_X_SIZE = 1600;
ROI_Y_START = 1;
ROI_Y_SIZE = 1200;
ONLINE_INTENSITY = true;
COMMENT = ;
HORI_BINNING = 1;
VERTI_BINNING = 1;
I know that stringmatch(wavenote,"*TIME*") does return a value of 1 so the KeyStr "TIME" should work. Maybe it has something to do with the spaces in the string "TIME = 18:42:05;" not "TIME=18:42:05;" ?????
October 17, 2015 at 08:25 am - Permalink
OK I figured out the problem, by placing the string on one line the code now works. The problem is that its the program that makes the file that separates all of these values on to seperate lines with the [] symbol. I cant change that, so i have to figure out a way to remove it all when i load in my files.
any suggestions would be appreciated
October 17, 2015 at 10:41 am - Permalink
My code works! until i save it. then it deletes this square character when i save it and the function no longer works. it wont let me type the square(it just adds a carriage return) so i will use [].
I've tried adding "/r" but that doesnt work, does anyone know how to explicitly program a carriage return??
Thanks
October 17, 2015 at 11:41 am - Permalink
October 17, 2015 at 12:10 pm - Permalink
From your screen dump, it looks like your keyword/value list has a linefeed after each semicolon. I get the same printout with this:
You should remove the linefeeds, like this:
Then StringByKey should work.
I'm not sure why StringByKey works with in your keyword/value list. I would replace it with just equal, like this:
October 17, 2015 at 01:20 pm - Permalink
Hi hrodstein,
This would indeed work (As does my code) but unfortunately not in regards to this stupid [] character because the "replacestring" funcition would be looking for /n in the wavenote, which isn't there. Only this [] character.
Thanks for the help though
Simon
October 17, 2015 at 01:48 pm - Permalink
October 17, 2015 at 01:50 pm - Permalink
October 17, 2015 at 01:56 pm - Permalink