Movie frames not updating

I am trying to write a function that makes a movie from a 3D stack of .tiff images (DataCube). I need to add a textbox to every frame of the movie with information about the temperature at which the frame was captured. The temperature information is stored in a text wave (TempData). If I run the statements in the for loop portion as separate commands then the code works. However, when I compile the procedure pasted below and run the function, the created movie just contains the first frame repeated several times and there isn't any text box in that frame.

Function MakeMovieFrom3DWave(DataCube,TempData)

    Wave DataCube,TempData
    variable i
    
    NewMovie /F=10/O as "NewMovie.avi"
    
    Make/o/n=(dimsize(DataCube,0),dimsize(DataCube,1)) frame
    
    NewImage/N=FrameGraph frame
    
    for (i=0; i < dimsize(DataCube,2); i+=1)
                
        frame = DataCube[p][q][i]
        TextBox/C/n=temperature TempData[i]
        
        DoUpdate
        AddMovieFrame
        
        print i        

    endfor
    
    CloseMovie
    KillWindow FrameGraph
    Killwaves frame
end

I need help in figuring out why this procedure is not behaving as intended.

Thank you.

You need to change the declaration for the wave parameter TempData to Wave/T, so that Igor knows that this wave contains text data.

Function MakeMovieFrom3DWave(DataCube,TempData)

    Wave DataCube
    Wave/T TempData
    variable i
    Display DataCube
    NewMovie /F=10/O as "NewMovie.avi"
   
    Make/o/n=(dimsize(DataCube,0),dimsize(DataCube,1)) frame
   
    NewImage/N=FrameGraph frame
   
    for (i=0; i < dimsize(DataCube,2); i+=1)
               
        frame = DataCube[p][q][i]
        TextBox/C/n=temperature TempData[i]
       
        DoUpdate
        AddMovieFrame
       
        print i        

    endfor
   
    CloseMovie
    KillWindow FrameGraph
    Killwaves frame
end

 

Suggestion from just from a quick glance at your code: Declare Wave Datacube and Wave/T TempData?

In the textbox command it expects a string and right now you are declaring a numeric wave called TempData. Is this a textwave? If so Wave/T will solve it. If not, you will need to make a string and do assign num2str(TempData[i]) to it with each iteration and use that in the textbox. 

Also, I'm not sure that this code is going to create the kind of movie you're intending. You don't say which version of Igor you're using, but starting with Igor 7, the target window when you call NewMovie is remembered and used by AddMovieFrame. I think you want to create a movie of the image window, not the regular graph, so you need to move your NewImage call to before the NewMovie call.

I am working on Igor 7.08 64-bit. I made all the suggested modifications and everything works perfectly. Thank you so much. You guys are awesome!

Here's the final version of my code in case anybody wants to take a look:

Function MakeMovieFrom3DWave(DataCube,TempData)

    Wave DataCube
    Wave/T TempData
    variable i
   
    Make/o/n=(dimsize(DataCube,0),dimsize(DataCube,1)) frame
   
    NewImage/N=FrameGraph frame
   
    NewMovie /F=10/O as "NewMovie.avi"
   
    for (i=0; i < dimsize(DataCube,2); i+=1)
       
        frame = DataCube[p][q][i]
        TextBox/C/n=temperature TempData[i]
       
        DoUpdate
        AddMovieFrame
       
        print i

    endfor
   
    CloseMovie
    KillWindow FrameGraph
    Killwaves frame
end