Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (divide)
      (equal)
      (less)
      (minus)
      (more)
      (multiply)
      (plus)
      (power)
      Abs
      And
      Append
      Asc
      Atn
      Auto
      Backup
      Bank
      Begin
      Bend
      Bload
      Boot
      Box
      Bsave
      Bump
      Catalog
      Char
      Chr
      Circle
      Close
      Clr
      Cmd
      Collect
      Collision
      Color
      Concat
      Cont
      Copy
      Cos
      Data
      Dclear
      Dclose
      Dec
      Def
      Delete
      Dim
      Directory
      Dispose
      Dload
      Do
      Dopen
      Draw
      Ds
      Ds string
      Dsave
      Dverify
      El
      Else
      End
      Envelope
      Er
      Err
      Exit
      Exp
      Fast
      Fetch
      Filter
      Fn
      For
      Fre
      Get
      Get num
      Getkey
      Go
      Gosub
      Goto
      Graphic
      Gshape
      Header
      Help
      Hex
      If
      Input
      Input num
      Instr
      Int
      Joy
      Key
      Left
      Len
      Let
      List
      Load
      Locate
      Log
      Loop
      Mid
      Monitor
      Movspr
      New
      Next
      Not
      Off
      On
      Open
      Or
      Paint
      Peek
      Pen
      Pi
      Play
      Pointer
      Poke
      Pos
      Pot
      Print
      Print num
      Pudef
      Quit
      Rclr
      Rdot
      Read
      Record
      Rem
      Rename
      Renumber
      Restore
      Resume
      Return
      Rgr
      Right
      Rlum
      Rnd
      Rreg
      Rspcolor
      Rsppos
      Rsprite
      Run
      Rwindow
      Save
      Scale
      Scnclr
      Scratch
      Sgn
      Sin
      Sleep
      Slow
      Sound
      Spc
      Sprcolor
      Sprdef
      Sprite
      Sprsav
      Sqr
      Sshape
      St
      Stash
      Step
      Stop
      Str
      Swap
      Sys
      Tab
      Tan
      Tempo
      Then
      Ti
      Ti string
      To
      Trap
      Troff
      Tron
      Until
      Using
      Usr
      Val
      Verify
      Vol
      Wait
      While
      Width
      Window
      Xor
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
KeywordAbbreviationToken (hex)Version(s)Classification
COLLECTCO{Shift+L}D14.xCommand and Statement
DECnoneD13.5, 7.0Function
COLLECTCOL{Shift+L}F33.5Command and Statement
COLLECTCOLL{Shift+E}F37.0Command and Statement

 Syntax  
COLLECT [ driveNumber ] [ { , | ON } U unitNumber ] ... [ , ItwoChar ] [ , R ] ... 
 
ParametersTypeLegal Value(s)Default ValueNote(s)
driveNumberInteger0 or 10Non-literal must be enclosed in parentheses ()
unitNumberInteger 8 ~ 11 Non-literal must be enclosed in parentheses () 
twoCharChar[2] any  Must be two literal characters. 
 
 
 Purpose 
Simple disk repair.  Checks and repairs the file system.

 
 Remarks 
COLLECT closes all files that are open on the device (unitNumber), regardless of which driveNumber they use, and then sends the device a "validate" command.
 
The "validate" command is device-specific.  The following is a an description of COLLECT in terms of a CBM-DOS file system (similar things would happen on FAT or NTFS file system).  First it rebuilds the BAM by freeing all blocks, then tracing all properly closed files in the disk directory and allocating each block of those files in the BAM.  Along the way, improperly closed files (so-called "splat" files) are removed from the directory.  Some software (in particular GEOS) stores data in blocks that can't be "found" the by most devices.  This results in some used blocks being marked "free" in the BAM.  Later writes to the "disk" can then use those blocks, but since they are really in use, the disk data has just become corrupt.  COLLECT should never be used on any commerical software disk (and some demo / hacker disks), unless the publisher specifically tells you it is safe to do so.  The makers of GEOS specifically tell you to never use COLLECT.
 
If an expression (enclosed in parentheses) is not valid, or an expression is used without parentheses, SYNTAX ERROR occurs.  If any parameter is not the correct type a TYPE MISMATCH ERROR will be generated.  Otherwise if a parameter is not a legal value (see table above), an ILLEGAL QUANTITY ERROR is generated.
 
Like all disk commands and statements, the Syntax is more flexible than shown above.  In particular, the parameters may be given in any order.  The general restrictions are: a comma (,) must not precede the first parameter (ON may do so), any non-literal value (a variable name or expression) must be enclosed in parentheses (), and do not supply the same parameter more than once.  Exceptions include the U and R parameters, which may used an unlimited number of times (R is ignored and the last unitNumber is used), and the twoChar parameter which must always be two literal characters (it may not be repeated although it is otherwise ignored). 
 
Assuming the syntax is good, BASIC will close all files on the device.  This may (rarely) generate an error by the KERNAL (for example DEVICE NOT PRESENT). Next it sends the "validate" command which again may be generate a KERNAL error; otherwise BASIC will not complain.  However you should check the error/status channel with DS or DS$ to ensure the command completed successfully.
 
Like all disk-based commands, COLLECT restricts the driveNumber to either 0 or 1 which often makes it unusable on a "disk" with multiple partitions.
 
Like all disk-based commands, COLLECT will reset DS$ and set the secret variable "DosFA" to the unitNumber (defaults to 8 if not given).  It also indirectly updates ST.
 
Examples:
COLLECT      : REM validate disk in drive 0 of unit 8
COLLECT U9   : REM validate disk in drive 0 of unit 9
COLLECT U(U) : REM validate disk in drive 0 of the unit given by variable U
 
 
 Compare With 
 
 Contrast With 
 See Also 
DS, DS$ONPRINT#ST
© H2Obsession, 2014