DWLambda allows custom, reusable functions to be created.
DWLambda effectively adds your own functions to a DriveWorks Project and can be used to:
DWLambda is added to a Project by:
The new function passes values into the parameters declared in the DWLambda.
DWLambda([Collection of Parameters], [Function])
Where:
Parameters are the names of Lambda References to be used within the Lambda Function. Each parameter is separated with a comma (,), for example a,b,c.
Function is the Lambda function to be executed. The function references each named parameter, for example a*b/c.
Create the Variable ConvertInchToMM and apply the following DWLambda function:
DWLambda(inch, inch * 25.4 )
Next use the Variable anywhere the conversion is required, as follows:
DWVariableConvertInchToMM(5)
will return 127 (5*25.4).
Or
DWVariableConvertInchToMM(TextBox1Return)
will return 50.8 if the TextBox1 control equals 2 (2*25.4).
Create the Variable Volume and apply the following DWLambda function:
DWLambda(height, width, depth, height * width * depth )
Next use the Variable anywhere the conversion is required, as follows:
DWVariableVolume(3, 5, 2)
will return 30 (3*5*2).
Or
DWVariableVolume(HeightReturn, WidthReturn, LengthReturn)
will return 30 when the controls equal 3, 5 and 2 (3*5*2).
Create the Variable HolePitch and apply the following DWLambda function:
DWLambda(Length, FirstHole, LastHole, HoleQty, (Length-FirstHole-LastHole)/(HoleQty-1) )
Next use the Variable anywhere the HolePitch is required, as follows:
DWVariableHolePitch(LengthReturn, 50, 75, 11)
will return 287.5 when the control equals 3000 ((3000-50-75) / (11-1)).
This example demonstrates using a variable that calculates the height (DWVariableCylinderHeight) and the DriveWorks Functions Pi and Power within a DWLambda.
Create the Variable VolumeCyl and apply the following DWLambda function:
DWLambda(radius, PI() * Power(radius,2) * DWVariableCylinderHeight )
Next use the Variable anywhere the conversion is required, as follows:
DWVariableVolumeCyl(20)
will return 376991.1 = Pi * 20 2 * 300 (the result of DWVariableCylinderHeight).
The following restrictions have been intentionally implemented to prevent ambiguity between which slot, of the function, is being referenced (either where the Lambda Function is defined or where it is called).
MyName and MyNumber functions are blocked when being called from within a DWLambda function.
Relative cell references (for example in a Calculation Table the reference [1L]) are blocked when being called from within a DWLambda function.
A relative reference or the MyName function can be passed into the DWLambda, as an argument, from outside the DWLambda function call.