Rename

I writing a program that needs to select a file at random, not hard. but what I then have to do is rename the file so that it can be used in a secondary program. Is there any way to rename a file while still in basic?

-Margalo ;-)

Comments

  • : I writing a program that needs to select a file at random, not hard. but what I then have to do is rename the file so that it can be used in a secondary program. Is there any way to rename a file while still in basic?
    :
    : -Margalo ;-)
    :

    ==============
    Depends on what version/platform the BASIC language is run on, a much rougher way of doing this is to copy the file using the read and write commands and delete the original.

    Maybe you could write a null string "" to the old file to almost erase it?

    I have never tried this on the BASIC computers i have used in the past.

    Hope this helps? :-)

    DrM

  • : I writing a program that needs to select a file at random, not hard. but what I then have to do is rename the file so that it can be used in a secondary program. Is there any way to rename a file while still in basic?
    :
    : -Margalo ;-)
    :
    If you're using QuickBasic or QBasic you can use the following statement:

    NAME - a statement that uses DOS to change the name of a disk file
    or directory
    Syntax
    NAME oldfilename AS newfilename
    > oldfilename, a string expression, is the name of an existing file.
    > newfilename, a string expression, must be a filename that does not exist. This could be tricky. Do a SHELL with a DIR to make sure.

    Tip: oldfilename and/or newfilename may contain a pathname. If the path in oldfilename is different than the path in newfilename, the NAME statement moves the file and renames it. Both files must be on the same drive.

    NOTE: If the NAME statement doesn't work for you, then I would copy the old file to a new file, but only using the SHELL statement. Then delete the old file with KILL if you like. Don't copy using reads and writes 'cause you can run into too many problems, like null characters, end-of-file characters, etc.

    Good luck!
    *****
    .NAME Statement QuickSCREENi


    QuickSCREEN Details Example Contents Index
    ──────────────────────────────────────────────────────────────────────────────
    NAME - a statement that uses DOS to change the name of a disk file
    or directory
    Syntax
    NAME oldfilename AS newfilename
    ■ oldfilename, a string expression, is the name of an existing file.
    ■ newfilename, a string expression, must be a filename that does not
    exist

    Tip: oldfilename and/or newfilename may contain a pathname. If the path
    in oldfilename is different than the path in newfilename, the NAME
    statement moves the file and renames it. Both files must be on the
    same drive.



  • : : I writing a program that needs to select a file at random, not hard. but what I then have to do is rename the file so that it can be used in a secondary program. Is there any way to rename a file while still in basic?
    : :
    : : -Margalo ;-)
    : :
    : If you're using QuickBasic or QBasic you can use the following statement:
    :
    : NAME - a statement that uses DOS to change the name of a disk file
    : or directory
    : Syntax
    : NAME oldfilename AS newfilename
    : > oldfilename, a string expression, is the name of an existing file.
    : > newfilename, a string expression, must be a filename that does not exist. This could be tricky. Do a SHELL with a DIR to make sure.
    :
    : Tip: oldfilename and/or newfilename may contain a pathname. If the path in oldfilename is different than the path in newfilename, the NAME statement moves the file and renames it. Both files must be on the same drive.
    :
    : NOTE: If the NAME statement doesn't work for you, then I would copy the old file to a new file, but only using the SHELL statement. Then delete the old file with KILL if you like. Don't copy using reads and writes 'cause you can run into too many problems, like null characters, end-of-file characters, etc.
    :
    : Good luck!
    : *****
    : .NAME Statement QuickSCREENi
    :
    :
    : QuickSCREEN Details Example Contents Index
    : ──────────────────────────────────────────────────────────────────────────────
    : NAME - a statement that uses DOS to change the name of a disk file
    : or directory
    : Syntax
    : NAME oldfilename AS newfilename
    : ■ oldfilename, a string expression, is the name of an existing file.
    : ■ newfilename, a string expression, must be a filename that does not
    : exist
    :
    : Tip: oldfilename and/or newfilename may contain a pathname. If the path
    : in oldfilename is different than the path in newfilename, the NAME
    : statement moves the file and renames it. Both files must be on the
    : same drive.
    :
    :
    :
    :
    YESSSSSSSSSSSSS! TY TY TY! I knew there was somthing I hadn't tryed! DUH! *smacks self in head* TY agian!

    -Margalo ;-)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories