\ 4tH library - TOOLBELT BACK - Copyright 2004,2007 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] BACK [IF]
: BACK ( addr1 n1 c -- addr1 n2 )
  >R BEGIN DUP IF OVER OVER 1- CHARS + C@ R@ <> ELSE DUP THEN
  WHILE 1- REPEAT R> DROP
;

: -SCAN OVER >R BACK R> OVER - >R CHARS + R> -1 /STRING ;

: (SPLIT)                  ( a1 n1 a2 n2  -- a2 n2 a1 n1-n2 n2)
   DUP >R ROT >R ROT R> R@ - R> ;
: /SPLIT                   ( a1 n1 a2 n2  -- a2 n2 a1 n1-n2)
  (SPLIT) DROP ;
: -SPLIT                   ( a1 n1 a2 n2  -- a2 n2 a1+n2 n1-n2)
  (SPLIT) CHARS ROT + SWAP ;

[DEFINED] 4TH# [IF]
hide (SPLIT)
[THEN]
[THEN]

