TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: KEN UZZELL
from: MARCEL VELDHUIZEN
date: 1996-09-10 16:05:00
subject: File Copy

Hi Ken Uzzell, hope you are having a nice day
Monday, 2 September 1996 20:34:24, Ken Uzzell wrote to All Subject:
File Copy
 KU> samples but found none. Can someone please offer advise or point me
 KU> in the right direction.
 Actually, it's not that hard...
 Here's a home-made one:
----- PBCOPY.BAS -----
' One can switch on and off the dialog-box by using a non-zero / zero
' value for %Dialog...
%Dialog = 1
$IF %Dialog
  $LINK "D:\PB32\UNIT\SCRNUNIT.PBU"
$ENDIF
FUNCTION CopyFile (Source AS STRING, Destination AS STRING, MinWidth AS 
INTEGER) AS INTEGER
  'Install LOCAL error-handler
  ON LOCAL ERROR GOTO ErrorInCopy
  DIM FHandle (1 TO 2) AS INTEGER
  $IF %Dialog
    ' Calculate width of the box
    BoxWidth% = MAX(LEN(Source) + 11, LEN(Destination) + 11, MinWidth)
    ' Center it
    Column% = (80 - BoxWidth%) / 2
    DIM SaveScrn (BoxWidth% * 7) AS INTEGER
    QSAVE 10, Column%, 7, BoxWidth%, SaveScrn(0)
    QBOX 10, Column%, 7, BoxWidth%, 48
    QPRINT 11, Column% + 2, "From : " + Source, 48
    QPRINT 12, Column% + 2, "To   : " + Destination, 48
    QPRINT 14, Column% + 2, STRING$(BoxWidth% - 4, 176), 48
  $ENDIF
  ' Open source file
  FHandle(1) = FREEFILE
  OPEN Source FOR BINARY ACCESS READ SHARED AS FHandle(1)
  ' Open destination file
  FHandle(2) = FREEFILE
  OPEN Destination FOR BINARY LOCK READ WRITE AS #2
  Length& = LOF(FHandle(1))
  TotalLength& = Length&
  ' Start copying
  DO WHILE Length& > 0
    GET$ #1, MIN(2048, Length&), ReadF$
    DECR Length&, MIN(2048, Length&)
    PUT$ #2, ReadF$
    $IF %Dialog
      BarLength% = (TotalLength& - Length&) / TotalLength& * (BoxWidth% - 4)
      IF BarLength%  OldBar% THEN
        QPRINT 14, Column% + 2, STRING$(BarLength%, 219), 48
        OldBar% = BarLength%
      END IF
    $ENDIF
  LOOP
  CLOSE FHandle(1)
  CLOSE FHandle(2)
ExitCopyFile:
  $IF %Dialog
    QREST 10, Column%, 7, BoxWidth%, SaveScrn(0)
  $ENDIF
  EXIT FUNCTION
  ' Error handler:
ErrorInCopy:
  CopyFile = ERR
  RESUME ExitCopyFile
END FUNCTION
' Testing:
CLS
x% = CopyFile ("C:\MSIE30.EXE", "D:\MSIE30.EXE", 40)
----------
It hasn't gone through a lot of testing, I just created it.. It doesn't
screw up any files though;-)
It returns a 0 if succesfull or a standard PB error-code if not. The 40
in the test-line is the minimum width of the dialog-box to be used.
If you have further questions, feel free to ask..
 >>> Marcel Veldhuizen <<<<<<<< * Origin: United Bbs Systems Europe MailGate to -> Fido USA (2:2802/337.0)

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™.