Dialog not working

95 views
Skip to first unread message

Amundsf

unread,
Apr 2, 2025, 1:26:21 PM4/2/25
to mementodatabase
Hi

What am I missing here?

Dialog is not show'd and dialogRes() is entered all 3 times.

const myDialog = dialog()
myDialog.title("Beregnet ny til dato")
.text("Beregnet ny til dato er: " + newTo + "\n Legge en ekstra dag?")
.positiveButton("Ja", (dialogRes(e, newTo, 1)) )
.negativeButton("Nei", (dialogRes(e, newTo, 2)) )
.neutralButton("Avbryt", (dialogRes(e, newTo, 3)) )
.show();

function dialogRes(e, newTo, res){

message("Entered dialogResult with res " + res);

// 1 = Add one more day
if (res == 1) {
message("Res 1 = Increase with 1 day");
newTo.setDate(newTo + 1);
}

// No = Keep newTo
if (res == 2) {
message("Res 2 = Keep number of days");
//Keep
}

// Cancel = Cancel
if (res == 3) {
message("Res 3 = Cancel");
cancel();
exit();
}

// Oppdater feltet til
e.set("Til", newTo);
message("Til er oppdatert");

}

Thank you a lot in advance!
 - Amund

Er Mo

unread,
Apr 2, 2025, 2:17:07 PM4/2/25
to mementodatabase
Hallo
Die 3 Schaltflächen im dialog() können auf eigene Funktionen verweisen . Du brauchs die Teile nicht mit " res " Trennen . Wenn man keine Fungtion angibt wird Nichs ausgefürt ( = Abrechen ) . Dabei ist zu beachten das das Skript NICHT gestoppt wird um auf die Antwort von User zu warten . Wenn du den Verlauf des Programmst ändern willst muss du das dialog() skript auslaufen lassen und mit " Ja " ," Nein " Skript ( Funktion ) weiter machen . Zum Ender der Funktion muss ein " return " stehen .
Hier meine Testbibliothek " Start " : Es durchläuft alle Einträgen , fragt den Status ab und speicher diesen in einer anderen Bibliothek .

Hello
The three buttons in dialog() can refer to their own functions. You don't need to separate them with "res." If you don't specify a function, nothing is executed (= aborted). Please note that the script is NOT stopped to wait for the user's response. If you want to change the program flow, you must let the dialog() script run and continue with the "Yes," "No" script (function). A "return" must be used at the end of the function.
Here is my test library "Start": It runs through all entries, queries the status, and saves it in another library.
"

Ernst

Amund Stigen Fjeld

unread,
Apr 2, 2025, 3:14:53 PM4/2/25
to mementodatabase
Thank you. I have kind of solved it know, the dialog window is now shown again.

But I don't understand how to use dialog when all code parts is runned?
How can i do one thing when possible button is used and another thing when negative button is used  - when both code parts is runned all times?


 - Amund



--
You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/IPwGXrRdnyA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/5c0e6151-5798-4baa-b57c-5e40f96e5dffn%40googlegroups.com.

Er Mo

unread,
Apr 2, 2025, 3:36:42 PM4/2/25
to mementodatabase
Hallo
Du hast in deinen Beispiel eine Funktion für alle 3 Schalter . Mache für jeden Schalter einer extra Funktion . Diese kannst du in " Geteilt " Ablagen

Hello
In your example, you have a function for all three switches. Create a separate function for each switch. You can store these in "Shared."

Ernst

Amund Stigen Fjeld

unread,
Apr 2, 2025, 3:44:56 PM4/2/25
to Er Mo, mementodatabase
Yes, I understand that I can split dem, but they will anyway all be runned?

I can do something like example below. Cancel is easy to fix.
But in example below is both dialogAdd1Day and dialogAdd0 runned in all cases?
I just want the one for the button user push to be runned. Is that possible?

Thank you a lot in advance! :-)

const myDialog = dialog()
  myDialog.title("Ny til-dato")
.text("Ny til dato kalkulert til " + newTo + " \n\nLegge til en dag?")
.positiveButton("Ja", (dialogAdd1Day(e, newTo)) )
.negativeButton("Nei", (dialogAdd0(e, newTo,)) )
.neutralButton("Avbryt", (cancel() ) )
.show()

function dialogAdd1Day(e, calcedTo){

var newTo = new Date(calcedTo);
newTo.setDate(calcedTo.getDate() + 1);


// Oppdater feltet til
e.set("Til", newTo);

return;

}

  function dialogAdd0(e, calcedTo){

// Oppdater feltet til
e.set("Til", calcedTo);

return;

}  


 - Amund



Mmm

unread,
Apr 3, 2025, 3:28:58 AM4/3/25
to mementodatabase
Запишите кнопки так:

.positiveButton("Ja", () => { dialogRes(e, newTo, 1) })
.negativeButton("Nei", () => { dialogRes(e, newTo, 2) })
.neutralButton("Avbryt", () => { dialogRes(e, newTo, 3) })


Можете не использовать дополнительную функцию, а действия записать непосредственно в кнопке:

.neutralButton("Avbryt", () => { 
    message("Res 3 = Cancel");
    cancel();
    exit(); 
})

среда, 2 апреля 2025 г. в 22:44:56 UTC+3, Amundsf:

Amund Stigen Fjeld

unread,
Apr 3, 2025, 12:37:07 PM4/3/25
to Mmm, mementodatabase
Hi

Thank you :-)

I have edited the script as below.
It seems to be good now for neutral button (cancel).
But positive/negative button is still strange.

When i use button both two messages highlighted in yellow below give med the expected date.
But the value on the entry is not changed and it does not after switching entry to see eather.

But next time button is used: Then is the value updated as the selected choice of positive/negative button last time, and the update is then done before selecting yes/no in the dialog.

Is it in short not possible to use Dialog for this? Or does this seems like a bug?

Thank you in advance
 - Amund


const myDialog = dialog()
myDialog.title("Ny til-dato")
.text("Ny til dato kalkulert til " + newTo + " \n\nLegge til en dag?")
.positiveButton("Ja", () => {dialogRes(e, newTo, 1)} )
.negativeButton("Nei", () => {dialogRes(e, newTo, 0)} )
.neutralButton("Avbryt", () => {cancel(); exit(); } )
.show()

function dialogRes(e, calcedTo, daysToAdd){

message("Entered dialogResult with days to Add: " + daysToAdd);

//message("CalcedTo: " + calcedTo);

var newTo = new Date(calcedTo);
//message("NewTo initialisert: " + newTo);

if (daysToAdd >0) {
//message("DaysTo Add: " + daysToAdd);
newTo.setDate(calcedTo.getDate() + daysToAdd);
}

// Oppdater feltet til
message("Ready to set to dato = " + newTo);
e.set("Til", newTo);

// Test
var test = e.field("Til");
message("To is updated to" + test);

return;

}


 - Amund



Mmm

unread,
Apr 3, 2025, 1:06:15 PM4/3/25
to mementodatabase
Попробуйте заменить 
return;

на
return true;

Вероятно это ошибка "отрисовки" страницы.
Можете дополнительно добавить return true; и на кнопку:
.positiveButton("Ja", () => {dialogRes(e, newTo, 1); return true;} )

Иногда это помогает...

четверг, 3 апреля 2025 г. в 19:37:07 UTC+3, Amundsf:

Amund Stigen Fjeld

unread,
Apr 3, 2025, 1:12:11 PM4/3/25
to Mmm, mementodatabase
That did it, thank you so very much! :-D

Is this something that should be reported to Vasya, or is it out of his control?


Thank you again!
 - Amund


Mmm

unread,
Apr 3, 2025, 1:19:02 PM4/3/25
to mementodatabase
return true;  --> это его рекомендация. 

Он знает о некоторых проблемах "отрисовки" и вероятно поставил себе в очередь доработки...

В таких случаях стараюсь обновление полей вынести в отдельную функцию и возврат делать с помощью return true; 

четверг, 3 апреля 2025 г. в 20:12:11 UTC+3, Amundsf:
Reply all
Reply to author
Forward
0 new messages