Hello,
I've been trying to get an eval as the output of a notification but I can't get it to work.
So I created a notification, and the number on the notification is supposed to go up by the click of a button.
Example = Example + 1
Notification.get("notification").setTitle("Example")
Can somebody tell me what I'm doing wrong, of if this is even possible?
Thank you!
Eval in notifications
-
kerkersklave
- Explorer At Heart

- Posts: 709
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Eval in notifications
"Example" is a string, that is, just the Text Example, if you want to use the variable named Example, remove the quotation marks.
Re: Eval in notifications
Thank you
so now i have:
Example = Example + 1
Notification.get("Notification").setTitle(Example)
But the notification remains unchanged on screen.
so now i have:
Example = Example + 1
Notification.get("Notification").setTitle(Example)
But the notification remains unchanged on screen.
- eXquisite
- Explorer

- Posts: 31
- Joined: Sun Feb 06, 2022 1:32 pm
- Sexual Orientation: Bisexual/Bi-Curious
Re: Eval in notifications
To me it looks correct. Are you sure you named your notification correctly, so it's called "Notification" (without quotation marks and with upper letter at the beginning)?
Edit: your variable "Example" is a constant, that's why you can't change it - rename it to "example". Any variable that's starting with upper case is a constant.
If you want to add text before the number use this code instead (replace "Score: " with what you want):
Edit: your variable "Example" is a constant, that's why you can't change it - rename it to "example". Any variable that's starting with upper case is a constant.
Code: Select all
var example = 0;
example++;
Notification.get("Notification").setTitle(example);
Code: Select all
Notification.get("Notification").setTitle("Score: " + example)
Re: Eval in notifications
I still seem to be doing something wrong. Edit: I am an idiot for skimming your message. The problem lies with the uppercase letter.
Rightnow im getting score: 1
But the score should be 0 still at that point.
Why did you put the "++" at the end there and what is the language called?
Ive learned alot already, despite the thing not working yet. So thank you both for the input!
Rightnow im getting score: 1
But the score should be 0 still at that point.
Why did you put the "++" at the end there and what is the language called?
Ive learned alot already, despite the thing not working yet. So thank you both for the input!
-
kerkersklave
- Explorer At Heart

- Posts: 709
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Eval in notifications
Uppercase does not make a difference for the variable. It is a convention to name constants with uppercase letters (all uppercase, not only the first), but that is just for readability. It is not a rule of Javascript.
If tested it, and the issue is, that EOS requires setTitle to be called with a String, not a number. That's why:
won't work.
But the following will:
++ is the increment operator in Javascript (and many other programming languages), x = x + 1 works just as well of course.
If tested it, and the issue is, that EOS requires setTitle to be called with a String, not a number. That's why:
Code: Select all
var Example = 0
Notification.get("asd").setTitle(Example)
But the following will:
Code: Select all
var Example = 0
Notification.get("asd").setTitle("" + Example)
Re: Eval in notifications
That did it. Thanks.
It didn't help that I assumed I didn't need to call up the Notification each time, but it makes a lot of sense.
It didn't help that I assumed I didn't need to call up the Notification each time, but it makes a lot of sense.
