- edited description
Escaping JavaScript variables does not work properly
In order to set the resource strings from within a (JSCodeGen'ed) project it's necessary to update the $R variable.
However, it's currently not possible to do so (at least I do not know any working ways). If for example one would write something like:
asm
$R = ["some content"]
end;
the compiler complains "Hexadecimal digit expected".
To make it compile it's necessary to escape the $ sign like:
asm
&$R = ["some content"]
end;
However, this unfortunately ends in code still containing the escape character "&".
Comments (4)
-
reporter -
reporter I just found a good workaround for this issue:
var ResourceStrings external '$R': Variant;
It doesn't render the issue invalid, but at least it's working and it's more pascalish.
-
repo owner Issues traces to TdwsJSLanguageExtension.ReadInstr, which does a TestName before switching the tokenizer, and if the first token within the asm block is a name starting with '$' it goes kaboom.
asm ; $R = ["some content"] end;
And yes, using an external variant is preferable, you can also use an external function (tagged with "property") if you want it to be read-only:
function ResourceStrings : Variant; external '$R' property;
(it's the syntax for JS external properties, but it works in that case as well)
-
repo owner - changed status to resolved
Fixed Issue
#103→ <<cset 7f3107da589e>>
- Log in to comment