Changes the name of a file on disk; in some implementations is used for renumbering lines and references to them
Implemented by: hptsb, msatari, GWBASIC, msxdisk, bwbasic, bw32, QBasic, VBDOS, FreeBASIC
With variations: ansifull (file attribute), decbasic, trsdisk (for renumbering lines), level3 (renumbers lines and line references)
Also written as:
In most Microsoft-based BASICs where it exists, NAME is a disk-only, file-related command implemented by extensions, interpreters or compilers with disk support. It takes a current file name, the AS particle and a new name:
NAME "TEST.BAS" AS "MYPROG1.BAS"
If the system supports multiple virtual and/or physical disk drives, the unit specifier may precede filenames. MSX and IBM-PC Microsoft BASICs will use the familiar single-letter-and-colon pattern:
NAME "A:TEST.BAS" AS "A:MYPROG1.BAS"
Uncertain behaviour might be expected if different drive specifiers are used for the old and new name.
Directory paths are also supported in BASICs that run on an hierarchical filesystem, such as the MS-QB family. Supposedly they should only be allowed with the current file name; it remains to be checked what happens if current and new file names contain paths, both equal and different.
TRS-80 BASICs had a different application for NAME: renumbering program lines, just like RENUM in other Microsoft-derived BASICs.
NAME 100, 10, 10
Check the RENUM page for an explanation on the arguments. In TRS-80 Level III BASIC, the command automatically updates the target lines of GOTO, GOSUB, THEN, ELSE, RESUME, INPUT#LEN, ON-GOTO and ON-GOSUB.
The ANSI Standard "Full" specification lists NAME as one of the "core attributes" for files that could be used in the list of arguments of an OPEN or ASK statement:
OPEN #3: NAME "myfile" ! The following command results in "myfile" being stored in N$: ASK #3: NAME N$
The specification is incredibly confusing about anything and whether a file can be renamed is no exception. SET is mentioned as one of the commands that provide "file operations" (section 11, caput), so it might be possible to use something like SET #3: NAME "newname
, but further mentions to SET in the section are apparently restricted to is usage with "pointer control" as part of the so-called "record operations".