NAME a$ AS b$
NAME StringExpr1 AS StringExpr2
Description:
This command renames the file specified in the string expression StringExpr1 to StringExpr2. StringExpr1 can represent any valid filename that is not a read-only file, and StringExpr2 can be any valid filename as long as it doesn't specify a file that already exists.
Usage:
'rename the old file as a backup
name rootFileName$ + ".fre" as rootFileName$ + ".bak"
'open a new file and write data
open rootFileName$ + ".fre" for output as #disk
Name is used to rename a file
It fails if:
1. The file to be renamed DOESN't exist
2. The file it is to be renamed to, DOES already exist.
You can tell if it fails cause your program crashes
Err = 53 if file to be renamed DOESN'T exist.
Err = 58 if the file to be renamed to already exist.
You can avoid the crash by
0 staying in bed that day
1 Checking the attributes of the file to be renamed to make sure it is not read-only. Change the attributes, or don't apply the rename.
2 Verifying the file to be renamed exists, and either create it, or don't apply the rename.
3 Verifying that the file being renamed to DOESN'T exist before attempting to rename it. If it DOES exist, rename it first, or kill it.
4 If file to be renamed DOESN'T exist, 'you could create it' or 'don't apply the rename after checking'
5 Use on error goto [label], check the Err code, and code an alternative solution.
6 Don't use the NAME command.
7. You can also avoid this, and many other problems, by reading the forums and applying what the experts recommend.
BTW -
NOT TRUE, I've been renaming files with read-only attributes without errors while running some tests.
A bug? or another help file error?