Block.st
branchjv
changeset 18062 014678b4657a
parent 18060 3708e12e9aa8
parent 15270 5ff032ca0d1c
child 18066 89d51443ba6f
equal deleted inserted replaced
18061:2643e3012a13 18062:014678b4657a
  2482 
  2482 
  2483 valueWithRestart
  2483 valueWithRestart
  2484     "the receiver must be a block of one argument.  It is evaluated, and is passed a block,
  2484     "the receiver must be a block of one argument.  It is evaluated, and is passed a block,
  2485      which, if sent a value-message, will restart the receiver block from the beginning"
  2485      which, if sent a value-message, will restart the receiver block from the beginning"
  2486 
  2486 
  2487     |myContext|
  2487     |myContext restartAction|
  2488 
  2488 
  2489     myContext := thisContext.
  2489     myContext := thisContext.
  2490     ^ self value:[ myContext restart ].
  2490     restartAction := [ myContext unwindAndRestart ].
       
  2491     ^ self value:restartAction.
  2491 
  2492 
  2492     "
  2493     "
  2493      [:restart |
  2494      [:restart |
  2494         (self confirm:'try again ?') ifTrue:[
  2495         (self confirm:'try again ?') ifTrue:[
  2495             restart value.
  2496             restart value.
  2502 
  2503 
  2503 valueWithRestartAndExit
  2504 valueWithRestartAndExit
  2504     "the receiver must be a block of two arguments, a restart and an exit block.
  2505     "the receiver must be a block of two arguments, a restart and an exit block.
  2505      See description of valueWithExit and valueWithRestart for their use"
  2506      See description of valueWithExit and valueWithRestart for their use"
  2506 
  2507 
  2507     |myContext|
  2508     |myContext restartAction|
  2508 
  2509 
  2509     myContext := thisContext.
  2510     myContext := thisContext.
  2510     ^ self value:[myContext restart] value:[:exitValue | ^exitValue].
  2511     restartAction := [ myContext unwindAndRestart ].
       
  2512     ^ self value:restartAction value:[:exitValue | ^exitValue].
  2511 
  2513 
  2512     "
  2514     "
  2513      [:restart :exit |
  2515      [:restart :exit |
  2514         |i|
  2516         |i|
  2515 
  2517 
  3116 ! !
  3118 ! !
  3117 
  3119 
  3118 !Block class methodsFor:'documentation'!
  3120 !Block class methodsFor:'documentation'!
  3119 
  3121 
  3120 version
  3122 version
  3121     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.196 2013-05-13 19:21:34 stefan Exp $'
  3123     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.198 2013-05-24 18:13:53 cg Exp $'
  3122 !
  3124 !
  3123 
  3125 
  3124 version_CVS
  3126 version_CVS
  3125     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.196 2013-05-13 19:21:34 stefan Exp $'
  3127     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.198 2013-05-24 18:13:53 cg Exp $'
  3126 ! !
  3128 ! !
  3127 
  3129 
  3128 
  3130 
  3129 Block initialize!
  3131 Block initialize!