asm block errors

Greetings,

I came across some weird interactions when writing in asm blocks on RAD Studio 10.2 and Web Core version 1.6.

One of them is that you cannot give a value to a globally assigned Delphi variable. For instance,

asm
  ThreadLink = AObject.GetJSONValue('MessageText').replace(exp,"<a href='$1' target='_blank'>$1</a>");
end;

This doesn't work when ThreadLink is a global variable. For the people who have a similar problem: you have to declare it locally.

Then you have this interaction:

asm
  var exp = /(\b((https?|ftp|file):\/\/|(www))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*)/ig;
  ThreadLink = AObject.GetJSONValue('MessageText').replace(exp,"<a href='$1' target='_blank'>$1</a>");
end;

The above code block works if you have declared the variables correctly, but the following code gives as error: 'ThreadLink is undefined':

asm
  var exp = /(\b((https?|ftp|file):\/\/|(www))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*)/ig;
  ThreadLink = AObject.GetJSONValue('MessageText').replace(exp,"<a href='$1' target='_blank'>$1</a>");
  BoldText = ThreadLink.replace(SearchText,"<b>"+SearchText+"</b>");
end;

You can fix this by simply using the variables in Delphi, e.g.:

if False then ShowMessage(ThreadLink + ' | ' + BoldText);

I'm curious whether these are bugs or my knowledge is just limited regarding this matter.

Kind regards.

Hi,
place '$mod.' in front of the variable: $mod.ThreadLink.
This should work.
Ralf

This is by design by the pas2js compiler.