Inline variables aren't working in TMS Web Core

112 views Asked by At

When I try to use an inline variable, then I get a Syntax error. Here's my code:

procedure TfrmMain.btnSignInClick(Sender: TObject);
begin
  var UserEmail := edtEmail.Text;
  var UserPassword := edtPassword.Text;
  var UserRememberMe := tglRememberMe.Checked;

  SignIn(UserEmail, UserPassword);
end;

The Syntax error happens on this line: var UserEmail := edtEmail.Text;.

Changing the inline variable to also specify the type doesn't work either:

procedure TfrmMain.btnSignInClick(Sender: TObject);
begin
  var UserEmail: String := edtEmail.Text;
  var UserPassword: String := edtPassword.Text;
  var UserRememberMe: Boolean := tglRememberMe.Checked;

  SignIn(UserEmail, UserPassword);
end;

This is valid Delphi code that would work in VCL and FMX, but it doesn't seem to work in TMS Web Core. Why? What am I doing wrong?

1

There are 1 answers

1
Shaun Roselt On BEST ANSWER

According to a TMS Support Center post, the pas2js transpiler (which emits JavaScript code from Object Pascal code) does not support inline variables. So you'll have to use the old-school way of declaring variables:

procedure TfrmMain.btnSignInClick(Sender: TObject);
var
  UserEmail: String;
  UserPassword: String;
  UserRememberMe: Boolean;
begin
  UserEmail := edtEmail.Text;
  UserPassword := edtPassword.Text;
  UserRememberMe := tglRememberMe.Checked;

  SignIn(UserEmail, UserPassword);
end;