Hello,
I am trying to assign text from one wave to another, that is, I have a text wave, w1, and I am trying to assign its elements to another wave, w2, but I receive the error "a wave assignment error: "An attempt was made to treat a text wave as if it were a numeric wave.""
I've tried a simplified version of what I am attempting to do:
Function Example()
Variable i
Make/T/O w1= {"a","b","c"}
Make/T/O w2
For (i=0; i<numPnts(w1); i+=1)
w2[i] = w1[i]
EndFor
End
And this work exactly how I would have expected it to. Any suggestions?
Hi,
I ran your example as posted and it worked without issue. Created 2 text waves W1 of length 3 points and W2 of 128 with a,b, and c in the right spot.
Tried on IP8.
Can you supply the non-simplified code?
Andy
Yes, that example does work exactly how you would expect it to. I have a chunk of my code pasted below. It is just a snippet of the larger procedure I am working on but this section is essentially merging data, under three different conditions, inserting the data into different parts of an already existing waves. I am receiving the error for the line:
If you create a wave reference pointing to a text wave, you need to use the /T flag so that the Igor compiler knows it is a text wave. For example:
Function Test() // Make with a simple name - Creates an automatic wave reference named textwave0 Make/O/T textwave0 Wave/T textwave0 // This is redundant - Make already creates the wave reference
// Make without a simple name - no automatic wave reference is created String name = "textwave1" Make/O/T/N=3$name = "Hello" Wave/T tw1 = $name// This is required because no automatic wave reference is created
// Reference to a text wave named textwave2 that is assumed to already exist in the current data folder Wave/T tw2 = textwave2 End
I recommend rereading this section of the help. It takes both experimentation and rereading before if all sinks in.
June 27, 2018 at 06:47 am - Permalink
Stats_StatusFlag[FirstPoint + i] = Load_Stats_StatusFlag0[i]
These two waves are both text waves. Also, I am using Igor Pro 6.3.7.2.
For (i=0; i<numPnts(EndTime); i+=1)
If (EndTime[i] >= Load_EndTime[0])
FirstPoint = i
Break
EndIf
EndFor
For (i=0; i<numPnts(Load_EndTime); i+=1)
If (EndTime[FirstPoint + i] > Load_EndTime[i])
InsertPoints FirstPoint + i, 1, EndTime
EndTime[FirstPoint + i] = Load_EndTime[i]
InsertPoints FirstPoint + i, 1, Stats_StatusFlag
Stats_StatusFlag[FirstPoint + i] = Load_Stats_StatusFlag0[i]
InsertPoints FirstPoint + i,1,Stats_Median_nm
Stats_Median_nm[FirstPoint + i] = Load_Stats_Median_nm0[i]
InsertPoints FirstPoint + i,1,Final_SMPS_Data
For (j=0; j<54; j+=1)
Final_SMPS_Data[FirstPoint + i][j] = Sorted_SMPS_Data[i][j]
EndFor
ElseIF (EndTime[FirstPoint + i] == Load_EndTime[i])
If (V_Flag == 0)
DoAlert /T="Data Already Loaded",1,"Data already loaded for this time period, would you like to overwrite the current data?"
ElseIf (V_Flag ==1)
EndTime[FirstPoint + i] = Load_EndTime[i]
Stats_StatusFlag[FirstPoint + i] = Load_Stats_StatusFlag0[i]
Stats_Median_nm[FirstPoint + i] = Load_Stats_Median_nm0[i]
For (j=0; j<54; j+=1)
Final_SMPS_Data[FirstPoint + i][j] = Sorted_SMPS_Data[i][j]
EndFor
EndIf
Else
For (i=0; i<numPnts(Load_EndTime);i+=1)
InsertPoints numPnts(EndTime), 1, EndTime
EndTime[numPnts(EndTime) - 1] = Load_EndTime[i]
InsertPoints numPnts(EndTime), 1, Stats_StatusFlag
Stats_StatusFlag[numPnts(EndTime) - 1] = Load_Stats_StatusFlag0[i]
InsertPoints numPnts(EndTime), 1, Stats_Median_nm
Stats_Median_nm[numPnts(EndTime) - 1] = Load_Stats_Median_nm0[i]
InsertPoints numPnts(EndTime), 1, Final_SMPS_Data
For (j=0; j<54; j+=1)
Final_SMPS_Data[numPnts(EndTime) - 1][j] = Sorted_SMPS_Data[i][j]
EndFor
EndFor
EndIf
EndFor
June 27, 2018 at 07:01 am - Permalink
// Make with a simple name - Creates an automatic wave reference named textwave0
Make/O/T textwave0
Wave/T textwave0 // This is redundant - Make already creates the wave reference
// Make without a simple name - no automatic wave reference is created
String name = "textwave1"
Make/O/T/N=3 $name = "Hello"
Wave/T tw1 = $name // This is required because no automatic wave reference is created
// Reference to a text wave named textwave2 that is assumed to already exist in the current data folder
Wave/T tw2 = textwave2
End
June 27, 2018 at 07:14 am - Permalink
June 27, 2018 at 07:29 am - Permalink