Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tip: use name function instead of cmd shell move
#1
It's not so obvious, but it's night/day difference using "name" function instead of cmd shelling out to "Move" a file.  My main use of using the "name" function is to rename files inside of a directory.  And so for a majority of others too.

Things to remember be in one of the two directories. "CHDir"  use the "..\name-of-file" to move to present or other directory (reversible command).  ie: name "..\name-of-file" as "name-of-file".  example moves other file in directory to present chdir.  It's possible to rename the destination file to something else like: "new-name-of-file"  Twice the work for a single function.

PS.
It really is night n day difference.

Thought i would share.  B4 you comment.  Using name function to move is a benefit only to people who read deeply in the help records.
Reply
#2
For sure that's something which many people are not aware of, although its mentioned at the Wiki page https://qb64phoenix.com/qb64wiki/index.php/NAME

However, be careful that both paths are on the same drive or you risk a "Rename across disks" error. Not sure if this is still valid for QB64, but QBasic did error out when you tried to move a file from one to another drive. https://qb64phoenix.com/qb64wiki/index.php/ERROR_Codes
Reply
#3
(04-03-2023, 10:46 PM)RhoSigma Wrote: or you risk a "Rename across disks" error.

Point taken.  Better off using a program to move it off disk, and or rename it then.
Reply
#4
This is for historical reasons. On Unix, and on MS-DOS beginning in v2, a directory is actually a file which only has information about other files. Therefore "renaming" a file inside a directory a child of the "root", to the computer is like changing a word in a text file. The "root" directory, however, was handled quite differently at least in MS-DOS; it had a limited number of entries stored directly into the FAT or something like that.

It would have been irritating if M$ came up with "NAME" for QuickBASIC/BASIC PDS and it wasn't possible to move a file from one child directory to another, and instead had to copy to destination, verify destination and then delete source. Programmers would have insisted on the quirk which really isn't.
Reply




Users browsing this thread: 7 Guest(s)