User Tools

Site Tools


bind_declare_runtime_expression_string_variable_.htm
Navigation:  Language Reference > 10 - Expressions > Runtime Expression Evaluation >====== BIND (declare runtime expression string variable) ====== Previous pageReturn to chapter overviewNext page

 

BIND ( name,variable )
name,procedure
group

blk2blue.jpg

BIND Identifies variables allowed to be used in dynamic expressions.
name A string constant containing the identifier used in the dynamic expression. This may be the same as the variable or procedure label.
variable The label of any variable (including fields in FILE, GROUP, or QUEUE structures) or passed parameter. If it is an array, it must have only one dimension.
procedure The label of a Clarion language PROCEDURE which returns a STRING, REAL, or LONG value. If parameters are passed to the procedure, they must be STRING value-parameters (passed by value, not by address) and may not be omittable.Parameters cannot be omittable in the procedure's prototype. For example, functions with prototypes like as follows cannot be passed to BIND:myfunction (STRING,<;STRING>),STRING
group The label of a GROUP, RECORD, or QUEUE structure declared with the BINDABLE attribute.

The BIND statement declares the logical name used to identify a variable, EQUATE, or user-defined procedure in runtime expression strings. A variable or user-defined procedure must be identified with the BIND statement before it can be used in an expression string for either the EVALUATE procedure or a VIEW structure's FILTER attribute.

With regards to EVALUATE, the evaluator is assuming a default value '' to all parameters in the function call in the expression string passed to EVALUATE. In other words, the prototype is assumed to be as follows:

myfunction (STRING='',STRING=''),STRING

and therefore actual parameters can be omitted in the expression.

BIND(name,variable) The specified name is used in the expression in place of the label of the variable.
BIND(name,procedure) The specified name is used in the expression in place of the label of the procedure.
BIND(group) Declares all the variables within the GROUP, RECORD, or QUEUE (with the BINDABLE attribute) available for use in a dynamic expression. The contents of each variable's NAME attribute is the logical name used in the dynamic expression. If no NAME attribute is present, the label of the variable (including prefix) is used.

A GROUP, RECORD, or QUEUE structure declared with the BINDABLE attribute has space allocated in the .EXE for the names of all of the data elements in the structure. This creates a larger program that uses more memory than it normally would. Also, the more variables that are bound at one time, the slower the EVALUATE procedure will work. Therefore, BIND(group) should only be used when a large proportion of the constituent fields are going to be used.

Example:

PROGRAM
 MAP
  AllCapsFunc(STRING),STRING                       !Clarion procedure
 END
Header    FILE,DRIVER('Clarion'),PRE(Hea),BINDABLE  !Declare header file layout
OrderKey   KEY(Hea:OrderNumber)
Record      RECORD
OrderNumber  LONG
ShipToName   STRING(20)
           END
         END
StringVar STRING(20)
CODE
BIND(Hea:Record)                !Binds all fields in record e.g. Hea:ShipToName
BIND('ShipName',Hea:ShipToName) !Easier to use “ShipName” then “Hea:ShipToName”
BIND('SomeFunc',AllCapsFunc)
BIND('StringVar',StringVar)
StringVar = 'SMITH'
CASE EVALUATE('StringVar = SomeFunc(ShipName)')
OF ''
   IF ERRORCODE()
    MESSAGE('Error ' &amp; ERRORCODE() &amp; ' – ' &amp; ERROR())
   ELSE
    MESSAGE('Unkown error evaluating expression')
   END
OF '0'
   DO NonSmithProcess
OF '1'
   DO SmithProcess
END
AllCapsFunc PROCEDURE(PassedString)
CODE
RETURN(UPPER(PassedString))
!End of above example

UNBIND

BINDEXPRESSION

EVALUATE

PUSHBIND

POPBIND

FILTER

DISPOSE

bind_declare_runtime_expression_string_variable_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)