Arrays with bounds checking#

\ Arrays with bounds checking

| : (ARRAYERROR 
    ABORT" Array out of bounds!" ; 

: ARRAY ( size -- )
  CREATE DUP , 2* ALLOT
  DOES> ( i -- addr )
  OVER        0< (ARRAYERROR
  2DUP @ 1- - 0> (ARRAYERROR
  SWAP 1+ 2* + ;

: CARRAY ( size -- )
  CREATE DUP , ALLOT
  DOES> ( i -- addr )
  OVER        0< (ARRAYERROR
  2DUP @ 1- - 0> (ARRAYERROR
  + 1+ ;

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 03-Feb-2023 16:21 by Carsten Strotmann  
G’day (anonymous guest) My Prefs
© 2010-2021 AtariWiki
All content in the Wiki is licensed under Creative Commons Share Alike License, unless otherwise noted.
JSPWiki v2.8.3