RESOLVED - Return of two variables from a function

Hello,
always in my intent to learn the code I came across this need:

Within a function I have an event on a table that generates two variables.
These two variables I would like to recall them when I call the function.

function buttomActivated() {
$w(“#TabEventi”).onRowSelect( (event) => {
const index = event.rowIndex;
const idRows = event.target.rows[index]._id;
let AttivoRows = event.rowData.attivo;
let NameRows = event.rowData.nomeEventoOErimonia;
if (AttivoRows === undefined) {
$w(“#serviceActivate”).disable();
$w(“#serviceActivate”).label = ‘-’;
$w(‘#serviceName’).hide();
}else {
$w(‘#serviceName’).text = NameRows;
$w(‘#serviceName’).show();
$w(“#serviceActivate”).enable();
if (AttivoRows === true) {
$w(“#serviceActivate”).label = ‘Disattiva’;
AttivoRows = false;
}else {
$w(“#serviceActivate”).label = ‘Attiva’;
AttivoRows = true;
}
}
});
return(idRows, AttivoRows);
}

export function serviceActivate_click() {
let pipo = buttomActivated();
console.log('Test ’ + pipo);
}

With this code I tried to do there are two questions:

Can I apply two variables to the return?
If I apply the return it must now give me a undefine error, rightly since these are within the onRowSelect event.
How can I transfer these two variables?

I hope I explained myself in the best way, and I hope so much that someone can help me because this case happens to me often

Thank you

Is anyone kind enough to help me?

Fixed, I lost a bit of time to understand but the end I arrived in this way, ie declaring the variables in a global and not just within the function. I hope it is the best way, if someone sees that I’m wrong I ask to be able to correct myself.

let index = null;
let idRows = null;
let AttivoRows = null;
let NameRows = null;

function buttomActivated() {
$w(" #TabEventi “).onRowSelect( (event) => {
index = event.rowIndex;
idRows = event.target.rows[index]._id;
AttivoRows = event.rowData.attivo;
NameRows = event.rowData.nomeEventoOErimonia;
if (AttivoRows === null) {
$w(” #serviceActivate “).disable();
$w(” #serviceActivate “).label = ‘-’;
$w(’ #serviceName ‘).hide();
}else {
$w(’ #serviceName ‘).text = NameRows;
$w(’ #serviceName ').show();
$w(” #serviceActivate “).enable();
if (AttivoRows === true) {
$w(” #serviceActivate “).label = ‘Disattiva’;
AttivoRows = false;
}else {
$w(” #serviceActivate ").label = ‘Attiva’;
AttivoRows = true;
}
}
});
}

Thank you