string2anyfield.txt


\ string2anyfield 99.5.9 1:50pm CRJ

\ Forth translation of standard C
\ code for writing on screen fields
\ (SetFieldTextFromStr function)
\ Ported 99.5.5 by carl@ucsd.edu

needs core-ext
needs Forms

: string>Handle ( str u -- handle. )
  DUP 1+ S>D MemHandleNew
  2DUP 2>R MemHandleLock 2>R
  DUP 0 SWAP 2R@ ROT M+ C!A
  S>D ROT >abs 2R> MemMove DROP
  2R> 2DUP MemHandleUnlock DROP ;

: freeHandle ( handle. -- )
  2DUP OR IF MemHandleFree DROP
  ELSE 2DROP THEN ;

: handle>Field ( handle. fieldID -- )
  GetObjectPtr
  2DUP FldGetTextHandle 2>R
  2SWAP 2OVER FldSetTextHandle
  FldDrawField   2R> freeHandle ;

: string>anyField ( str u fieldID -- )
  >R string>Handle R> handle>Field ;


  HTMLized by Forth2HTML