TweetFollow Us on Twitter

Record Definitions
Volume Number:5
Issue Number:2
Column Tag:Forth Forum

Record Definitions

By Jörg Langowski, MacTutor Editorial Staff

“Record definitions in Mach2”

Record structures and arrays are not part of standard Forth implementations. More than two years ago, in V2#7, I had given an example how to implement records. Mach2 has evolved since then, and so have ways of implementing new data structures, as you can see in the Object Forth project by Wayne Joerding that we recently discussed. For those of you who do not want a full object-oriented system, but still ways of defining data structures in an easy way, I have found two examples on the GEnie bulletin boards. Those examples show two fundamentally different approaches to deal with record definitions.

‘Local’ field names - method 1

The problem in setting up the Forth compiler to deal with record definition in a proper way is somewhat similar to implementing an object-oriented programming system. That is, just like a message is local to an object, and the same message may cause different effects on different objects, a field name should be local to a record. In the Pascal record definitions


rec1 = record
 x: real;
 i: integer;
 y: real;

rec2 = record
 y: real;
 j: integer;
 x: real;

the field x would create a different offset into a record of type rec2 than for a rec1 type; and rec1.i, rec2.j would be valid while rec1.j, rec2.i would not. So if we define a field name as some kind of Forth word, this word should be in some ‘local vocabulary’ that belongs to the record definition and is only visible while the field reference is resolved.

The other requirement is that we should be able to pass a record as a parameter to a routine, so that given the pointer to a record on the stack, a Forth definition would know how to resolve the field reference. In a strongly typed language like Pascal this is easy; field references into record formal parameters can be resolved at compile time because the procedure arguments are of defined type. In Forth, typically the address of a data structure would be passed on the stack. However, at compile time there is no way we can restrict the type of argument that this address might later point to at run time! This problem could only be solved by type checking built into the record definition and deferring the resolution of the field reference to run time, some sort of ‘late binding’.

The first method of record definition (Listing 1), written by Waymen Askey of Palo Alto Shipping (I added some minor modifications, like floating point and array support), creates a local dictionary for each record template in the Forth dictionary space. When a record template is defined, using the syntax


template rec1
 :real x
 :word i
 :byte c

its field names x, i and c are compiled into the dictionary together with relevant information for resolving the references. At the end of the template declaration, the dictionary links are changed in such a way that the ‘local’ names are skipped when the dictionary is searched. Let’s declare a record:


rec1 structure myRec

A field of this record is later accessed by using the structure fetch/store words, s@ and s!.

myRec x s@ will put the value in field x of myrec on the floating point stack, and myRec i s@ will put the word value of field i on the stack. The trick Waymen used was to build some intelligence into the fetch/store words. When the record and field words, myRec and x for example, are executed or compiled into a definition, field type and offset are determined and kept in global variables. The s@ word will check these variables and know how to access the field, whether - in immediate execution - to do a byte, word or long word fetch, addressing into an array, or a ten-byte fetch onto the floating point stack for a real number; or at compile time create code that will do these things later.

The drawback of this approach is that field references can only be resolved at compile or immediate execution time. If we wanted to write a word that operates on a record whose address is passed on the stack, we couldn’t use the field names that were defined in the record template - they are only valid right after a record name was executed or compiled. Therefore, a definition like


: getX { myRec -- } myRec x s@ ;  

must fail because myRec is a local variable, not a record name.

An example how to use this method of record declaration with various field types is given at the end of the listing. You see the drawback: Even though the record fields wavelength, temperature, and angle are all themselves structures of the same type parameter, there is no way to factor out the common code in


 cr curve1 wavelength name s^ count type .” = “
 curve1 wavelength value s@ f.
 curve1 wavelength unit s^ count type
 cr curve1 temperature name s^ count type .” = “
 curve1 temperature value s@ f.
 curve1 temperature unit s^ count type
 cr curve1 angle name s^ count type .” = “
 curve1 angle value s@ f.
 curve1 angle unit s^ count type

by using a word that would just print name, value and unit of any given parameter. If this problem was resolved, the record compiler would almost be perfect.

‘Global’ field names - method 2

Listing 2 shows a much simpler approach to structure definitions that does not do type checking. I downloaded this code from the Forth Roundtable on GEnie, and unfortunately have not the slightest idea who the author is. All I could find out was that the original code was probably posted on the East Coast Forth Board.

However, since this code solves one of our problems, record passing as formal parameters, I’d like to print it here. Its strategy is much more like that of the structure words built into MacForth Plus. Here, a record template is defined like


RECORD Rectangle
        Global  SHORT: Top
        Global  Short: Left
        Global  Short: Bottom
        Global  SHORT: RIght
Variable myRect Rectangle 4 - VALLOT ;

so the record name, when executed, simply leaves the record length on the stack for later ALLOT or VALLOT. The field names are words which add the field offset to an existing address on the stack, so they can be used in any context. We have to check ourselves whether the address is a valid record address and whether the field referenced actually exists in that record (if we care at all). All field names are global, and therefore must be unique; no two different record declarations can have fields of the same name at different offsets.

This approach is not so different from the very basic one that I used in most of my examples, where I simply defined field names as constants and added the offset to the record address.

What the Macintosh Forth world needs is really a combination of the two approaches, with type checking at compile time and local field names for convenience, and a possibility to resolve field references on record addresses at compile time without too much overhead. If one knew the type of the record passed on the stack ahead of time (which is usually the case), one could probably define some ‘field reference resolution word’ which computes an offset given a template and a field name. I hope I can show you an example in one of my next columns.

Upcoming: an update to Wayne Joerding’s Object Forth, and a review of PocketForth, a public domain 16-bit Forth that comes as an application and a desk accessory. Stay tuned.

Listing 1: Structure definitions with local field names
\ STRUCTUREs 2.5   for the Macintosh  MACH2
\ Jan 3, 1987 by Waymen Askey 
\ edited, floating point & array addition by 
\ J. Langowski @ MacTutor
\ This MACH2 extension is released for the public good; 
\ however, for those planning commercial use of this code, 
\ please notify  me so that I might know of its intended use.
\              Waymen Askey @ PASC
\  also GEnie MACH2 RoundTable.

only mac also sane also forth definitions
variable current.template
variable op.type
variable A5offset ( holds the A5 offset to a structure )

( CODE word utilities used in STRUCTURE 2.5 )
code  ( -- a | variable link pointer )
 lea $F7F8(A5),A0
 move.l A0,-(A6)

code a5@  ( -- a )
 move.l A5,-(A6)
end-code mach
code get.field  ( a1 a2 -- a3 -1 or 0 | searches templates )
  ( a1=template, a2= pad, a3=field pointer, 0 if not found )
 move.l (A6)+,D2
 move.l (A6)+,D3
 moveq.l #0,D1
 moveq.l #0,D0
@start  movea.l D3,A1
        movea.l D2,A0
        move.b (A1)+,D1  ( link to next field )
        beq.s @end       ( if link=0, field not found )
        move.b (A1),D0
@loop   cmpm.b (A1)+,(A0)+
        dbne D0,@loop
        beq.s @found
        add.l D1,D3   ( increment field pointer )
        bra.s @start
@found  movea.l D3,A1
        move.b 1(A1),D1  ( get string count )
        addq.w #2,D1
        btst #0,D1  ( test for odd count )
        beq.s @even
        addq.w #1,D1
@even   add.l D1,D3
        moveq.l #-1,D1
        move.l D3,-(A6)
@end    move.l D1,-(A6)

code >sr  ( n -- | push value onto subroutine stack )
 move.l (A6)+,-(A7)
end-code mach

code sr>  ( -- n | pop value from subroutine stack )
 move.l (A7)+,-(A6)
end-code mach

code sr@  ( -- n | copy value from subroutine stack )
 move.l (A7),-(A6)
end-code mach

( Miscellaneous utility words used in STRUCTURE 2.5 )
: >even  ( a -- a’ | 
 word aligns address, i.e. rounds up to even)
 dup  1 and  + ;

: >odd  ( a -- a’ | odd aligns address, rounds up to odd )
 1 or ;

: needed  ( n -- | checks for at least n items on stack )
 depth 1- > abort” Missing needed stack item(s)! “ ;

( Brute-force machine code words )
: ncode,  
( n1...n -- | machine code defining word, stuffs n words )
 create   dup needed   dup 2* w,   
 0 do   w,   loop
 does>   ( -- | compiles machine code )
 dup   2+ swap   dup w@   +   
 do   i  w@  w,   -2 +loop ;  

( define some machine code “stuff” words )
41ED 1 ncode,  lea_d(a5),a0      
4EBA 1 ncode, jsr_d(PC)
4EAD 1 ncode, jsr_d(A5)
( LEA and JSR also need a word of extension for displacement )
2D3C 1 ncode, move.l_#,-(A6)  
 ( plus a long extension for # )
2D08 1 ncode,  move.l_a0,-(a6)     
4E75 1 ncode,  rts,
( The following expect an address to be in A0 )
7000 1010 2D00 3 ncode, byte@
7000 3010 2D00 3 ncode, word@
2D10 1 ncode, long@
201E 1080 2 ncode, byte!
201E 3080 2 ncode, word!
209E 1 ncode, long!
\ disassemble the following to check how they work.
\ Exercise for the reader... - JL
5187 5587 2247 22d8 22d8 32d8 6 ncode, real@
2247 20d9 20d9 30d9 5087 5487 6 ncode, real!
201e e580 2d30 0000 4 ncode, array@
201e e580 219e 0000 4 ncode, array!
201e e380 4281 3230 0000 2d01 6 ncode, warray@
201e e380 221e 3181 0000 5 ncode, warray!

( Dictionary header, name, and struct link words )
: link>name   ( lfa -- ‘nf | ‘nf points to header length byte)
 4 + ;
: name.count   
 ( ‘nf -- ‘nf+1  n | dictionary header name count)
 count 31 and ;

: link>segment  
 ( lfa -- ‘sf | ‘sf is the dictionary segment field address)
 link>name name.count  +  >even ;
: link>parameter  
 ( lfa -- ‘pf | ‘pf is the parameter field pointer)
 link>segment 2+ ;

: link>struct  ( lfa -- struct.fields )
 link>segment 4 + ;
: jsr_d(PC),  ( lfa -- | compiles PC relative JSR)
 link>body here -  w, ;
: jsr_d(A5),  
 ( lfa -- | compiles A5 relative JSR, i.e. jump table )
 link>parameter w@  w, ;
:  ( -- lfa | returns lfa of )
 “” find  drop ;

: nallot  ( n -- | allots n bytes in name space )
 np +! ; 
: name,   ( -- parses and compiles text into name space.)
 32 word  np @  over c@ 1+  dup >odd nallot  cmove ;
: nc,  ( n -- | compiles byte into name space )
 np @ c!   1 nallot ;
: nw,  ( n -- | compiles word into name space )
 np @ w!   2 nallot ;
: n,  ( n -- | compiles long into name space )
 np @ !   4 nallot ;
( TEMPLATE, STRUCTURE and field words )
: struct.error  ( -- )
  cr pad count type 
  .”  ?  Error, unknown field or incomplete structure path! “
  abort ;
: template  ( -- here 0 | begins TEMPLATE definition )   
  create here 0   2 allot 
  does>  ( -- template.size ) 
    dup w@ swap 4 - body>link   current.template ! ;
: tend  
 ( here n -- | (T)emplate(END) ends template definition  )
  swap w!   0 nw, ;
: afield  ( size op.type --  )
  create  w,  >even w,
  does>  ( here Toffset -- here new.Toffset )
         ( Toffset means (T)emplate(OFFSET) )  
    2dup 2+   w@  + >sr  
    w@  np @ >sr  1 nallot  name,  
    0 nc, ( field type=0 )   nc, ( op.type )   
    nw, ( Toffset )   np @ sr@ - sr> c! ( field link )
    sr> ;
( The following op.types are reserved and defined below )
( 06 byte, 12 word, 18 long, 24 string, 
 30 real, 36 struct, 42 array, 48 warray )

( op.type  AFIELD  named.afield.type )
1  06 afield  :byte   
2  12 afield  :word
4  18 afield  :long
10 30 afield  :real

: :string  ( here Toffset size -- here Toffset+size+1  )
 3 needed  1+   over +   >even swap   
 np @ >sr  1 nallot  name,   
 0 nc, ( field type=0 )   24 nc, ( op.type=24) 
   nw, ( Toffset )   np @ sr@ - sr> c! ( field link ) ;     

: :array  ( here Toffset size -- here Toffset+size+1  )
 3 needed  4* over +   swap   np @ >sr  1 nallot  name,   
 0 nc, ( field type=0 )   42 nc, ( op.type=42) 
  nw, ( Toffset )   np @ sr@ - sr> c! ( field link ) ;     

: :warray  ( here Toffset size -- here Toffset+size+1  )
 3 needed  2* over +   swap   np @ >sr  1 nallot  name,   
 0 nc, ( field type=0 )   48 nc, ( op.type=48) 
  nw, ( Toffset )   np @ sr@ - sr> c! ( field link ) ;     

: :struct  ( here Toffset size -- here Toffset+size  )
 3 needed  over +   >even swap   
 np @ >sr  1 nallot  name,  
 06 nc, ( field type=06 )  36 nc, ( op.type=36 )
 nw, ( Toffset )
 current.template @ - n, ( template link )  
  np @ sr@ - sr> c! ( field link ) ;  

: >pad  ( a -- | moves string to pad )
  pad over c@ 1+  cmove ;

:  { | name.pointer var.pointer vlink --  }
 np @ -> name.pointer @ -> var.pointer   
 name.pointer ! 
 name.pointer var.pointer -    -> vlink
 name.pointer dup 1 and + -> name.pointer
 vlink name.pointer !
 name.pointer 4 + np ! ;

( Decision table for field type decode )
: do.afield ( ^field.type --  true )
 1+ dup c@ op.type !   1+ w@ A5offset +!   -1 ;

: do.bfield  ( ^field.type -- new.template false )
 dup 1+ dup c@ op.type !   1+ w@ A5offset +!
 4 + @ +   link>struct   0 ; 

: rts rts, ; immediate
( DO.FIELD table entries decode field data )
( afield’s are simple :BYTE, :WORD, 
 :LONG, :STRING types )
( bfield’s are :STRUCT fields )

create do.field  ( field_type  table_offset/type )
]do.afield rts  (   afield         0            )
 do.bfield rts  (   bfield         6            )
[                ( end of current table          )

: make.struct  ( A5offset  -- )   
( This is the word which must resolve a structure reference. )
  A5offset !  ( A5 displacement for the struct )
  36 op.type !  ( set default op.type to struct ) +  link>struct  ( template.address -- )
    32 word   >pad
    pad get.field        
    if  ( field found )
      dup  c@ do.field +  execute
    else ( field not found )
      pad find 1 = 
        link>body   execute  -1
  until ;

: structure  
( n -- | creates structure alloting n bytes in variable space )
  1 needed create   immediate   
  -4 allot lea_d(a5),a0  vp @ w,  ( variable-like beginning )
  move.l_#,-(A6)  current.template @ - ,    
  move.l_#,-(A6)   vp @ ,  
  “ make.struct” find drop dup link>segment  w@ 0=
  if  jsr_d(PC),  else  jsr_d(A5), then
  vallot ; 

( STRUCTURE operators )
: compileA5  ( -- | compiles A5 reference )
  lea_d(a5),a0  a5offset @ w, ;

: pushA5  ( -- | executes A5 var reference )
  a5offset @ a5@ + ;

: do.bit  ( -- )  ( I’m lazy, define your own.  W. Askey )
  cr .” BIT operations are yet undefined!” abort ;
: do.struct  ( -- )  ( Fetch/store doesn’t make sense here. )   
  cr .” STRUCTURE fetch/store operations are undefined! “ abort ;
: do.string  ( -- )  ( If you wish, define your own. )
  cr .” STRING fetch/store operations are undefined! “ abort ;
: do.byte@  ( f -- )
  if compileA5  byte@ else  pushA5 c@ then ;
: do.word@  ( f -- )
  if compileA5  word@ else pushA5 w@ then ;
: do.long@  ( f -- )
  if compileA5 long@ else pushA5 @ then ;
: do.array@  ( idx f -- )
  if compileA5 array@ else 4* pushA5 + @ then ;

: do.warray@  ( idx f -- )
  if compileA5 warray@ else 2* pushA5 + w@ then ;

: do.real@  ( f -- )
  if compileA5 real@ else pushA5 f@ then ;

 ( Decision table for fetch )
 create op.table@   ( op.types are offsets into this table ) 
 ]  do.bit rts      ( op.type = 0  )
    do.byte@ rts    (  “  “   = 6  )
    do.word@ rts    (  “  “   = 12 )
    do.long@ rts    (  “   “  = 18  etc, etc. )
    do.string rts
    do.real@ rts
    do.struct rts
 do.array@ rts
 do.warray@ rts

: do.byte!  ( f -- )
  if compileA5  byte! else pushA5 c! then ;
: do.word!  ( f -- )
  if compileA5  word! else pushA5 w! then ;
: do.long!  ( f -- )
  if compileA5 long! else pushA5 ! then ;

: do.array!  ( idx f -- )
  if compileA5 array! else 4* pushA5 + ! then ;

: do.warray!  ( idx f -- )
  if compileA5 warray! else 2* pushA5 + w! then ;

: do.real!  ( f -- )
  if compileA5 real! else pushA5 f! then ;

create op.table!  ( decision table for store )
]do.bit rts
 do.byte! rts
 do.word! rts
 do.long! rts
 do.string rts
 do.real! rts
 do.struct rts
 do.array! rts
 do.warray! rts
: s^  ( -- a | returns pointer to structure field )
( ALL field types are allowed. i.e. strings, struct, etc. )
 state @ 
 if  compileA5 move.l_a0,-(a6) else pushA5 then 
; immediate

: s@  ( -- data | Fetch field contents, data type smart)
  state @
  op.type @ op.table@ + execute ; immediate

: s!  ( data -- | Store into field, data type smart)
  state @
  op.type @ op.table! + execute ; immediate
: stype  ( -- op.type | returns the op.type of a field )
 op.type @  state @ 
  if [compile] literal then 
; immediate
( Examples of structure usage.  Data Storage is limited to the approximately 
32K global area referenced off of register A5 -- just as for regular 
MACH2 variables. Structure references have a REQUIRED syntax, it is best 
NOT to use any non-STRUCTURE Forth words when between field names in 
a structure calling sequence.  That is, please end each structure reference 
prior to any DUP’s, SWAP’s, etc. The structure pointer operator -- S^ 
-- may be used at any place in the structure calling sequence.  S^ will 
return the address of the field or structure itself.  Structures MUST 
be terminated with a defined structure operator!  The defined operators 
in this upload are S^, S@, S!, and STYPE.  WARNING, if you forget to 
terminate a structure, no structure reference will be compiled and an 
error message MAY NOT be given.  Remember also that field names ARE CASE 
SENSITIVE and LOCAL to the structure template.  Last comment, structures 
MAY be nested to any level. ) 


template Point
 :word x
 :word y

template Rect
  :word top
  :word left
  :word bottom
  :word right
tend  ( TEND ends template definition )
\ example for FP parameters 
template parameter
30 :string name
 :real value
30 :string unit

template measurement
 :long date \ in internal Mac format
80 :string title
255 :string descriptor
parameter :struct wavelength
parameter :struct temperature
parameter :struct angle
256:array time
256:array counts

measurement structure curve1

: testarray
 100 0 do i 4* i curve1 time s! loop
 100 0 do i curve1 time s@ . cr loop;

: .date ( DateTime DateForm ) { | [ 40 lallot ] mydate -- }
 8 shift ^ mydate call IUDateString ^ mydate count type;

 pad 1+ 80 expect span @ pad c! pad number? not while
 drop cr .” Illegal number [integer], reenter - “

: read.float
 pad 1+ 80 expect span @ pad c! pad fnumber? not while
 fdrop cr .” Illegal number [float], reenter - “

: setup.curve1 { | dattim -- }
 ^ dattim call readdatetime drop @
 cr .” Today is “ 1 .date
 cr .” Setting up parameters for curve 1.”
 dattim curve1 date s!
 “ lambda” dup c@ 1+ curve1 wavelength name s^ swap cmove 
 “      T” dup c@ 1+ curve1 temperature name s^ swap cmove 
 “  delta” dup c@ 1+ curve1 angle name s^ swap cmove 
 “ [nm]” dup c@ 1+ curve1 wavelength unit s^ swap cmove 
 “  [K]” dup c@ 1+ curve1 temperature unit s^ swap cmove 
 “  [°]” dup c@ 1+ curve1 angle unit s^ swap cmove 
 cr .” Title (one line) - “ cr pad 80 expect
 span @ curve1 title s^ c!
 pad curve1 title s^ 1+ span @ cmove 
 cr .” Description (one line) - “ cr pad 80 expect
 span @ curve1 descriptor s^ c!
 pad curve1 descriptor s^ 1+ span @ cmove
 cr .” lambda [nm] - “ read.float curve1 wavelength value s!
 cr .”      T  [K] - “ read.float curve1 temperature value s!
 cr .”  delta  [°] - “ read.float curve1 angle value s!
\ example setup of ‘measurement data’
 20 0 do
 i i curve1 time s!
 i 100 * i curve1 counts s!

 cr .” End setup -- “ cr;
: dump.curve1 { | [ 80 lallot ] mydate -- }
 cr .” Data taken on “ curve1 date s@ 1 .date
 cr curve1 title s^ count type
 cr curve1 descriptor s^ count type
 cr curve1 wavelength name s^ count type .” = “
 curve1 wavelength value s@ f.
 curve1 wavelength unit s^ count type
 cr curve1 temperature name s^ count type .” = “
 curve1 temperature value s@ f.
 curve1 temperature unit s^ count type
 cr curve1 angle name s^ count type .” = “
 curve1 angle value s@ f.
 curve1 angle unit s^ count type
 cr .” data follows:”
 20 0 do cr
 i curve1 time s@ . space
 i curve1 counts s@ .
Listing 2: Structure definitions from ECFB
\ downloaded from GEnie  J. L. Nov 1988
\ Originally from East Coast Forth Board, 
\ author A. Nonymous
( This is a set of machforth routines for building records. They allow 
you to build a named record with items of various sizes. Executing the 
record name leaves the record size on the stack, executing an item name 
leaves the offset of the item into the record on the stack. It creates 
a template for the record but not the actual record. Create the record 
with “ create <name> <record name> allot” or “variable <name> <record 
name> 4 - vallot” depending if you want the entry in the dictionary or 
variable space )
: Align ( n1 -- [n1] or [n1 + 1] makes n word aligned )
        dup 2 mod + ; ( USED TO WORD ALIGN 2 & 4 BYTE ITEMS )
: RECORD ( -- a 0)
         HERE 4 +  CREATE  0 dup W,  DOES>  W@ ;
         ( USED TO OPEN A RECORD )
: BYTE: ( a n -- a n1+1)
        CREATE DUP W, 1+ DOES> W@ + ;
: BYTES: ( a n1 n2 -- a n1+n2 | AN ARRAY OF n2 bytes ) 
        CREATE OVER Align W, swap Align + DOES> W@ + ;
: SHORT: ( a n1  -- a n1+2 | 2 byte integer item )
        CREATE Align DUP W, 2+ DOES> W@ + ;

: WORD: ( a n1  -- a n1+2 | 2 byte integer item )
        CREATE Align DUP W, 2+ DOES> W@ + ;
: BOOLEAN: ( a n1  -- a n1+2 | 2 byte boolean item )
        CREATE Align DUP W, 2+ DOES> W@ + ;
: SHORTS: ( a n1 n2 -- a n1+n2*2 | an array of n2 shorts )
   CREATE OVER Align  W,  2* Swap Align  + DOES> W@ + ;
: LONG:  ( a n1  -- a n1+4 | a 4 byte integer )
        CREATE Align DUP W, 4 + DOES> W@ + ;
: POINTER:  ( a n1  -- a n1+4 | a 4 byte integer )
        CREATE Align DUP W, 4 + DOES> W@ + ;
 ( a n1 n2 -- a n1+n2*4 | an array of n2 4 byte integers )
  CREATE OVER Align  W, 4 * swap Align + DOES> W@ + ;
: HANDLE: ( a n1  -- a n1+4 | a handle, 4 byte, item )
        CREATE Align DUP W, 4 + DOES> W@ + ;
: HANDLES: ( a n1 n2 -- a n1+n2*4| array of n2 handles )
  CREATE OVER Align  W, 4 * swap Align  + DOES> W@ + ;
: ADDR: ( a n1  -- a n1+4 | 4 byte address item, ie pointer )
        CREATE Align DUP W, 4 + DOES> W@ + ;
: ADDRS: ( a n1 n2 -- a n1+n2*4 | array of n2 addresses )
  CREATE OVER Align  W, 4 * swap Align + DOES> W@ + ;
: RECT: ( a n1 n2 -- a n1+8 | a rect item )
  CREATE Align DUP W, 8 + DOES> W@ + ;
: RECTS: ( a n1 n2 -- a n1+n2*8 | an array of n2 rects )
  CREATE  OVER Align  W, 8 * swap Align + DOES> W@ + ;
: STRING: ( a n1 n2 -- a n1+n2+1 | a string item n2+1 long ) 
  CREATE OVER W, + 1+ DOES> W@ + ;
: RECORD: ( a n1 n2 -- a n1+n2 | a record item of size n2) 
  CREATE OVER Align  W, swap Align + DOES> W@ + ;
 { Mainaddr size --|sets size of struct at a to n }
                Mainaddr W@ Size <
                IF Size MainAddr W! THen ;
: SUB.REC ( -- )
        CReate  0 W, 2DUP Here 2- Rot Rot DOES> W@ ;
: END.SUB { SubAddrs MainAddrs Size -- }
        Size SubAddrs W!
        MainAddrs W@ Size <
        IF Size Align MainAddrs W! THen ;
RECORD Rectangle
        Global  SHORT: Top
        Global  Short: Left
        Global  Short: Bottom
        Global  SHORT: RIght
: rect Variable Rectangle 4 - VALLOT ;


Community Search:
MacTech Search:

Software Updates via MacUpdate

Apple GarageBand 10.1 - Complete recordi...
The new GarageBand is a whole music creation studio right inside your Mac -- complete with keyboard, synths, orchestral and percussion instruments, presets for guitar and voice, an entirely... Read more
Duplicate Annihilator 5.7.7 - Find and d...
Duplicate Annihilator takes on the time-consuming task of comparing the images in your iPhoto library using effective algorithms to make sure that no duplicate escapes. Duplicate Annihilator... Read more
OS X Server 4.1.3 - For OS X 10.10 Yosem...
Designed for OS X and iOS devices, OS X Server makes it easy to share files, schedule meetings, synchronize contacts, develop software, host your own website, publish wikis, configure Mac, iPhone,... Read more
pwSafe 4.1 - Secure password management...
pwSafe provides simple and secure password management across devices and computers. pwSafe uses iCloud to keep your password databases backed-up and synced between Macs and iOS devices. It is... Read more
Kodi 15.0.rc1 - Powerful media center to...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
Coda 2.5.11 - One-window Web development...
Coda is a powerful Web editor that puts everything in one place. An editor. Terminal. CSS. Files. With Coda 2, we went beyond expectations. With loads of new, much-requested features, a few surprises... Read more
Bookends 12.5.7 - Reference management a...
Bookends is a full-featured bibliography/reference and information-management system for students and professionals. Access the power of Bookends directly from Mellel, Nisus Writer Pro, or MS Word (... Read more
Maya 2016 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
RapidWeaver 6.2.3 - Create template-base...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
MacFamilyTree 7.5.2 - Create and explore...
MacFamilyTree gives genealogy a facelift: it's modern, interactive, incredibly fast, and easy to use. We're convinced that generations of chroniclers would have loved to trade in their genealogy... Read more

Rage of Bahamut is Giving Almost All of...
The App Store isn't what it used to be back in 2012, so it's not unexpected to see some games changing their structures with the times. Now we can add Rage of Bahamut to that list with the recent announcement that the game is severely cutting back... | Read more »
Adventures of Pip (Games)
Adventures of Pip 1.0 Device: iOS iPhone Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: ** ONE WEEK ONLY — 66% OFF! *** “Adventures of Pip is a delightful little platformer full of charm, challenge and impeccable... | Read more »
Divide By Sheep - Tips, Tricks, and Stre...
Who would have thought splitting up sheep could be so involved? Anyone who’s played Divide by Sheep, that’s who! While we’re not about to give you complete solutions to everything (because that’s just cheating), we will happily give you some... | Read more »
NaturalMotion and Zynga Have Started Tea...
An official sequel to 2012's CSR Racing is officially on the way, with Zynga and NaturalMotion releasing a short teaser trailer to get everyone excited. Well, as excited as one can get from a trailer with no gameplay footage, anyway. [Read more] | Read more »
Grab a Friend and Pick up Overkill 3, Be...
Overkill 3 is a pretty enjoyable third-person shooter that was sort of begging for some online multiplayer. Fortunately the begging can stop, because its newest update has added an online co-op mode. [Read more] | Read more »
Scanner Pro's Newest Update Adds Au...
Scanner Pro is one of the most popular document scanning apps on iOS, thanks in no small part to its near-constant updates, I'm sure. Now we're up to update number six, and it adds some pretty handy new features. [Read more] | Read more »
Heroki (Games)
Heroki 1.0 Device: iOS Universal Category: Games Price: $7.99, Version: 1.0 (iTunes) Description: CLEAR THE SKIES FOR A NEW HERO!The peaceful sky village of Levantia is in danger! The dastardly Dr. N. Forchin and his accomplice,... | Read more »
Wars of the Roses (Games)
Wars of the Roses 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: | Read more »
TapMon Battle (Games)
TapMon Battle 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: It's time to battle!Tap! Tap! Tap! Try tap a egg to hatch a Tapmon!Do a battle with another tapmons using your hatched tapmons! *... | Read more »
Alchemic Dungeons (Games)
Alchemic Dungeons 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: ### Release Event! ### 2.99$->0.99$ for limited time! ### Roguelike Role Playing Game! ### Alchemic Dungeons is roguelike... | Read more »

Price Scanner via

13-inch 1.6GHz MacBook Air on sale for $849,...
Best Buy has the 2015 13″ 1.6GHz/128GB MacBook Air on sale for $849.99 on their online store this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders... Read more
Apple Refurbished iMacs available for up to $...
The Apple Store has Apple Certified Refurbished iMacs available for up to $380 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free: - 27″ 3.5GHz 5K iMac – $1949 $... Read more
Apple refurbished 2014 13-inch Retina MacBook...
The Apple Store has Apple Certified Refurbished 2014 13″ Retina MacBook Pros available for up to $400 off original MSRP, starting at $979. An Apple one-year warranty is included with each model, and... Read more
Seagate Backup Plus Drives Feature 200GB of C...
Seagate Technology plc has announced that its Backup Plus family of external storage offerings will now include 200GB of OneDrive cloud storage, a major added value, and the addition of Lyve’s photo... Read more
Canon PIXMA MG3620 Wireless Inkjet All-in-One...
Canon U.S.A., Inc. has announced the PIXMA MG3620 Wireless (1) Inkjet All-in-One (AIO) printer for high-quality photo and document printing. Built with convenience in mind for the everyday home user... Read more
July 4th Holiday Weekend 13-inch MacBook Pro...
Save up to $150 on the purchase of a new 2015 13″ Retina MacBook Pro at the following resellers this weekend. Shipping is free with each model: 2.7GHz/128GB MSRP $1299 2.7GHz/... Read more
27-inch 3.5GHz 5K iMac on sale for $2149, sav...
Best Buy has the 27″ 3.5GHz 5K iMac on sale for $2149.99. Choose free shipping or free local store pickup (if available). Sale price for online orders only, in-store prices may vary. Their price is $... Read more
Apple now offering refurbished 2015 11-inch...
The Apple Store is now offering Apple Certified Refurbished 2015 11″ MacBook Airs as well as 13″ MacBook Airs (the latest models), available for up to $180 off the cost of new models. An Apple one-... Read more
15-inch 2.5GHz Retina MacBook Pro on sale for... has the 15″ 2.5GHz Retina MacBook Pro on sale for $2274 including free shipping. Their price is $225 off MSRP, and it’s the lowest price available for this model. Read more
Finally Safe To Upgrade To Yosemite’?
The reason I’ve held back from upgrading my MacBook Air from OS X 10.9 Mavericks to 10.10 Yosemite for nearly a year isn’t just procrastination. Among other bugs reported, there have been persistent... Read more

Jobs Board

*Apple* Music Producer - Apple (United State...
**Job Summary** Apple Music seeks a Producer to help shepherd some of the most important content and editorial initiatives within the music app, with a particular focus Read more
Editor, *Apple* News - Apple (United States...
**Job Summary** Editor, Apple News The Apple News team is looking for passionate, knowledgeable editors to help identify and deliver the best in breaking national, Read more
*Apple* Watch SW Application Project Manager...
**Job Summary** The Apple Watch software team is looking for an Application Engineering Project Manager to work on new projects for Apple . The successful candidate Read more
Engineering Project Manager - *Apple* Searc...
**Job Summary** Apple 's new Spotlight Suggestions service provides fast, relevant search results from the Inte et in Spotlight and Safari on iOS and OS X. We are looking Read more
Business Development Manager - *Apple* Pay...
**Job Summary** Apple Pay is seeking an experienced relationship manager to support the ongoing management of partners for the Apple Pay platform. This position will Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.