parseInt(x)
works but
round(x)
does not (it passes the parser but crashes the program)
There is a slight difference between the two, parseInt
will basically truncate and give the integer part whereas round will round
the integer to the nearest integer.
Leo
January 1, 2024, 6:04pm
2
I’m surprised if round crashes, since it’s part of JScript rather than Opus.
Can you provide some minimal code that shows the problem?
lxp
January 1, 2024, 6:38pm
3
Me too, it's in many scripts and has never crashed.
We are talking about Math.round()
, right?
tried round(x)
and math.round(x)
but not Math.round(x)
many thanks @lxp and happy new year all
Leo
January 1, 2024, 11:00pm
5
When you say round crashed, do you mean the script failed with an error message (because the function isn't defined), or did the whole program actually crash?
no error message, the dialog window flashed white and dissapeared.
Leo
January 2, 2024, 10:13am
7
A dialog closing isn’t the same as a crash.
We still have no example code to reproduce any issue.
it's a crash. Not a Directory Opus crash, a programmitical crash of the script.
For instance (this is not the only way of crashing a script like this) change the Math.round to math.round and it will crash
if (iconDPI != 100 && iconDPI >= DPI_LOWER && iconDPI <= DPI_UPPER)
{
dialog.Control("static24").label = DOpus.DPI.dpi + " (" + Math.round((DOpus.DPI.dpi * iconDPI) / 100) + ")";
dialog.Control("static14").label = FOLDER_DETAILS[0][0][1] + " px" + " (" + Math.round((FOLDER_DETAILS[0][0][1] / iconDPI) * 100) + "px)";
dialog.Control("static15").label = FOLDER_DETAILS[1][0][1] + " px" + " (" + Math.round((FOLDER_DETAILS[1][0][1] / iconDPI) * 100) + "px)";
}
if logging is on then this message is displayed
lxp
January 2, 2024, 3:29pm
9
Be careful with what you classify as crash - you might get asked to send in the crash logs
2 Likes
Leo
January 4, 2024, 2:41pm
10
That's an error, not a crash.