Hoping this is an easy one! Version number with 2 decimal places
-
I'm trying to compare version numbers of my software but if I type a number with 2 decimal places:
if (data.version < 2.0.1)
I get the error:
Interface:! Line 702, column 28: Found literal when expecting ')'
One decimal place works just fine
-
@DanH Try a string ""
-
@d-healey I did, it doesn't produce an error but nor does the callback fire....
-
@DanH And data.version is definitely less than 2.0.1?
-
@d-healey yes indeed!
I remember I tried this yonks ago and it didn't work
-
Works here (I'm using it for Rhapsody also). Both numbers need to be strings.
-
@d-healey said in Hoping this is an easy one! Version number with 2 decimal places:
Both numbers need to be strings.
This might be where I'm going wrong in the data.... thanks
-
@d-healey the data in the version file is simply
{ "version": "2.0.0" }
-
@DanH What do you see with
Console.print(data.version < "2.0.1");
-
-
@d-healey the below gives me an error though
Console.print(data.version);
-
@DanH said in Hoping this is an easy one! Version number with 2 decimal places:
the below gives me an error though
You need to tell me what the error is.
-
API call with undefined parameter 0
-
@DanH So data.version is undefined.
-
@d-healey yup struggling to figure out why though.... Here's a longer version of the script
inline function loadVersionFile() { local appDataDir = FileSystem.getFolder(FileSystem.AppData); return appDataDir.getChildFile("Version.js"); } inline function checkOnLoadSettings() { local HVersion = loadVersionFile(); if (HVersion.isFile()) { local data = Engine.loadFromJSON("..//Version.js"); if (data.version <"2.0.4") { HUpdate_Panel.showControl(1); } else { HUpdate_Panel.showControl(0); } } else { HUpdate_Panel.showControl(1); } } checkOnLoadSettings();
-
@DanH Use
File.loadAsObject()
-
@d-healey instead of ...?
Also how do you get the red text in here?
-
@DanH Code tags for red text (a single backtick at the start and end. `
Instead of Engine.loadFromJSON() - You already went to the trouble to get the file object so you might as well use it.
-
@d-healey Righto, thanks!