Unity isn't reading the mesh I created

In my game, I am proceduraly drawing a mesh. I know how to draw the mesh, so now Im putting it into a function so I can call the function later. Here is my code so far:

function Start(){

var block : GameObject = new GameObject("Block");
var mesh : Mesh = new Mesh ();
var meshFilter = block.AddComponent(MeshFilter); 
block.AddComponent(MeshRenderer); 
block.renderer.material = Resources.Load("VoxelMaterial");
DrawTheMesh();
}

function DrawTheMesh() {

var vertices = new Vector3[4]; 
var triangles = new int[6];
vertices[0] = Vector3(0,0,0); 
vertices[1] = Vector3(0,0,1); 
vertices[2] = Vector3(1,0,1);
vertices[3] = Vector3(1,0,0);
triangles = [0,1,2,0,2,3];
mesh.vertices = vertices; 
mesh.triangles = triangles; 
var uvs = new Vector2[mesh.vertices.length];
for (var i=0; i < uvs.Length; i+=1) {
uvs <em>= Vector2(mesh.vertices_.x, mesh.vertices*.z);*_</em>

}

}
I know this code works just fine, because Ive drawn a shape with it before. But when I put it into a function called DrawTheMesh, it gives an error saying "unknown identifier: “mesh” ". Which doesn’t make sense, since I clearly defined it at the very beggining during the Start function. Does anyone know why its doing this?

You are declaring ‘mesh’ inside Start() which means that mesh exists only during the lifetime of that specific Start() call, and only in the scope of the Start() function. Move the declaration to the top of the file (above the start function). You should be able to initialize it there as well.