If you have a class-variable `foo` in the Application class, and try to set it in one go by using
Application.getApp().foo = 789;
you receive a syntax error. Breaking the statement into two statements, where Application.getApp() is assigned to the temp variable `app` fixes the parse error.
Test case:
Application.mc
using Toybox.Application as App;
class IQTestApp extends App.AppBase {
var foo = 123;
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state) {
}
// onStop() is called when your application is exiting
function onStop(state) {
}
// Return the initial view of your application here
function getInitialView() {
return [ new IQTestView() ];
}
}
View.mc
using Toybox.Application;
using Toybox.WatchUi as Ui;
class IQTestView extends Ui.SimpleDataField {
// Set the label of the data field here.
function initialize() {
SimpleDataField.initialize();
label = "My Label";
}
// The given info object contains all the current workout
// information. Calculate a value and return it in this method.
// Note that compute() and onUpdate() are asynchronous, and there is no
// guarantee that compute() will be called before onUpdate().
function compute(info) {
// Fails with mismatched input '=' expecting {'(', ';', '.', '['}
// Application.getApp().foo = 789;
// Succeeds
var app = Application.getApp();
app.foo = 789;
return 0.0;
}
}