Why does my code produce a "Make error" when calling method on wave of waves (Make/WAVE)?

The code below compiles, but when I run it, the debugger is opened. The debugger's call stack only contains driver_batch(), so I have not included the gigantic monstrosity that is the the functions called in it here, just abbreviated versions. Thus, the problem seems to be in the way that I am creating and using Make/WAVE. The specific error message in the debugger is Make error: "Can't convert a wave reference wave to or from another type." I'd really appreciate it if someone could explain what this means and why it is happening.

My understanding of this is predicated on my understanding of what happens when you do Make/N=(0, 0, 0) and add to the second an third dimensions, which is as follows. Say you add a point to the first dimension several times times, it looks like a 3D stick or line made of cubes. Then, if you add a couple of data points to each wave in the second and third dimensions, the stick becomes a pine tree that only grows its horizontal branches in two directions. Is this accurate?

#pragma rtGlobals=3     // Use modern global access method and strict wave access
Function driver_batch()// use of *_batch here will allow us to use preexisting code for running script on all waves in experiment file
    //for spont, do something like below for stepDataAnalysis()
    Make /O/D/N=(0, 0, 0)/WAVE cStepCurves//dim=0: Cell number dim=1: FI dim=2: IV see display curves below for explanation
    stepDataAnalysis(cStepCurves)//changes sStepData
    DisplayCurves(cStepCurves)
end

//my explanation in comments below may not be particularly relevant.
Function stepDataAnalysis(cStepCurves)
    wave cStepCurves
        ...//add information to cStepCurves wave. by way of Insert/M=1 /M=2
 
end
Function DisplayCurves(cStepCurves)
        wave cStepCurves
        ...//I call Display on the second and third dimensions, separately, (which are wave objects if I understand correctly?) as each wave
           //represents an IV curve and FI curve (like in electrical engineering/physics or patch clamping neurons)
end


I wanted to call Display on waves, which is why I am bothering with Make/Wave in the first place. Many, many thanks to you all.
Please read the manual concerning waves containing wave references ("/WAVE" flag) carefully.

/D and /WAVE are not compatible. The first creates a double precision wave, the latter a wave of references.
Does "cStepCurves" contain one wave, i.e., one data set, or several waves,i.e., a set of data sets?
In the first case, the /WAVE flag is wrong
Make /O/D/N=(0, 0, 0) cStepCurves

In the second case the "wave" statements are missing the /WAVE flag and the Make operation has an extra /D:
Make /O/N=(0, 0, 0)/WAVE cStepCurves
...
wave cStepCurves


Adding data points to a dimension alters the size of the "cuboid" shaped data set -- no branches.
HJ


Caffeine helps reading:
My guess is that you want
Make /WAVE /N=(0,2)

This would address two waves (y-dimension) for each experiment (x-dimension)

Experiment IV-curve FI-curve
1§ 4DF6 357A 4242 666F
2 946B CDF6 FD23 23A0*
....

§calculated index
*wave references
Yes, cStepCurves contains several waves, ie a set of data sets. The post-caffeine part of your post appears to be exactly what I was looking to do- thanks so much for clearing that up.
Followup question: when using this piece of code Make /WAVE /N=(0,2) how can I insert points into the y-dimension for each of the two waves in the y-dimension? My best guess is something like
InsertPoints /M=1 DimSize(cStepCurves, 1), 1, cStepCurves cStepCurves
cStepCurves[DimSize(cStepCurves, 0) - 1][1] = foo
but then I don't know which wave in the y-dimension for that x-value I am accessing, if any at all, or both.
My guess is that you don't want to do that. You want to add to the x dimension (another experiment rather than a new curve).
Your x (actually it's "p") value is an index for your experiments. The y (actually "q") 'selects' the wave reference (q=0: FI q=1: IV)

Long story short x for the experiment, y for the waveS (sic).
HJ
Actually HJDrescher, I'm pretty sure that is what I want to do. Each x value is a separate set of data, and I need to add one piece of analysis after another, for two types of analysis, into that data. Is there a feasible way to do that? I'm having trouble even understanding how to access the y-values, the waves within the waves. Here is what I am trying to do:
Make /WAVE /N=(0,2) cStepCurves
InsertPoints/M=1 numpnts(wName[cellNum][0]), 1, wName[cStepCurves][0]
InsertPoints/M=1 numpnts(wName[cellNum][1]), 1, wName[cStepCurves][1]

It does not compile.
It may help to clean up the terminology.

X refers to the rows dimension of a 1D or greater wave.

Y refers to the columns dimension of a 2D or greater wave.

The contents of any element is called the "data value".

A 2D wave has X indices, Y indices, and data values.

Sometimes with XY pairs, we call the data value of the Y wave the "Y value", but when talking about multi-dimensional waves, stick to the terminology above.

Often it is best to create a simplified, self-contained example that anyone can easily understand and execute. Here is an simplified, self-contained example that may help:

Function Example1()
    Make/O/N=5 wave00 = p
    Make/O/N=5 wave01 = p+1
    Make/O/N=5 wave10 = p+2
    Make/O/N=5 wave11 = p+3
   
    Make/O/WAVE/N=(2,2) waves
    waves[0][0] = wave00
    waves[0][1] = wave01
    waves[1][0] = wave10
    waves[1][1] = wave11
   
    Wave w = waves[0][1]    // w is the data value of the waves matrix at row 0, column 1
    Edit w as "Row 0, column 1 of waves matrix"
   
    Wave w = waves[1][0]    // w is the data value of the waves matrix at row 1, column 0
    Edit w as "Row 1, column 0 of waves matrix"
End


What if you don't know how many rows you will eventually have in your waves matrix and want to add to it incrementally. You might try this, which does not work:
Function Example2()             // This does not work
    Make/O/N=5 wave00 = p
    Make/O/N=5 wave01 = p+1
    Make/O/N=5 wave10 = p+2
    Make/O/N=5 wave11 = p+3
   
    Make/O/WAVE/N=(0,0) waves
   
    InsertPoints 0, 1, waves            // Add a row to waves
    waves[0][0] = wave00
    waves[0][1] = wave01
   
    InsertPoints 1, 1, waves            // Add a row to waves
    waves[1][0] = wave10
    waves[1][1] = wave11
   
    Wave w = waves[0][1]
    Edit w as "Row 0, column 1 of waves matrix"
   
    Wave w = waves[1][0]
    Edit w as "Row 1, column 0 of waves matrix"
End


This does not work because, when you make a wave with 0 rows and 0 columns, it is a zero-dimensional wave, not a 2D wave. To see this, execute:
Make/O/N=(0,0) test; Print WaveDims(test)


This prints 0, not 2 as you might expect. The reason for this is that Igor determines the dimensionality of a wave by the highest dimension with a non-zero number of elements.

If you call InsertPoints on test, it becomes a 1D wave, not a 2D wave as you wanted.

You can fix this by creating the waves matrix with 0 rows and 2 columns:
Make/O/N=(0,2) test; Print WaveDims(test)


This prints 2.

Which brings us to this solution for incrementally adding rows to the waves matrix:
Function Example3()
    Make/O/N=5 wave00 = p
    Make/O/N=5 wave01 = p+1
    Make/O/N=5 wave10 = p+2
    Make/O/N=5 wave11 = p+3
   
    Make/O/WAVE/N=(0,2) waves
   
    InsertPoints 0, 1, waves            // Add a row to waves
    waves[0][0] = wave00
    waves[0][1] = wave01
   
    InsertPoints 1, 1, waves            // Add a row to waves
    waves[1][0] = wave10
    waves[1][1] = wave11
   
    Wave w = waves[0][1]
    Edit w as "Row 0, column 1 of waves matrix"
   
    Wave w = waves[1][0]
    Edit w as "Row 1, column 0 of waves matrix"
End
hrodstein, thank you for your carefully constructed explanation. But, using the terms you laid out, how do you add columns? That's the problem I have been having.
The first parameter to InsertPoints is the dimension that you want to extend. 0=rows, 1=columns.

You must start with a non-zero number of columns in order for the wave to be 2D.

If that does not solve the problem, post a simplified, self-contained example illustrating what you are trying to do.
Right, but if you do Make/O/WAVE/N=(0,2) waves, then doing InsertPoints/M=1 1, 1, waves does not tell me which column I am adding to, since the N=(0,2) means there are two columns for each row index. Or am I adding to both columns?

Edit: let me get together a self-contained example. Sorry I haven't been doing that.

Edit: In the documentation for Igor 6.37, the first parameter is said to be beforeElement, which marks the point before where the numElements points are added, which seems different from what you said. The dimension is determined by the /M flag. Is the /M flag what you meant by the first parameter, or are referring to beforeElement? What you said seems to conflict directly with the documentation for Igor 6.37.

I edited your example to demonstrate the slightly different thing I am trying to do, most specifically in the :
Function Example3()
    Make/O/N=5 wave00 = p
    Make/O/N=5 wave10 = p+2
   
    Make/O/WAVE/N=(0,2) waves
 
    InsertPoints/M=0 1, 1, waves            // Add a row to waves
    waves[0][0] = wave00
   
    InsertPoints/M=1 1, 1, waves[1]         // Add a ***column to waves
    waves[0][1] = wave10
     
    Wave w = waves[0][1]
    Edit w as "Row 0, column 1 of waves matrix"
 
    Wave w = waves[1][0]
    Edit w as "Row 1, column 0 of waves matrix"
End


Sorry. I made a mistake when I wrote:
Quote:
The first parameter to InsertPoints is the dimension that you want to extend.


It should have been
Quote:
The InsertPoints /M flag specifies the dimension that you want to extend.


I'm still unclear whether you want a fixed number of rows and a variable number of columns or if both are to be variable. Consequently I have written the following demo to do both.

I also wrote it so that you can start with a zero-dimension wave (Make/N=(0,0)). The demo uses Redimension to make the wave 2D the first time you add a row or column.

Function AddRowTo2DWave(w2D)        // Returns the row index of the new last row
    Wave w2D
   
    if (WaveDims(w2D) != 2)
        Redimension/N=(1,1) w2D
        return 0
    endif
   
    Variable numRows = DimSize(w2D, 0)
    InsertPoints/M=0 numRows, 1, w2D
   
    return numRows
End

Function AddColumnTo2DWave(w2D)     // Returns the column index of the new last column
    Wave w2D
   
    if (WaveDims(w2D) != 2)
        Redimension/N=(1,1) w2D
        return 0
    endif
   
    Variable numColumns = DimSize(w2D, 1)
    InsertPoints/M=1 numColumns, 1, w2D
   
    return numColumns
End

Function DemoAddingRowsAndColumns()
    Make/O/N=(0,0) demo2DWave = NaN     // Will be 2D after first add below
    Edit demo2DWave
    DoUpdate
   
    Variable column
    for(column=0; column<3; column+=1)
        Variable lastColumn = AddColumnTo2DWave(demo2DWave)
        demo2DWave[0][lastColumn] = column
        DoUpdate
    endfor
   
    Variable row
    for(row=1; row<4; row+=1)
        Variable lastRow = AddRowTo2DWave(demo2DWave)
        demo2DWave[lastRow][0] = row
        DoUpdate
    endfor
End


The demo uses a numeric wave but the adding of rows and columns works with any type of wave.

The DoUpdate calls are just so you can step through this in the Igor debugger and see what the wave looks like after each added row or column. Set a breakpoint on the first DoUpdate and step through the function to the end. This will show you what happens at each step.

I agree with hrodstein

I'm still unclear whether you want a fixed number of rows and a variable number of columns or if both are to be variable. Consequently I have written the following demo to do both.


Please run the following command ONE BY ONE and have a look what happens.

make /O/N=(0,0) test
edit test
insertpoints /M=0, 1, 1, test
insertpoints /M=1, 1, 1, test
insertpoints /M=0, 1, 1, test
insertpoints /M=1, 1, 1, test
insertpoints /M=0, 1, 1, test


You will see, that adding a new row also creates the cell in the second column once it is "reasonable".
Hope this helps,
HJ