Repository navigation
ASFv3.4.0
[v3.4.0] - 2026-11-05
https://github.com/ECP-Solutions/ASF/releases/tag/v3.4.0
Highlights
-
Added
- Portable examples —
examples/portable/holds six ASF scripts that run unchanged in Excel, Word, PowerPoint, LibreOffice Calc, Writer and Impress: a first example and five for construction site management (a budget summary by chapter, checks of daily work reports against the budget, a monthly progress certificate, a polynomial price revision and the normalisation of item lists with regular expressions). Each script passes the open document toscripts/lib/office.vas, which finds out the application and gives the six the same API: a report is a new sheet in a spreadsheet, headings, paragraphs and a table in a text document, and slides in a presentation; spreadsheets supply the input tables, the other applications a sample project (scripts/data/project.vas). One host module per suite (hosts/OfficeHost.basfor the three Microsoft applications,hosts/LibreOfficeHost.basfor the three LibreOffice ones) only runs the scripts.tools/run_lo.pyruns every script in Calc, Writer and Impress, compares what it wrote withexpected/, and buildsportable-examples.ods,.odt,.odpand.xlsx. The scripts use the fixes below, so they need ASF 3.3.2;ASF.oxtis version 3.3.2. throwand the catch variable —throw exprraisesexpr, whichcatch (e)binds toe;catch (e)also binds the message of a runtime error. Athrowthat nocatchhandles ends the script, andASF.LastErrorholds its value (or the last runtime error), so a host can tell why a script returned nothing.Tools/vba_check.py— finds two VBA compile errors that the LibreOffice test run cannot see, since LibreOffice Basic compiles that code: ByRef argument type mismatch (aVariantpassed to aByRefparameter of another type, aspinfo(1)was) and Duplicate declaration in current scope.python3 Tools/vba_check.pycheckssrc/*.cls; CONTRIBUTING.md describes it.
- Portable examples —
-
Fixed
Mathin exported functions — a function exported by a module and called from another script could not useMath(Math.floor(x)returned nothing): a module's scope now hasMath, as the program's does.- Methods on template literals —
`${x}`.trim()ignored the call and returned the template; members and calls now chain on a template as on any string. ==and!=with arrays and objects — comparing an array or an object with anything (m == null,o == p) raised a type mismatch, which ended the function or script without a value;!=withnullraised too. They now never raise: objects are equal when they are the same object, arrays when they have the same items, and values VBA cannot compare (an array and a number,'a'and1) are not equal. Two numbers are still compared directly, so loops pay nothing for it.forin a function literal — in a function written as a value (let f = fun() { for (let i = 1, ...) ... }), the initializer of aforwas read as the comparisoni == 1: the counter started empty and the loop did not run as written. Function literals are now normalised as named functions are.- Arrays to UNO methods (LibreOffice) — passing an ASF array to a UNO method or property (
range.setDataArray(rows),table.setDataArray(rows)) failed: arrays now reach UNO as nested sequences from 0, converted to the type the member declares ([][]anyeven when every cell is a string). - Unknown members of arrays and strings — reading a member that arrays or strings do not have (
[1].nope,'abc'.nope.x) evaluated it as a call, and the call evaluated the member again, without end: VBA stopped with Out of stack space, LibreOffice crashed. Such a member is nowundefined, and calling it ([1].nope()) is an error that names it: 'nope' is not a method of an array. - Operators that cannot take their operands —
[1] + 1,{a: 1} * 2,'abc' - 1or[1] < 2ended the script with VBA's Type mismatch (Object variable not set or Incorrect property value in LibreOffice). Every binary operator now raises an error that names the operator and its operands, such as Operator - cannot be applied to 'abc' and 1, whichcatchreceives andLastErrorholds;<<and>>also report arrays and objects instead of returningundefined. What VBA converts still works ('5' - 1is 4), and division by zero andthrowkeep their own errors.+and&with a string write arrays and objects as templates do ('rows: ' + [1, 2]givesrows: [ 1, 2 ]), andnullas nothing, also in LibreOffice, where'a' + nullwas a type mismatch. typeofwithout parentheses —typeof [1]did not compile (Invalid collapsed identifier),typeof 'a',typeof 3ortypeof -xwere read wrongly, andtypeof (o).aortypeof ('abc').lengthdropped what follows the parentheses.typeoftakes any unary operand now, with or without parentheses, andtypeof (x).yis the type ofx.y, as in JavaScript.- Missing properties — reading a property an object does not have (
o.nope) gave VBA'sNothing:typeofsaidnull,o.nope == nullwas false, and a host that received it failed with Object variable not set. It isundefinednow. - Templates — an object literal in a placeholder lost its closing brace (
`${{a: 1}}`gave{ a: 1 }}), a brace inside a string in a placeholder ended it (`${'}'}`), and an escaped backtick (\`) ended the template. - Brackets in strings and comments — the compiler counted the brackets of strings and comments when it checked that the program's brackets are balanced, so
return 'a)';or a comment with one parenthesis did not compile. defaultinswitch— thedefaultblock never ran: the tokenizer marksdefaultas a keyword (forexport default) andswitchonly looked for a name, so a value that matched no case did nothing. Writing a case as in JavaScript (case 2: return x;), which ASF does not have, ended the script with Invalid procedure call; it is now a compile error that shows the ASF form,case 2 { ... }.Mathconstants andMath.random—Math.PIandMath.Egaveundefined(the names were compared in upper case with the lower-cased member name, and a property read never reached them), andMath.random()did not exist although the Language reference uses it.MathhasPI,E,LN2,LN10,LOG2E,LOG10E,SQRT2andSQRT1_2now, andrandom(); the Language reference has a section onMath.join()andtoString()— without a separator they joined the items with nothing (12) instead of the documented', '(1, 2).- VBA: ByRef argument type mismatch in
ASF_VM—CallNamedFunctionpassedpinfo(1), an element of aVariant, to thestmts As Collectionparameter ofInvokeClosure, which VBA does not compile (LibreOffice Basic does not check it). The object parameters ofInvokeClosure,CallNamedFunctionandCallClosureareByValnow, so aVariantthat holds the object is accepted and converted when the call runs. return [x]— a one-item array literal afterreturn(and aftertypeof,throw,case,in,of,else,delete,voidandinstanceof) was read as an index on a variable named like the keyword, soreturn [3];andreturn [3].length;returned nothing.
-
Test coverage:
module_system_math_in_exported_function(withtest/math_module.vas),template_literal_method_chain,equality_with_arrays_and_objects,return_array_literal,throw_reaches_catch,uncaught_throw_in_last_error,for_loop_in_function_literal,unknown_member_of_array_or_string,operators_on_arrays_and_objects,typeof_operand,missing_property_is_undefined,template_braces_quotes_backticks,join_default_separator,brackets_in_strings_and_comments,switch_default,switch_colon_case_is_an_errorandmath_constants_and_randomintest/TestRunner.bas.