capturing a value as variable

howdy. this is an update of an older thread that i am unable to find (in 6 pages, so i gave up. i explained it poorly before anyway). THANK YOU to those who responded to the other thread.

here is an example of what i would want to do. i'm using a different sensor but the idea is the same.

pseudocode:

read input from potentiometer (0-1023).
let's imagine that i am constantly moving this pot, so the value is always changing.
i want to capture the value of potentiometer at the moment a tact switch is triggered...BUT NOT CONTINUOUSLY, only for the very first instant i push (and hold) that tact switch.

does anyone have a suggestion or a snippet of code for me to adapt?
thank you for your time.
nym

Something like:

#define TACT_PIN ...
#define POT_PIN ...

void setup ()
{
  pinMode (TACT_PIN, INPUT) ;
  digitalWrite (TACT_PIN, HIGH) ; // enable internal pull up, assume tactile switches to ground
}

boolean previous_state = HIGH ;
int pot_val ;

void loop ()
{
  int tactile = digitalRead (TACT_PIN) ;
  if (previous_state == HIGH && tactile == LOW)
  {
    pot_val = analogRead (POT_PIN) ;
  }
  delay (10) ; // debounce
  previous_state = tactile ;
  ...
}