Make the p.x p.y availabe to all the code (global)

I was hoping to apply this to setup, or find a way when I call a void-sub from void loop that it remains available?

    p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, 0,tft.width()));  //swapped
    p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, 0,tft.height()));  //swapped

you must make the variable p global

please post your code so we can show how.

{

  TSPoint p = ts.getPoint();
    // if sharing pins, you'll need to fix the directions of the touchscreen pins
  //pinMode(XP, OUTPUT);
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE)
  {
    
     // scale from 0->1023 to tft.width
    p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, 0,tft.width()));  //swapped
    p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, 0,tft.height()));  //swapped

if (p.y > 0 && p.y < tft.height() && p.x > 0 && p.x < tft.width())
{ 
do stuff... go to sub and read what soft button pressed
Sub kicks back error p not declared

}

is that all the code?
this won't compile ...

no, but the problem area,

I have moved on an just left the code in void loop. I was trying to get it into it's on void.

thanks for looking!