User Tools

Site Tools

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


BIND ( name,variable )


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.


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

ClipboardContents   &STRING  !size it when I know how big it is
LoadClipboardRoutine   ROUTINE 
  UNBIND('ClipboardContents',ClipboardContents) !Reference will change with NEW
  IF NOT ClipboardContents &= NULL THEN 
  ClipboardContents &= NEW(STRING(LEN(CLIPBOARD()+1)))
  BIND('ClipboardContents',ClipboardContents)    !Bind to new Reference
  ClipboardContents = CLIPBOARD()
  !Thanks to Carl Barnes for this example

See Also:








bind_declare_runtime_expression_string_variable_.htm.txt · Last modified: 2023/09/08 09:49 by carlbarnes