| **Navigation:**  [[introduction.htm|Language Reference]] > 10 - Expressions > Runtime Expression Evaluation >====== BIND (declare runtime expression string variable) ====== | [[runtime expression evaluation.htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[bindexpression declare runtime expression .htm|{{btn_next_n.gif|Next page}}]] | | || ** ** | | **BIND** | **( **| //name,variable//| **)** | | | | | //name,procedure //| | | | | | //group //| | {{blk2blue.jpg|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 ' & ERRORCODE() & ' -- ' & 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 !********************************** 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 DISPOSE(ClipboardContents) END ClipboardContents &= NEW(STRING(LEN(CLIPBOARD()+1))) BIND('ClipboardContents',ClipboardContents) !Bind to new Reference ClipboardContents = CLIPBOARD() !Thanks to Carl Barnes for this example **See Also:** [[unbind free runtime expression string variable .htm|UNBIND]] [[bindexpression declare runtime expression .htm|BINDEXPRESSION]] [[evaluate return runtime expression string result .htm|EVALUATE]] [[pushbind save runtime expression string name space .htm|PUSHBIND]] [[popbind restore runtime expression string name space .htm|POPBIND]] [[filter set view filter expression .htm|FILTER]] [[dispose de allocate heap memory .htm|DISPOSE]]