User Tools

Site Tools


en:pfw:library

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:pfw:library [2024-11-16 15:11] – [Pseudo code for the Flash library] willemen:pfw:library [2025-02-06 17:59] (current) – [A library for Forth] willem
Line 1: Line 1:
 ====== A library for Forth ====== ====== A library for Forth ======
 +
 +*W.O.*
  
  
Line 9: Line 11:
 The interface consists of the following word: ''%%NEED%%'' The interface consists of the following word: ''%%NEED%%''
  
-  * ''%%NEED%%''  ''%%( "name" -- i*x )%%'' Make sure “name” is present in the dictionary. If not, load it from a library. If "name" already exists, do nothing.+  * ''%%NEED%%''  ''%%( i*x "name" -- j*x )%%'' Make sure “name” is present in the dictionary. If not, load it from a library. If "name" already exists, do nothing.
  
 An optional word as suggested by Ulrich Hoffmann An optional word as suggested by Ulrich Hoffmann
Line 15: Line 17:
  
 Optional words as suggested by Willem Ouwerkerk Optional words as suggested by Willem Ouwerkerk
-  * ''%%NEEDED%%''  ''%%( a b -- i*x )%%'' Make sure that name represented by the string a b is present in the dictionary. If not, load it from a library. If name already exists, do nothing.+  * ''%%NEEDED%%''  ''%%( i*x a b -- j*x )%%'' Make sure that name represented by the string a b is present in the dictionary. If not, load it from a library. If name already exists, do nothing
 +  * ''%%RUN%%'' ''%%( i*x "name" -- j*x )%%'' Find "name" in the library and load & run the script from a library.
   * ''%%.LIB%%''  ''%%( -- )%%'' Show all section/chapter headers of the current library in one or more columns   * ''%%.LIB%%''  ''%%( -- )%%'' Show all section/chapter headers of the current library in one or more columns
   * ''%%VIEW%%'' ''%%( "name" -- )%%'' View the code from the libary, that belongs to "name".   * ''%%VIEW%%'' ''%%( "name" -- )%%'' View the code from the libary, that belongs to "name".
Line 65: Line 68:
 They act as separators and are not part of the text itself. They act as separators and are not part of the text itself.
  
-The ''%%09%%'' marks the end beginning of a chapter, like this:\\ +The ''%%09%%'' marks the end of a chapter, like this:\\ 
-Note that: The library starts with a dummy ''%%09%%'' so that the first keyword line can be found.\\ + 
-  * ''%%09%%'' chapter-1 ''%%09%%'' chapter-2 ''%%09%%'' last-chapter ''%%09%%''+  * chapter-1 ''%%09%%'' chapter-2 ''%%09%%'' last-chapter ''%%09%%''
  
 The ''%%0D%%'' marks the end of a line:\\ The ''%%0D%%'' marks the end of a line:\\
   * line-1 ''%%0D%%'' line-2 ''%%0D%%'' last-line ''%%0D%%''   * line-1 ''%%0D%%'' line-2 ''%%0D%%'' last-line ''%%0D%%''
  
-The first line of each library chapter starts with case insensitive keyword(s) separated by spaces. The word ''%%CHAPTER%%'' builds this the first line, and provides this line with a+The first line of each library chapter starts with case insensitive keyword. The word ''%%CHAPTER%%'' builds this the first line, and provides this line with a
 backslash to prevent the keywords for being executed while loading a chapter. Then it adds all source code until the ''<nowiki>%%</nowiki>'' marker is found. The end of each chapter is marked by ''%%09%%'' backslash to prevent the keywords for being executed while loading a chapter. Then it adds all source code until the ''<nowiki>%%</nowiki>'' marker is found. The end of each chapter is marked by ''%%09%%''
 The end of the library is kept in a pointer that is updated when we extend the library.\\ The end of the library is kept in a pointer that is updated when we extend the library.\\
Line 425: Line 428:
 ==== A little extra ==== ==== A little extra ====
  
-Loading a lot of library code in one go. it is used like this: ''%%need( -rot -2rot d- asm\ )%%''\\+Loading a lot of library code in one go. It must be used like this: ''%%need( -rot -2rot d- asm\ )%%''\\
 Note that ''%%BL-WORD%%'' is a typical noForth word that uses ''%%REFILL%%'' inside, so it can load multiple lines of library words when you need too. Note that ''%%BL-WORD%%'' is a typical noForth word that uses ''%%REFILL%%'' inside, so it can load multiple lines of library words when you need too.
  
en/pfw/library.1731766280.txt.gz · Last modified: 2024-11-16 15:11 by willem