en:pfw:library
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:pfw:library [2025-03-20 16:55] – [Optional additions] willem | en:pfw:library [2025-04-01 15:56] (current) – [noForth t library use] willem | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== A library for Forth ====== | + | ====== A library for (no)Forth ====== |
| - | *W.O.* | + | *W.O. 2025* |
| Line 14: | Line 14: | ||
| An optional word as suggested by Ulrich Hoffmann | An optional word as suggested by Ulrich Hoffmann | ||
| - | * '' | + | * '' |
| Optional words as suggested by Willem Ouwerkerk | Optional words as suggested by Willem Ouwerkerk | ||
| * '' | * '' | ||
| * '' | * '' | ||
| - | * '' | + | * '' |
| - | * '' | + | * '' |
| ===== Pseudo code ===== | ===== Pseudo code ===== | ||
| Line 164: | Line 164: | ||
| LIB value LIBHERE | LIB value LIBHERE | ||
| - | : LIB-FIND | + | : FIND-CHAPTER |
| - | keyword place \ Save keyword | + | |
| - | | + | libhere lib |
| - | libhere | + | |
| - | begin | + | |
| - | | + | 2dup < throw |
| - | 0D scan nip over 1+ \ Get line with keywords, skip \ | + | dup c@ r@ c@ = until |
| - | | + | dup 2r@ over s<> 0= until \ Name ok? |
| - | 2dup > while | + | |
| - | bl skip dup >r \ Skip leading spaces | + | |
| - | bl scan \ After keyword | + | |
| - | r@ over r> - \ Keyword length | + | |
| - | keyword count s<> 0= \ Keyword found, leave source address | + | |
| - | if 2drop nip exit | + | |
| - | then | + | |
| - | | + | |
| - | 2drop 09 scan 1+ \ Find library section, skip 09 | + | |
| - | | + | |
| : LIB-REFILL | : LIB-REFILL | ||
| Line 200: | Line 192: | ||
| : NEEDED | : NEEDED | ||
| ['] lib-refill | ['] lib-refill | ||
| - | | + | |
| and lib-load ; | and lib-load ; | ||
| Line 263: | Line 255: | ||
| : OPEN-LIB | : OPEN-LIB | ||
| - | libhere lib <> if | + | libhere lib <> if |
| - | libhere 100 /mod 100 * | + | libhere 100 /mod 100 * |
| - | dup to libhere | + | dup to libhere |
| buffer 100 move to ptr {w exit \ Read uncomplete sector to buffer, open flash | buffer 100 move to ptr {w exit \ Read uncomplete sector to buffer, open flash | ||
| - | then 0 to ptr 09 lc, | + | then 0 to ptr |
| : CLOSE-LIB | : CLOSE-LIB | ||
| Line 303: | Line 295: | ||
| repeat | repeat | ||
| - | : LOOK-AT | + | : LOOK-AT |
| </ | </ | ||
| Line 374: | Line 366: | ||
| ===== The library is just bare ASCII ===== | ===== The library is just bare ASCII ===== | ||
| - | When displayed | + | When opened in an editor |
| <code forth> | <code forth> | ||
| - | \ VERSION VERSIE VSN | + | |
| cr .( NEED version 0.33 ) | cr .( NEED version 0.33 ) | ||
| cr .( | cr .( | ||
| Line 452: | Line 444: | ||
| </ | </ | ||
| - | Viewing code chapter from any library. It needs the name as string parameter.\\ | + | Viewing code chapter from any library. It needs the library |
| <code forth> | <code forth> | ||
| - | : CHAPTERS-FROM ( " | + | : CHAPTERS-FROM ( " |
| lib libhere 2> | lib libhere 2> | ||
| chapters | chapters | ||
en/pfw/library.1742486154.txt.gz · Last modified: 2025-03-20 16:55 by willem