Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \ STACKCHECKER.TXT
- \ Stack issue fixing tool by Jan Langevad / [email protected] 2026-02-10
- \ Place Copystack in your code/word that seems to have a stack problem.
- \ Place CheckStack in code/word, where you will check that stack is still intact,
- \ both in DEPTH and i content.
- \ Your program will stop if your stack has been changed unintentionally.
- \ By "zooming in" in your placement of these words, you should be able to locate
- \ nasty stack issues even in recursive programs.
- \ See alternative solution to same problem:
- \ https://github.com/forth2020/frenchie68/blob/main/sdigest-generic.4th
- \ by Francois Laagel
- 100 value StackLength \ choose your own wanted length!
- create StackCopy StackLength allot
- : CopyStack
- depth StackLength 1- >
- if CR ." StackCopy's StackLength is to small! Will call QUIT efter a KEY is entered"
- KEY drop QUIT
- then
- depth \ any data on stack?
- if depth StackCopy ! \ remember depth
- depth 0
- do depth i - 1- pick
- StackCopy i +
- 1+ \ skip over copy depth
- !
- loop
- then
- ;
- : CheckStack \ is stack = saved stack?
- Depth
- StackCopy @ =
- if \ cr ." Stack DEPTH OK !"
- \ check if stack content is unchanged:
- depth 0
- do depth i - 1- pick \ get stack entry
- StackCopy i + \ now, get saved entry
- 1+ \ skip over copy depth
- @
- =
- 0=
- if cr ." Stack entry changed! Hit ENTER! " KEY drop
- else \ cr ." Stack unchanged- OK! " cr
- then
- loop
- cr
- else cr ." Stack depth changed! Content: " cr .S
- ." Hit ENTER! " KEY drop
- then
- ;
Advertisement
Add Comment
Please, Sign In to add comment