Entering a function

Hi folks,
I’m trying hard to learn, but this has me baffled…
I’m using the example sketch which turns on a LED, when a button is pressed. I have modified the sketch in an attempt to enter a function which will count 1000 iterations of the void loop, then turn the LED off.
What actually happens, is the function will only be entered if the button is held down continually… Code follows:

 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when pressing a pushbutton attached to pin 2. 
 The circuit:
 * LED attached from pin 13 to ground 
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe
 This example code is in the public domain.

// constants won't change. They're used here to 
// set pin numbers:

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int offski = 0;              // number of times throuh loop

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

  if (buttonState == HIGH){     
    // turn LED on and call loopy function:

    digitalWrite(ledPin, HIGH);  


/* start a loop counter delayed 10mS per count. Increment 
 variable 'offski' by one for every iteration of the loop,
 when 1000 loops have been counted, turn off the led*/

void loopy(){

  offski ++;
  delay (10); 
  if (offski >= 1000)
    digitalWrite(ledPin, LOW);

Any help would be greatly appreciated.

Where is the looping structure in the loopy() function. It runs. It exits. That's it.

the function will only be entered if the button is held down continually

You only call the function when the button state is HIGH

Thanks for the replies.
I'll try a different approach.

You perhaps meant:

void loopy()
  for (int offski = 0 ; offski < 1000 ; offski++)
    delay (10); 
  digitalWrite(ledPin, LOW);

Thanks Mark.
Yes, that works exactly as I intended.
Sort of like a FOR - NEXT loop in BASIC.

I'll keep plugging away at some examples, to see if I can make it sink in to my ageing grey cells.