Difference between revisions of "TES5Edit Scripting Functions"

Jump to navigation Jump to search
109 bytes removed ,  19:09, 16 September 2016
→‎Pascal implementation: reorganized; previous list was too messy to be useful
imported>DavidJCobb
(→‎Pascal implementation: no absolutes; there's pretty much no way to use pointers or memory tricks or anything else, well, useful)
imported>DavidJCobb
(→‎Pascal implementation: reorganized; previous list was too messy to be useful)
Line 437: Line 437:
TES5Edit appears to use [http://jvcl.delphi-jedi.org/JvInterpreter.htm JVCL] to interpret Delphi, a variant of Pascal. A few details can be found below.
TES5Edit appears to use [http://jvcl.delphi-jedi.org/JvInterpreter.htm JVCL] to interpret Delphi, a variant of Pascal. A few details can be found below.


* TES5Edit's Pascal implementation doesn't stably implement <code>Try</code> blocks. There are errors that can slip through, and they are hard to document because the interpreter rarely reports the correct cause.
* In TES5Edit's Pascal implementation, values are returned by assigning to <code>Result</code>, rather than by assigning to the function name.
* TES5Edit's Pascal implementation does not appear to support function overloading.
* TES5Edit's Pascal implementation does not appear to support open array parameters (e.g. <code>array of integer</code>).
* TES5Edit's Pascal implementation does not appear to support the <code>With</code> statement.
* TES5Edit's Pascal implementation does not support <code>absolute</code> variables.
* TES5Edit's Pascal implementation does not support <code>&</code> as a prefix for suppressing keyword parsing (e.g. <code>&For</code> to refer to a variable named "For").
* TES5Edit's Pascal implementation does support the <code>^</code> or <code>@</code> operators.
* TES5Edit's Pascal implementation has exceptionally poor support for defined classes and subclasses:
** The <code>constructor</code> keyword is not supported.
** Subclasses without a constructor don't trip up the parser, but attempting to instantiate them (e.g. <code>MyClass.Create</code>) causes TES5Edit to choke on the classname, which it sees as an undefined identifier. At this time, it's not known whether custom classes can actually be ''used'' in an xEdit script.
** The <code>object</code> keyword (as used in [http://docwiki.embarcadero.com/RADStudio/Berlin/en/Classes_and_Objects_(Delphi)#Object_Types object types]) is not supported.
** One can safely assume, then, that the classes and functionality available to one is limited by both the Delphi version (presently unknown) and the JVCL version (presently unknown) that TES5Edit uses.
* TES5Edit's Pascal implementation does not appear to support the <code>is</code> or <code>as</code> keywords. However, <code>TObject</code> and its subclasses offer a <code>ClassName</code> method.
* TES5Edit's Pascal implementation does not appear to support constructions such as <code>TList&lt;Integer&gt;</code>.
* TES5Edit's Pascal implementation does not appear to support constructions such as <code>TList&lt;Integer&gt;</code>.
* TES5Edit's Pascal implementation does not appear to support [http://docwiki.embarcadero.com/RADStudio/XE8/en/Procedural_Types procedural types] or [http://docwiki.embarcadero.com/RADStudio/XE8/en/Anonymous_Methods_in_Delphi anonymous methods].
* In TES5Edit's Pascal implementation, values are returned by assigning to <code>Result</code>, rather than by assigning to the function name.
* [http://docwiki.embarcadero.com/RADStudio/XE2/en/Variant_Support_Routines Variant support routines] don't appear to be implemented, making it tricky to work with variants.
* Type keywords such as varInteger aren't implemented.
* [http://docwiki.embarcadero.com/RADStudio/XE8/en/Structured_Types Structured types] don't appear to be implemented.
* Object classes such as TList and TStringList are very primitive; methods like AddRange are missing, and their Create constructors don't accept arguments.
* Object classes such as TList and TStringList are very primitive; methods like AddRange are missing, and their Create constructors don't accept arguments.
* TES5Edit's Pascal implementation doesn't support DateUtils.
* TES5Edit's Pascal implementation does not support the definition of custom enum types using the type keyword. It basically only supports the "type" keyword as a means of aliasing classes.
* TES5Edit's Pascal implementation supports out parameters but does not handle them properly. It appears as though they always receive default values (e.g. false booleans, empty strings). Var parameters properly receive values.
* TES5Edit's Pascal implementation, while allowing you to use the << and >> operators for bitshifting, will result in values of FFFFFFFFFFFFFFFF or 0 instead an actual result. Use the shr and shl operators instead to perform working bitshifting. `FormID shr 24` for load order, etc.


The reference documentation below appears to match what TES5Edit provides.
The reference documentation below appears to match what TES5Edit provides.


* [http://docwiki.embarcadero.com/Libraries/XE8/en/System.RegularExpressionsCore.TPerlRegEx TPerlRegEx], used for regular expressions.
* [http://docwiki.embarcadero.com/Libraries/XE8/en/System.RegularExpressionsCore.TPerlRegEx TPerlRegEx], used for regular expressions.
==== Broken language features ====
{|class="wikitable" width =100%
!style="text-align:left;"|Feature
!style="text-align:left;"|Details
|-
|anonymous methods
|Refer to the [http://docwiki.embarcadero.com/RADStudio/XE8/en/Anonymous_Methods_in_Delphi Embarcadero documentation].
|-
|array arguments
|A function cannot accept an argument with a type like <code>array of integer</code>.
|-
|function overloading
|Allows the same function to have multiple sets of arguments.
|-
|object types
|The <code>object</code> keyword isn't implemented.
|-
|out parameters
|Out parameters always receive default values, such as false for a boolean. Use var parameters instead.
|-
|procedural types
|Refer to the [http://docwiki.embarcadero.com/RADStudio/XE8/en/Procedural_Types Embarcadero documentation].
|-
|structured types
|Refer to the [http://docwiki.embarcadero.com/RADStudio/XE8/en/Structured_Types Embarcadero documentation].
|-
|subclasses
|The <code>constructor</code> keyword isn't implemented. Subclasses without a constructor can be defined, but attempts to instantiate them (<code>MyClass.Create</code>) will always break.
|-
|try
|Doesn't catch all runtime errors.
|-
|}
==== Unsupported operators ====
{|class="wikitable" width =100%
!style="text-align:left;"|Operator
!style="text-align:left;"|Description
|-
|&
|Prefix; suppresses parsing of a keyword (e.g. <code>&For</code> is a variable named "For").
|-
|@
|Prefix; retrieves the address of a variable for use as a pointer; compare to <code>&</code> in C++.
|-
|^
|Dereferences a pointer; compare to <code>*</code> in C++.
|-
|<<
|Used for bit shifting, but returns a junk result in xEdit. Use <code>Shl</code> instead.
|-
|>>
|Used for bit shifting, but returns a junk result in xEdit. Use <code>Shr</code> instead.
|-
|}
==== Unsupported keywords ====
{|class="wikitable" width =100%
!style="text-align:left;"|Keyword
!style="text-align:left;"|Description
|-
|absolute
|Allows two or more variables to occupy the same location in memory.
|-
|as
|Used to cast a variable to a given class.
|-
|constructor
|Used to declare a constructor function for subclasses; absence of this keyword makes subclasses impossible to use.
|-
|is
|Used to test whether a variable is an instance of a given class; for anything derived from <code>TObject</code>, you can use the <code>ClassName</code> method instead.
|-
|object
|Used to create [http://docwiki.embarcadero.com/RADStudio/Berlin/en/Classes_and_Objects_(Delphi)#Object_Types object types].
|-
|type
|Partial implementation. You can use it to alias a class name, but it's broken for every single other use and its existence is therefore pointless.
|-
|with
|Statement.
|-
|}
==== Unsupported classes and tools ====
{|class="wikitable" width =100%
!style="text-align:left;"|Feature
!style="text-align:left;"|Description
|-
|standard libraries
|Common Delphi units like DateUtils and System are unavailable.
|-
|[http://docwiki.embarcadero.com/RADStudio/XE2/en/Variant_Support_Routines Variant support routines]
|Makes it easier to identify a variant's current type, and cast variants. Relevant type keywords like <code>varInteger</code> are also missing.
|-
|}
Anonymous user

Navigation menu