This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
Formula from string

Formula from string 


 

Formula from string ( formulaString ) -> function result 
Parameter Type   Description
formulaString  Text in Text formula to be returned as object
function result  Object in A native object containing the formula

Formula from string creates a formula object based upon the formulaString. formulaString can be as simple as a single value or complex, such as a project method with parameters.

This command is similar to Formula, except that it handles a text-based formula. In most cases, it is recommended to use the Formula command. Formula from string should only be used when the original formula was expressed as text (e.g., stored externally in a JSON file). In this context, using token syntax is highly advised (see the Using tokens in formulas page and the Parse formula command).

Note: Because local variable contents can not be accessed by name in compiled mode, they can not be used in formulaString. An attempt to access a local variable with Formula from string will result in an error (-10737).

Example  

The following code:

 C_TEXT($textFormula)
 C_OBJECT($f)
 $textFormula:=Request("Please type a formula")
 If(ok=1)
    $f:=Formula from string($textFormula)
    ALERT("Result = "+String($f.call()))
 End if

will create a dialog accepting a formula in text format,

and execute the formula:



See also 

Formula
formula.source
Parse formula

 
PROPERTIES 

Product: 4D
Theme: Formulas
Number: 1601

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R3
Renamed: 4D v17 R6 (Formula from string)

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)