Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables support #27

Closed
wojciechczerniak opened this issue Nov 17, 2019 · 2 comments
Closed

Variables support #27

wojciechczerniak opened this issue Nov 17, 2019 · 2 comments
Labels
API Public methods and properties Feature Something we can add later on without introducing a breaking change

Comments

@wojciechczerniak
Copy link
Contributor

wojciechczerniak commented Nov 17, 2019

Description

Our previous formula engine had support for custom variables. The use case was that we can assign a value to a constant name. If we could assign anything a cell could hold we could assign range reference to a name.

Which gives us NamedRanges support. Worth considering.

Example

parser.setVariable('MY_VARIABLE', 5);
parser.setVariable('fooBar', 10);

parser.parse('(1 + MY_VARIABLE + (5 * fooBar)) / fooBar'); // returns `5.6`

API proposal

public setVariable(name: string, value: CellValue);
public getVariable(name: string): CellValue;

Local and global scope

There should be a global (workbook/engine) and local (worksheet) scope of variables. We can add an argument to the API proposal mentioned above.

Reference

https://github.com/handsontable/formula-parser

@wojciechczerniak
Copy link
Contributor Author

wojciechczerniak commented Dec 5, 2019

This would solve #5 with:

engine.setVariable('TRUE', `TRUE()`);
engine.setVariable('FALSE', `FALSE()`);

@wojciechczerniak wojciechczerniak added API Public methods and properties Feature Something we can add later on without introducing a breaking change Syntax labels Dec 10, 2019
@wojciechczerniak wojciechczerniak added this to the Future milestone Dec 10, 2019
@wojciechczerniak
Copy link
Contributor Author

Obsolete spec. Named Expressions #126 are variables on steroids and are a part of the ODFF spec

@wojciechczerniak wojciechczerniak removed this from the Next milestone Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Public methods and properties Feature Something we can add later on without introducing a breaking change
Projects
None yet
Development

No branches or pull requests

1 participant