TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: KEN UZZELL
from: LAWRENCE GORDON
date: 1996-09-08 08:36:00
subject: File Copy

Quoting Ken Uzzell to All:
KU> In one application I am developing, I have to copy binary files from one
KU> directory to another as part of its function.
KU> In my older MS Basic, I used a provided library to do this, thus I never
KU> developed the programming expertise to write code to copy binary files.
KU> I scanned and searched the PBXTRA2 CD for helpful tips or samples but 
found
KU> none. Can someone please offer advise or point me in the right direction.
Here's one that I use:
Input "Enter filename to copy: ",a$
'assumes file in current directory
Input "Enter directory to copy to: ",b$
call copyit(a$,b$)
end
SUB COPYIT (f$, nf$) SHARED
olddir$ = curdir$
olddrive$ = ucase$(left$(olddir$,1))
newdrive$ = ucase$(left$(nf$,1))
open "B",1,f$
if lof(1) = 0 then
close #1
kill f$
exit sub
else
close #1
end if
nf$=nf$+f$
open nf$ for binary as #2
close #2
kill nf$
'the above kills any file of the same name in newdirectory open "B",1,f$ open 
"B",2, nf$ filepointer&& = 0 'set file pointer to 0 amountleft&& = lof(1)  
'get lof(1) and save it in a variable while not eof(1) seek #1, filepointer&& 
if amountleft&& > 32000 then     'check how much remains get$ #1, 32000, a$   
          'use 32000 bytes for speed put$ #2, a$ incr filepointer&&, 32000 
amountleft&& = amountleft&& - 32000  'reduce amount left by 32000 else get$ 
#1, amountleft&&, a$ put$ #2, a$ exit loop end if wend close #1, #2 END SUB
 * WCE 2.1G1/2081 * 
--- InterEcho 1.19
---------------
* Origin: Toast House * (314) 994-0312 * (1:100/560)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.