Skip to content

THRU loads blocks in reverse order #9

@eekee

Description

@eekee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions