Error I can't figure out PLEASE HELP!!!!

Hello there.

I am trying to make a sketch for use on the arduino Mega 2560 board. I want to try to push a button, and send out a pulse from an ultrasonic range finder (MODEL HC-SRO4). I think i have the button system down, and a way for one push of the button to make only one pulse. the problem is when I try to convert the duration from pulseIN(trigPin, HIGH)[/b into the distance in inches. the error says that the function inchesConvert was not declared in scope. Is there something simple I overlooked? was I being stupid? i don't know. my code follows
const int buttonPin = 3; //declare all variables
const int echoPin = 9;
const int trigPin = 6;
int buttonState = 0;
int pulse = 0; // variables declared. moving on.
void setup() {
** Serial.begin(9600);**
** // put your setup code here, to run once:**
pinMode(buttonPin, INPUT);
pinMode(echoPin, OUTPUT);
pinMode(trigPin, INPUT); // set pin modes and begin the serial
void loop() {
** // put your main code here, to run repeatedly:**
long duration; //used for finding the duration of the echo
long inches; // used as a final count

buttonState = digitalRead(buttonPin);
if(buttonState == HIGH && pulse == 0){
** pulse = 1; // create one pulse from the button. dont want there to be any interferince.**
if(pulse == 1){
** digitalWrite(echoPin, LOW);**
** delayMicroseconds(2);**
** digitalWrite(echoPin, HIGH); // use the ultrasonic sensor**
** delayMicroseconds(10);**
** digitalWrite(echoPin, LOW);**
** duration = pulseIn(trigPin, HIGH); // meqsure the duration of the echo**

** inches = inchesConvert(duration); // run function "inchesConvert" on the duration**
pulse=0; // get set up for another push
long inchesConvert (long microseconds){
** return microseconds / 74 / 2; // function "InchesConvert"**

Serial.println(microseconds); // print final distance

please help me.

Where is this function inchesconvert. I see no function in your code

The function inchesConvert() is inside your loop(), that's one mistake. Also: microseconds is not declared.

This sort of problem will be easy to notice if you use the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) and then compare the resulting indentation to your intended program structure. It also makes your code much easier to read.

Formatting is a common courtesy to the people you expect to read your code, beneficial to your own development work, and so fast and easy. Just do it!