AbtLnFormula
Formulas are compiled into some kind of byte code when they are stored in a from or a view. An AbtLnFormula has two basic elements: the formula text (as an ASCII string) and the compiled formula (as byte array). When you read a formula from a form or a view document, you initially get the byte coded formula. When you send the text message to the formula object, the byte code is decompiled, and the appropriate text string is returned. You can change the text and recompile it sending the compile message to the formula an then use the formula with a document using the computeWithNote: method. Storing formulas however is not supported.
Run a formula with a document
Here is a sample that shows you how to operate a formula on a document:
| connection database formNote note formula newFormula |
"Start runtime system"
AbtLnEnvironment startUp.
"Set up a connection to local databases"
connection := AbtLnConnection local.
"Open a sample databases supplied with the feature"
database := connection openDatabase: 'VASAMPLE\VAFORMS'.
"Open a form note named 'FormulaTest' "
formNote := database formNoteByName: 'FormulaTest'.
"Select the input validation formula of the fourth field"
formula := (formNote allFormFields at: 4) inputValidationFormula.
"Print the formula string to the transcript window"
Transcript nextPutAll: formula text; cr.
"Create a new formula returning the current date"
newFormula := AbtLnFormula new text: '@Text(@Today)'.
"Execute the formula - compile is done implicitly -
and print the result to the Transcript window"
Transcript nextPutAll:
(newFormula computeWith: formNote) asString.
"Close the database"
database close.
"Shut down runtime"
AbtLnEnvironment shutDown.
Last modified date: 01/29/2015