Some non-standard words are implemented in SharpForth:
  • SYNTAX Shows (if available) the Forth ( -- ) syntax of a Forth Word. Example:
#4th>SYNTAX DUP
DUP (n1 -- n1 n1)  OK
  • TRACE, TRACEON and TRACEOFF can be used for debugging. Example:
TRACEON
123 5 .R
TRACEOFF

Will produce debug output (use SysInternals DebugView or Microsoft Visual Studio to capture and see it) of the words being executed, the execution nesting and the parameter stack before/after the word. TRACE is a variable.
  • LOAD-FILE <filename> will load a file and execute/interpret it. Note that the filename must be enquoted if it contains one or mote spaces.
  • DATA-MARKER is a pseudo word that is used to signal SEE to output the remaining definition of a word as an array. Example showing the actual live content of data stored inside a word:
#4th>CREATE VAL 3 CELLS ALLOT SEE VAL
: VAL 11993108 EXIT [ 0 0 0 ] ;
#4th>3 VAL ! SEE VAL
: VAL 11993108 EXIT [ 3 0 0 ] ;
  • SEE SharpForth's implementation of SEE nicely shows the live content of words created with CREATE, CONSTANT, VARIABLE or VALUE like:
#4th>VARIABLE VAR SEE VAR
: VAR 11993108 EXIT [ 0 ] ;
#4th>10 VAR ! SEE VAR
: VAR 12058644 EXIT [ 10 ] ;

and
#4th>10 VALUE VAL SEE VAL
: VAL 10 ;
#4th>5 +TO VAL SEE VAL
: VAL 15 ;

  • $TEMP Puts the %TEMP% Variable into the String buffer and leaves a c-addr and len on the stack :
$TEMP PEEK"

  • *$HOME Puts the %HOMEDRIVE%%HOMEPATH% Variables as a single string into the String buffer and leaves a c-addr and len on the stack :
$HOME PEEK"

  • $OS Puts the %OS% Variable into the String buffer and leaves a c-addr and len on the stack :
$OS PEEK"

  • PEEK" prints the string who's address and len are on the top of the stack without modifying the stack:
$TEMP PEEK"

  • PI puts Pi on top of the Stack:
PI F.

  • E puts e on top of the Stack:
E F.

  • TERM-HEIGHT puts the Terminal Window Height on top of the Stack:
TERM-HEIGHT .

  • TERM-WIDTH puts the Terminal Window Width on top of the Stack:
TERM-WIDTH .

  • ELAPSED puts the SharpForth Uptime in msec on top of the Stack:
ELAPSED .

  • FLUSH clears the input buffer:
FLUSH

Last edited Jan 3, 2014 at 12:40 PM by wvd_vegt, version 10

Comments

No comments yet.