Retreiving data from flash after boot

The http://www.arduino.cc/en/Reference/PROGMEM has a clear example of how I could save and load an int value in the flash memory.

But reading the data back makes use of the variable charSet (initiliased when writing it) to get the address:

PROGMEM  prog_uint16_t charSet[]  = {65000};

unsigned int displayInt;
int k;    // counter variable

// read back a 2-byte int
 displayInt = pgm_read_word_near(charSet + k)

How can I read the data without knowing the address?

For example (hypothetical case)

unsigned int displayInt;

// read back a 2-byte int
 displayInt = pgm_read_word_near(charSet + 0)

if (digitalRead(Button) == 1){
value = displayInt + 1;    //some value based upon the value retrieved from flash
PROGMEM  prog_uint16_t charSet[]  = {value};
}

This would give errors because charSet is not known at the first call

PROGMEM  prog_uint16_t charSet[]  = {analogRead(analogPin)};

That doesn't make any sense.

Ehm, sorry made a mistake.

unsigned int displayInt;

// read back a 2-byte int
 displayInt = pgm_read_word_near(charSet + 0)

if (digitalRead(Button) == 1){
value = displayInt + 1;    //some value based upon the value retrieved from flash
PROGMEM  prog_uint16_t charSet[]  = {value};
}

You can't write to PROGMEM at run time.

For storing changing values you should use EEPROM and not program flash. Flash has a lifetime of about 10’000 writes, EEPROM about 100’000 writes. Because of that in program flash only constants are stored, values that can change (as configurations) should be stored in EEPROM.