Not logged in
Overview
SHA1 Hash:be937afc34780cd9665abf748d8f73ce2b550f3b
Date: 2010-06-14 20:40:24
User: crc
Comment:Start adding ported code snippits from comp.lang.forth newsgroup.
Timelines: family | ancestors | descendants | both | trunk
Other Links: files | manifest
Tags And Properties
Changes
[hide diffs]    [patch]

Added user/crc/comp.lang.forth/plainstruct.retro version [9d8b9f0bdde89142]

@@ -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 ;
+
+