Storing strings in waves
mtaylor
#pragma rtGlobals=1 // Use modern global access method.
Function test()
make/T/O testTextWave={"text","goes","in","here"}
print testTextWave
print testTextWave[0]
End
Function testX()
wave testTextWave
print testTextWave
print testTextWave[0]
End
Function test()
make/T/O testTextWave={"text","goes","in","here"}
print testTextWave
print testTextWave[0]
End
Function testX()
wave testTextWave
print testTextWave
print testTextWave[0]
End
If you run test(), you get the following output:
•test()
testTextWave[0]= {"text","goes","in","here"}
text
•testX()
testTextWave[0]= {"text","goes","in","here"}
3.37009e-275
testTextWave[0]= {"text","goes","in","here"}
text
•testX()
testTextWave[0]= {"text","goes","in","here"}
3.37009e-275
can anyone tell me what I am doing wrong? The testX function can "see" the testTextWave just fine and print it in its entirety, but when asked to produce a single cell, it fails.
In your function TestX() you have to declare testtextwave was a text wave using the /T flag, otherwise, Igor will assume that it is numerical.
wave/T testTextWave
print testTextWave
print testTextWave[0]
End
February 9, 2012 at 01:46 pm - Permalink
wave/t testTextWave
print testTextWave
print testTextWave[0]
End
I don't know why the print testTextWave in the testX version in the original version worked though.
February 9, 2012 at 01:47 pm - Permalink
Was required to hold temporary values. This may seem obvious to everyone out there, but it took me hours of reading to figure it out.
February 9, 2012 at 01:52 pm - Permalink
The following function makes a string that I want to feed into another function. I can make the string just fine...
wave/t coeffnames
variable ii,cnum=numpnts(coeffnames)
string parslist = "pars[0][*]"
for(ii = 1 ; ii < cnum ; ii += 1)
parslist += ",pars["+num2istr(ii)+"][*]"
endfor
return parslist
End
but I'm not sure how to feed it into the display command
tells me that I am using the wrong datatype, which makes sense... display is expecting a wave, and i've fed it a string... the string contains a list of wavenames in what should be the proper syntax, but I can't seem to bridge the gap here. Is this even possible to do, or do I need to do this a different way? (I have worked out a loop to append traces to the graph one at a time, but thought this would be more elegant.
February 9, 2012 at 04:21 pm - Permalink
February 9, 2012 at 04:45 pm - Permalink
Execute is for executing strings as commands, but there are often better ways to do things.
February 10, 2012 at 06:08 am - Permalink
When your string of wavenames is in a semi-colon separated list called ywavelist, where every wave is in the currrent data folder or has explicit path designations, and each wave is a scaled wave, you could also do ...
LinkDisplay#LAppendtoGraph(ywavelist)
In case each y-wave needs to be plotted versus a specific x-wave, you can also use "linking" functions first, and then repeat the above for the proper outcome.
The Execute command is encapsulated in the LinkDisplay functions.
http://www.igorexchange.com/project/LinkDisplay
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
February 10, 2012 at 10:43 am - Permalink
February 11, 2012 at 11:39 pm - Permalink