write textWave to string

awirsing
Posts: 130
Joined: 2007-09-19
Location: Germany

Is there a simple way to write a whole textWave into a string variable avoiding a loop?

str=textWave would be the easiest, but doesn't work for some reason.

A.


andyfaff
Posts: 382
Joined: 2007-09-11
Location: Australia

Not sure about a text wave, but it's possible for a numerical wave with the sockitwavetostring operation.
It's easy to develop an xop to do what you want, but how would you delimit successive elements?


awirsing
Posts: 130
Joined: 2007-09-19
Location: Germany

andyfaff wrote:
Not sure about a text wave, but it's possible for a numerical wave with the sockitwavetostring operation.
It's easy to develop an xop to do what you want, but how would you delimit successive elements?

Well, that's the point. I don't want to delimit the elements. I just want to map the data in the memory to the string variable.

Another solution to this would be a kind of Redimension/n=1 textWave, that just removes the delimiters in the textwave preserving the whole content. One could then write str = textWave[0] or use the text wave directly.

A.


andyfaff
Posts: 382
Joined: 2007-09-11
Location: Australia

awirsing wrote:
andyfaff wrote:
Not sure about a text wave, but it's possible for a numerical wave with the sockitwavetostring operation.
It's easy to develop an xop to do what you want, but how would you delimit successive elements?

Well, that's the point. I don't want to delimit the elements. I just want to map the data in the memory to the string variable.

Another solution to this would be a kind of Redimension/n=1 textWave, that just removes the delimiters in the textwave preserving the whole content. One could then write str = textWave[0] or use the text wave directly.

A.

Ok then, that's really very simple. I can cook something up for you in the next couple of days. THe operation I was talking about before basically does the same for numeric waves, it won't be too difficult to add an option for a text wave.


andyfaff
Posts: 382
Joined: 2007-09-11
Location: Australia

I've updated the SOCKIT XOP to have an operation of this type.

string tooler = "", zippedtooler = ""
make/t test = num2istr(p)
sockitwavetostring test, tooler
print tooler
zippedtooler = zipencode(tooler)    //requires the ZIP XOP.

Only OS X version is available at the moment, but I'll build the windows version tonight.

Andy


awirsing
Posts: 130
Joined: 2007-09-19
Location: Germany

andyfaff wrote:
I've updated the SOCKIT XOP to have an operation of this type.
Only OS X version is available at the moment, but I'll build the windows version tonight.

Thanks Andy.
I will look into it. But the longer I think about it the more I feel that this feature should be built right into Igor itself.

Andreas


andyfaff
Posts: 382
Joined: 2007-09-11
Location: Australia

There are now windows and OS X versions.

Usage:

make/t tester = num2istr(p)
string wally = ""
sockitwavetostring tester, wally
print wally
// may need to record string lengths at some point
make/n=(numpnts(tester))/I/U W_stringlengths = strlen(tester)


Back to top