Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

THRU loads blocks in reverse order #9

Open
eekee opened this issue Sep 13, 2023 · 0 comments
Open

THRU loads blocks in reverse order #9

eekee opened this issue Sep 13, 2023 · 0 comments

Comments

@eekee
Copy link

eekee commented Sep 13, 2023

THRU loads blocks from "last" to "first" because it uses the index value of a FOR loop. This is the reverse of all other Forths I use, including Pygmy for DOS. I solved the issue by copying the THRU definition from Pygmy for DOS, pygmy.scr block 83 to pygmy.fth, producing this:

: THRU ( first last -)
  OVER - 1+ FOR ( n) DUP PUSH LOAD POP 1+ NEXT    DROP ;

With the attached block file, thru-test.scr.txt, before the fix we see this:

> " thru-test.scr.txt" OPEN
 ok
> 1 LOAD
loading   2 4 THRU
block 5
block 4
block 3
HI ?

With the fix applied, it runs like this:

> " thru-test.scr.txt" OPEN
 ok
> 1 LOAD
loading   2 4 THRU
block 2
block 3
block 4
block 5
 ok
> BYE
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant