X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=adoc%2Fp_break.adoc;h=f274ea6b10d8d3f5c04991251ad41edd497bca6a;hb=076f00a88873336acf2c7150281f1a8172683fe7;hp=f7da196579288ed75bcf2696fc105735941730c1;hpb=241c3dd0c465fb45a6ab240aa088268b8743cff4;p=rrq%2Frrqforth.git diff --git a/adoc/p_break.adoc b/adoc/p_break.adoc index f7da196..f274ea6 100644 --- a/adoc/p_break.adoc +++ b/adoc/p_break.adoc @@ -9,3 +9,25 @@ branch out of an enclosing xef:p_begin[BEGIN]-xref:p_end[END] block. Similar to xref:p_ifbreak[IFBREAK] it lays out the branch cell followed by a reserved cell for the branch offset, and inserts the resolution address just above the required 0 on the data stack. + +==== +.Usage example {counter:example}: unconditional break with a condition. +---- +: WTELL ( tfa -- ; Print word pname ) + 24 + DUP 8 + SWAP @ TELL SP EMIT +; + +: WORDS ( wordlist -- ; Print all words of word list ) + BEGIN + @ DUP IF DUP WTELL ELSE BREAK THEN + 1 IFAGAIN + END + DROP + NL EMIT +; +---- +==== + +See also <>, <>, +<>, <>, <>, +<> and <>.