ADDED user/crc/comp.lang.forth/plainstruct.retro Index: user/crc/comp.lang.forth/plainstruct.retro =================================================================== --- user/crc/comp.lang.forth/plainstruct.retro +++ user/crc/comp.lang.forth/plainstruct.retro @@ -0,0 +1,45 @@ +( Title: Plain Structures + File: plainstruct.fs + Version: 1.0.1 + Adaptor: David N. Williams + License: Public Domain + Test file: plainstruct-test.fs + Log file: plainstruct.log + Revised: June 14, 2010 +) + +decimal +: struct ( -- 0 ) 0 ; +: /struct: ( <"sizename"> u -- ) aligned constant ; +: +field ( offset size <"name"> -- offset+size ) + ` : over .data + ` .data ` + ` ; ; +: cfield: ( offset <"name"> -- offset+1char ) + 1 +field ; +: field: ( offset <"name"> -- offset+1cell ) + 1 +field ; +: 2field: ( offset <"name"> -- offset+2cells ) + 2 +field ; +: sfield: ( offset <"name"> -- offset+2cells ) + 2 +field ; + + + +struct ( point) + 1 +field >x + 1 +field >y + 1 +field >plotchar + /struct: /point + +create mypoint /point allot + 15 mypoint >x ! + 22 mypoint >y ! + 'o mypoint >plotchar ! + +: mypoint@ ( -- x y plotchar /point ) + mypoint push + r >x @ + r >y @ + pop >plotchar @ + /point ; + +