Hello Mikael
is there a way to use interpret in a buffer?
i mean, i have a buffer with some forth words, and some definitions.
if i need several buffers to interpret, i cannot use evaluate, because some of them finish in the midle of a definition, ande aluate doesnt work. but maybe if i change the source and use interpret i can use it and following reading the newbuffer until the end...
exMple:
create buffer 10 allot
buffer ------> ( : test 1 cr 1 + . ; )definition in two lines. twice the buffer
buffer evaluate doesnt work but I think if source is buffer, buffer interpret should work?
the idea is to interpret a text with multiline definitions longer than the buffer writing and reading the text to/from buffer several times. ( always complet lines finishing with cr lf )
Last edit: Pere font vilanova 2025-11-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1 ram create buf 20 allot
2 : test buf 20 evaluate ;
3 s" test3 1 2" buf swap cmove
4 test
5 buffer 20 erase
6 s" + . ;" buf swap cmove
7 test
test3---->3
if this possible?
my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.
Last edit: Pere font vilanova 2025-11-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I was writing the block words I found that FF should be restructured to accept input from a large buffer using REFILL. But I never did that restructuring.
Anyway it is easiest to have a line buffer that can accept a whole line, and evaluate one line at a time. If you take in only part of a line you may cut off some words in the middle which again a more difficult thing to handle.
So LOAD has the restriction that one line is always 64 bytes and a word is not allowed to be split across a 64 byte boundary.
When you have many lines in the 256 byte buffer you can interpret it one line at a time by analyzing the buffer for the line addresses and lengths and then give those to evaluate.
For the next 256 byte block you have to handle the overlap with the previous block. I think you would need 2 buffers for that.
Last edit: Mikael Nordman 2025-11-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you for the information. my idea was to have two buffer, a buffer 256 bytes and then a buffer of 64 bytes and a handle system. but now i'm thinking to have only one of 64 bytes and fill it reading the text until cr, evaluate and do the same until the end of file. i will check and try this idea and I will inform you.
It does not work because after the first evaluate the system is in compilation state so interpret will try to compile the phrase " buf2 c@+ evaluate" instead of executing it.
The word test2 only executes so there is no dependence on state.
Last edit: Mikael Nordman 6 hours ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've finally managed to read an entire 4K text from external storage without worrying about truncated definitions or being stuck mid-word at the end of a 256-byte page of Scamp3e. I parse to the next CR (even if it's on the next page), save it in a 64-byte buffer, and then evaluate. It works perfectly even when a definition is evaluated in several parts, as you mentioned in your answer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
WHAT ?
Hello Mikael
is there a way to use interpret in a buffer?
i mean, i have a buffer with some forth words, and some definitions.
if i need several buffers to interpret, i cannot use evaluate, because some of them finish in the midle of a definition, ande aluate doesnt work. but maybe if i change the source and use interpret i can use it and following reading the newbuffer until the end...
exMple:
create buffer 10 allot
buffer ------> ( : test 1 cr 1 + . ; )definition in two lines. twice the buffer
buffer evaluate doesnt work but I think if source is buffer, buffer interpret should work?
the idea is to interpret a text with multiline definitions longer than the buffer writing and reading the text to/from buffer several times. ( always complet lines finishing with cr lf )
Last edit: Pere font vilanova 2025-11-15
This works for me
Last edit: Mikael Nordman 6 hours ago
Having CR LF inside the buffer also works. All control bytes ( <32) are interpreted as white space.
Using evaluate like this does not work.
Last edit: Mikael Nordman 6 hours ago
what i really need: with loops and more accurate
1 ram create buf 20 allot
2 : test buf 20 evaluate ;
3 s" test3 1 2" buf swap cmove
4 test
5 buffer 20 erase
6 s" + . ;" buf swap cmove
7 test
test3---->3
if this possible?
my goal is evaluate a complet file of 4 K with a buffer of 256 bytes.
Last edit: Pere font vilanova 2025-11-15
When I was writing the block words I found that FF should be restructured to accept input from a large buffer using REFILL. But I never did that restructuring.
Anyway it is easiest to have a line buffer that can accept a whole line, and evaluate one line at a time. If you take in only part of a line you may cut off some words in the middle which again a more difficult thing to handle.
So LOAD has the restriction that one line is always 64 bytes and a word is not allowed to be split across a 64 byte boundary.
When you have many lines in the 256 byte buffer you can interpret it one line at a time by analyzing the buffer for the line addresses and lengths and then give those to evaluate.
For the next 256 byte block you have to handle the overlap with the previous block. I think you would need 2 buffers for that.
Last edit: Mikael Nordman 2025-11-15
thank you for the information. my idea was to have two buffer, a buffer 256 bytes and then a buffer of 64 bytes and a handle system. but now i'm thinking to have only one of 64 bytes and fill it reading the text until cr, evaluate and do the same until the end of file. i will check and try this idea and I will inform you.
last : why buf c@+ evaluate buf2 c@+ evaluate doesn't work? and : test2 buf c@+ evaluate buf2 c@+ evaluate ; works.?
Last edit: Pere font vilanova 2025-11-15
It does not work because after the first evaluate the system is in compilation state so interpret will try to compile the phrase " buf2 c@+ evaluate" instead of executing it.
The word test2 only executes so there is no dependence on state.
Last edit: Mikael Nordman 6 hours ago
I've finally managed to read an entire 4K text from external storage without worrying about truncated definitions or being stuck mid-word at the end of a 256-byte page of Scamp3e. I parse to the next CR (even if it's on the next page), save it in a 64-byte buffer, and then evaluate. It works perfectly even when a definition is evaluated in several parts, as you mentioned in your answer.