_anomDiebolt_
8 years agoQrew Elite
Formula Parser In JavaScript
THERE IS AN ASK OF YOU AT THE BOTTOM OF THIS POST - SKIP THE DETAILS IF YOU DON'T UNDERSTAND MY TECHNICAL RATIONALE
As some of you may be aware I am deep into creating a QuickBase Formula Parer in JavaScript that will parse and evaluate a QuickBase formula in client-side JavaScript. So a random formula (taken from a community posting) such as this:
QuickBase allows you to create formulas labels with both the characters "[" and "]" in the label and allowing the "]" character in a field makes the parsing difficult. More importantly, you can't use such a field in the formula language without generating a parsing error in QuickBase's own formula parser. So the simple advice is never use "[" or "]' in your formula labels. But beyond that I need an understanding of what other characters are used in the wild in your QuickBase formula labels.
THE ASK:
You can help me out by running a very short script from the browser console on any of your large application and send me the output. All this script does is run through every field in your application and enumerate all the letters used in your field names.
Here is the script and the attached screenshot shows me running it against the QuickBase Support Center application:
As some of you may be aware I am deep into creating a QuickBase Formula Parer in JavaScript that will parse and evaluate a QuickBase formula in client-side JavaScript. So a random formula (taken from a community posting) such as this:
If([TASK COMPLETE] and IsNull([COMPLETE DATE]) = "", Today(),... will get converted into a JSON syntax tree such as the following (which is essential for the evaluation of the formula inside the browser):
[COMPLETE DATE]
)
//Input parsed successfully.Everything is going swimmingly but there is a massive amount of testing that has to be automated and one weird problem has reared its head. Surprisingly this issue deals with what are valid formula labels not the syntax of the formula language itself,
[
{
"type": "Call",
"name": "If",
"arguments": [
{
"type": "binop",
"operator": "and",
"args": [
{
"type": "Field",
"name": "TASK COMPLETE"
},
{
"type": "binop",
"operator": "=",
"args": [
{
"type": "Call",
"name": "IsNull",
"arguments": [
{
"type": "Field",
"name": "COMPLETE DATE"
}
]
},
{
"type": "binop",
"operator": ",",
"args": [
{
"type": "Literal",
"value": "\"\""
},
{
"type": "binop",
"operator": ",",
"args": [
{
"type": "Call",
"name": "Today",
"arguments": null
},
{
"type": "Field",
"name": "COMPLETE DATE"
}
]
}
]
}
]
}
]
}
]
}
]
QuickBase allows you to create formulas labels with both the characters "[" and "]" in the label and allowing the "]" character in a field makes the parsing difficult. More importantly, you can't use such a field in the formula language without generating a parsing error in QuickBase's own formula parser. So the simple advice is never use "[" or "]' in your formula labels. But beyond that I need an understanding of what other characters are used in the wild in your QuickBase formula labels.
THE ASK:
You can help me out by running a very short script from the browser console on any of your large application and send me the output. All this script does is run through every field in your application and enumerate all the letters used in your field names.
Here is the script and the attached screenshot shows me running it against the QuickBase Support Center application:
var names = "";_.each(gFI, function(table, index) {
_.each(table, function(field, index) {
names += field.name;
});
});
var counts = _.countBy(names, function(letter) {
return letter;
});
console.log(JSON.stringify(counts, null, " "));