Qbasicnews.com
February 27, 2020, 07:54:33 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: How To Copy And Rename Files Using Free Basic  (Read 7405 times)
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #15 on: July 23, 2005, 11:00:11 AM »

Quote from: "Z!re"
arpgme, you just got SERVED!.. BOOOH YA!




*Ya, i know he's banned.. i just feelt like saying booh ya

Who are you and what have you done with my Z!re?
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Z!re
*/-\*
*****
Posts: 4599


« Reply #16 on: July 23, 2005, 11:15:16 AM »

:Huh:
Logged
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #17 on: July 23, 2005, 03:57:47 PM »

Quote
Who are you and what have you done with my Z!re?


...you have a z!re? Tongue
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #18 on: July 23, 2005, 06:32:16 PM »

well... I do =P
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #19 on: July 23, 2005, 06:57:25 PM »

Yeah, I have a Z!re and a whitetiger0990 and even a didjeridoo so they can play together!
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Z!re
*/-\*
*****
Posts: 4599


« Reply #20 on: July 23, 2005, 09:13:32 PM »

I suddenly feel very... objectified..
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #21 on: July 23, 2005, 09:57:00 PM »

I saw a hand held computer called "zire" at Radio Shack... For a second, I thought I was in a 3D forum..  Shocked .. But then I noticed, it was spelled Z-I-R-E, not Z-!-R-E...  Tongue
Logged

Kevin (x.t.r.GRAPHICS)

DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #22 on: July 23, 2005, 11:44:28 PM »

Palm Zire
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #23 on: July 24, 2005, 06:55:24 AM »

I'm so famous they named a Palm after me.. kind of old news though Tongue
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #24 on: July 24, 2005, 10:51:04 AM »

Yeah.. I don't get out much.. just saw it last week or so..  Tongue
Logged

Kevin (x.t.r.GRAPHICS)

Moneo
Na_th_an
*****
Posts: 1971


« Reply #25 on: July 24, 2005, 06:50:34 PM »

Quote from: "Sterling Christensen"
.....Here's some code:
Code:
const bufferSize = 1024
old$ = "\old_folder\old_name.blah"
new$ = "\new_folder\new_name.blah"

' If new$ exists, delete it:
if len(dir$(new$)) then kill new$

open old$ for binary access read as #1
open new$ for binary access write as #2

' Assuming FB's input$ works like QB's, and assuming
' FB's put has no chr$(0) trouble, this should work:
do
   buffer$ = input$(bufferSize, #1)
   put #2, , buffer$
loop until len(buffer$) < bufferSize

close #1, #2


EDIT: Method #2 2.0 - the "I forgot filenames can have spaces" release:
Code:
#ifdef __FB_LINUX__
const copyCommand = "cp"
#else
const copyCommand = "copy"
#endif

shell copyCommand + " " + chr$(34) + old$ + chr$(34) + " " + chr$(34) + new$ + chr$(34)


I've had bad experiences copying files from within a QB program by reading the first file and writing to the second. Opening the files for binary helps most of the time.

But, if the file is foreign to you, that is, you didn't create it, you could run into the following problems:
1) Non-standard end-of-record delimiters. (ok if open binary)
2) chr$(0) versus chr$(255) problems.
3) No end of record delimiters at all, which could cause input buffer overflow. (ok if open binary)
4) A zero-length-file which will probably cause an error on input.

All of the above problems go away if you SHELL to a COPY or MOVE command.

Also, if the input file does not exist, the COPY or MOVE will flash an error and continue, which may be good or bad for you. If your program opens the non-existant file, it hangs up on the error.
*****
Logged
speedlemon
I hold this place together
*****
Posts: 874



« Reply #26 on: July 24, 2005, 10:54:58 PM »

thanks benedicto for that solution.
i put this in the right section... wtf arpgme?
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #27 on: July 25, 2005, 08:18:57 AM »

Code:
open file1$ for binary as #1
ll = lof(1)
redim fbuff(ll-1) as ubyte
get #1, 1, fbuff()
close #1

kill file2$
open file2$ for binary as #1
put #1, 1, fbuff()
close #1
redim fbuff(0) as ubyte

Enjoy
Logged
speedlemon
I hold this place together
*****
Posts: 874



« Reply #28 on: July 25, 2005, 11:57:00 AM »

"Enjoy"
thanks, i will.

by the way, fieldview is looking hot. Cool
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #29 on: July 25, 2005, 12:21:22 PM »

heh, thanks.. if we could only finish it so people could see how hot it really is Tongue
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!