Acts as a closure encompassing PonderTalk statements. Any variables used by the statements within the block are untouched once the block is created. Blocks may have arguments that are handed in when they are executed. When a block is executed it returns returns the value of the last statement executed within the block. c.f. function calls.
Operation | Return | Description |
hasArgs: aHash |
boolean |
Returns true if aHash contains entries that match all the names of the arguments that the block requires. Otherwise returns false. |
valueHash: aHash |
P2Object |
The block is executed with the values of its arguments being taken by name from aHash. Answers the value of the last statement executed by the block. Throws an error if aHash does not satisfy the block's arguments. |
valueVars: aHash |
P2Object |
The block is executed with the values in aHash being added to the block's environment variables. Variables in aHash will overwrite environment variables with the same name. The values are added for this call only and do not persist. Answers the value of the last statement executed by the block. |
value |
P2Object |
executes the block with no arguments. Answers with the result of the last statement executed by the block. |
value: arg0 |
P2Object |
Executes the block with one argument: arg0. Answers with the result of the last statement executed by the block. |
value: arg0 value: arg1 |
P2Object |
Executes the block with two arguments: arg0 and arg1. Answers with the result of the last statement executed by the block. |
value: arg0 value: arg1 value: arg2 |
P2Object |
Executes the block with three arguments: arg0, arg1 and arg2. Answers with the result of the last statement executed by the block. |
values: anArray |
P2Object |
Executes the block with anArray of arguments. Answers with the result of the last statement executed by the block. |
whileTrue: aBlock |
self |
While the receiver is true, keep executing aBlock with no arguments |
whileFalse: aBlock |
self |
While the receiver is false, keep executing aBlock with no arguments |
onError: anErrorBlock |
P2Object |
associates anErrorBlock with the receiver. The error block is executed if a Ponder2 error occurs in the receiver. The error block is given one P2Error argument which contains the error details. |