What is returned to the calling statement is the last item processed in the function, so all you should have to do is to place the handle you are calling the new data table as the last item, and it will return it to the calling variable. See the simple example below
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt2 = New Table( "lookup",
New Column( "Sex", character, values( {"F", "M"} ) ),
New Column( "Avg Height", values( {68, 70} ) )
);
joinTables = Function( {x1, x2, m1},{},
dtFinal = x1 << join( With( x2 ), Merge same name columns(1), Match Columns( Column( m1 ) == Column( m1 ) ) );
dtFinal;
);
dtSlopeTable=joinTables(dt,dt2,"Sex");
show(dtSlopeTable);
Jim