SCRATCH

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: SCRATCH
Abbreviation: SC Shift+R
Type: Command
Token code: BASIC 4.0:
217/$D9
BASIC 3.5 and 7.0:
242/$F2
Handling routine
in BASIC ROM:
BASIC 3.5:
51674–51699
$C99C–$C9F3
BASIC 7.0:
41798–41825
$A2A1–$A2D6
List of all BASIC keywords


Remark: This article describes the BASIC command SCRATCH in Commodore BASIC V3.5 or higher.

Type: Command
General Programming-Syntax: SCRATCH <filename> [,D<drive number>] [[,]ON U<device number>]

SCRATCH is a BASIC 3.5 command that is used to delete files on a diskette.
The filename parameter may consists of multiple filenames separated by a comma (string is limited to 16 characters) which may also contain wildcard characters or a file type selector.
In direct mode the action is preceded by an interactive request for acknowledgment:

ARE YOU SURE?

Any input not starting with "Y" aborts the command.

In direct mode the disk error status (also provided in system variable DS$) shows how many files actually have been deleted (by means of the track value). Because the track number is limited to 2 digits, values greater than 99 will get cut off at the hundreds. Even though 100 files have been scratched the result became 00 which makes it impossible to determine the actual count of deleted files for all cases.

Examples[edit | edit source]

Removes file "GAME 1" from the disk in drive 0 of floppy device 8:

SCRATCH "GAME 1"

Tries to remove two files (if existing):

SCRATCH "GAME,SCORE"

Tries to remove file "UTIL" and all files with name length of one, but only of sequential type:

SCRATCH "UTIL,?=S"

Removes file "BAD-GAME" from disk on drive 1 of an dual-drive floppy addressed as device 9:

SCRATCH "BAD-GAME", D1, U9

Same as the previous but with alternative parameter syntax:

SCRATCH "BAD-GAME" ON U9,D1

Removes all files starting with "DATA-198" of any ending (match all wildcard "*") on device 11 (implicitly drive 0):

SCRATCH "DATA-198*",U11

Using variables (the command is executed without a acknowledgement question):

100 MASK$="SCR*"
110 DRIVE=0
120 DEV=8
130 SCRATCH (MASK$),D(DRIVE),U(DEV): PRINT "Status: ";DS$


BASIC V3.5 Commands

ABS | ASC | ATN | AUTO | BACKUP | BOX | CHAR | CHR$ | CIRCLE | CLOSE | CLR | CMD | COLLECT | COLOR | CONT | COPY | COS | DATA | DEC | DEF | DELETE | DIM | DIRECTORY | DLOAD | DO | DRAW | DS | DS$ | DSAVE | END | EL | ELSE | ER | ERR$ | EXIT | EXP | FN | FOR | FRE | GET | GET# | GETKEY | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | INSTR | INT | JOY | KEY | LEFT$ | LEN | LET | LIST | LOAD | LOCATE | LOG | LOOP | MID$ | MONITOR | NEW | NEXT | ON | OPEN | PAINT | PEEK | POKE | POS | PRINT | PRINT USING | PRINT# | PUDEF | RCLR | RDOT | READ | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | RLUM | RND | RUN | SAVE | SCALE | SCNCLR | SCRATCH | SGN | SIN | SOUND | SPC | SQR | SSHAPE | STOP | STR$ | SYS | TAB | TAN | TRAP | TROFF | TRON | UNTIL | USR | VAL | VERIFY | VOL | WHILE | WAIT