Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

CONCAT

Keyword Abbreviation Token (hex) Version(s) Classification
CONCAT CON{Shift+C} CC 4.x Command and Statement
RGR R{Shift+G} CC 3.5, 7.0 Function
CONCAT C{Shift+O} FE 13 7.0 Command and Statement

  Syntax   
CONCAT tailFile D tailDrive ] [ { , | ON } U unitNumber ] ... [ , ItwoChar ] [ , R ] ... TO headFile [ D headDrive ] [ { , | ON } U unitNumber ] ...
 
Parameters Type Legal Value(s) Default Value Note(s)
tailFile  String  1 to 16 characters   Must not begin with @ 
tailDrive Integer 0 or 1 0 Non-literal must be enclosed in parentheses ()
headFile String  1 to 16 characters   Must not begin with @ 
headDrive Integer  0 or 1  tailDrive  Non-literal must be enclosed in parentheses ()
unitNumber Integer  8 ~ 11  Non-literal must be enclosed in parentheses () 
twoChar Char[2]  any    Must be two literal characters. 
 
 
  Purpose  
Media file manipulation.  Append the contents of tailFile to the end of headFile.

 
  Remarks  
CONCAT extends headFile by appending the contents of tailFile.  The parameters headFile and tailFile are the filenames of the files you would like to "merge"; they should be located on drives headDrive and tailDrive respectively.  Both files must be on the same device (unitNumber).  Note the unitNumber may be given an unlimited number of times (before or after the TO preposition), but only the last value is used.  The unitNumber defaults to 8 if never given.
 
Both filenames are required.  If either filename has more than 16 characters then STRING TO LONG ERROR will be generated instead.  If either filename has zero characters then MISSING FILE NAME ERROR occurs.  If either filename begins with an @ character, BASIC generates SYNTAX ERROR (even though the device may allow this).  Many devices will complain if either filename includes wild-card characters, like ? and *, but BASIC does not care.
 
Most devices allow tailFile to be any "typical" type, like SEQ, PRG, or "real" (not GEOS VLIR) USR types, but require headFile to be SEQ unless a type-specfier is used.  However, the way BASIC constructs the command sent to the device, most devices will report SYNTAX ERROR if you try to specify a file-type with CONCAT.  Thus if you want to work with non-SEQ files, you have to use the "BASIC 2.0 method" by sending a properly constructed "copy" command (see a DOS reference manual).
 
Assuming the Syntax is good, BASIC sends a command to the device (this updates ST) and reports no error unless the command transmission failed (for example, DEVICE NOT PRESENT).  However, if either filename does not already exist, the device will normally generate an error "62, FILE NOT FOUND,00,00".  The device might generate an error in other cases (like write-protected media, or not enough space).  Be sure to check the device status with DS or DS$.
 
The drive numbers (tailDrive and headDrive) may be different, as far as BASIC is concerned.  Many devices only allow drive number 0.
  
If a required parameter is omitted, or 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 (string or numeric) 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, 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 R and U parameters, which may used an unlimited number of times (R is ignored), and the twoChar parameter which must always be two literal characters (also ignored but may not be repeated). 
  
Like all disk-based commands, CONCAT restricts the "drive/parittion" numbers (headDrive and tailDrive) to either 0 or 1 which often makes it unusable on a "disk" with multiple partitions.
 
Like all disk-based commands, CONCAT will reset DS$ and set the secret variable "DosFA" to the unitNumber.  It also indirectly updates ST.
 
Examples:
CONCAT "MORE" TO "BASE"    : REM append MORE onto BASE; both on drive 0, unit 8
CONCAT "MORE",D1 TO "BASE" : REM append MORE onto BASE; both on drive 1, unit 8
CONCAT "MORE" TO "BASE",D1 : REM append MORE (drive 0) onto BASE (drive 1); both on unit 8
CONCAT "MORE" TO "BASE",U9 : REM append MORE onto BASE; both on drive 0, unit 9
CONCAT (M$)TO(B$),U(U)     : REM using variables
 
 
  Compare With  
 
  Contrast With  
  See Also  
DS, DS$, ONPRINT#ST, TO 
© H2Obsession, 2014
Comments