Main
   Home
   About
   DiscussionBoard
Files
   About
   Submit
   Search
Downloads
   Action
   QB64
Links
   Link to us
QB45.org
[ Back to QB45 | FAQ | Search a message | Reply to this message | Back to messages ]

gablea on 08/16/11 - 09:51:49

Hi all

how do I copy a file with in my App so I can display a message saying

Transfering product.dat 12% ||||||--------

||||----- is to be a ascii process bar.

any thoughts?

Todd on 09/07/11 - 14:17:43

I don't have the QB docs open at the moment but what you would need to do is determine the file size using a DOS API call/interrupt and then store the size in a LONG or DOUBLE. Then open the file in binary input mode and allocate a small buffer (more than likely a string) in memory (16 KB is good) and read the data into the string with 16 KB at a time. Then write the data to the new location using a file pointer opened in binary output mode. One concern is when you read the end of the file and it's less than 16 KB. You will need a way to find how much data was read in (again may be in the QB docs) then save it as the last part of the file.

The progress bar is simple since you store a long for the size and a long for the data that has been read and transferred. The progress is refreshed each time you read part of the file.

TopGun on 09/09/11 - 23:47:46

u can use something like this perhaps:

do

progress = progress + 1
if progress > 100 then END

LOCATE 10,6: print str$(progress) + "----------"

for bar = 0 to progress

locate 10, 10 + bar: print "|"

next bar

loop


Something like that, I never tested the code but pretty sure it works. Should be easy to modify to your program I think :)

TopGun on 09/09/11 - 23:54:47

LOL pretty sure that's not what you're looking for HAHA it's been a long day! But even still it might come in handy lol

Plasma on 10/27/11 - 20:00:57



DECLARE SUB CopyFile (From$, To$)

SUB CopyFile (From$, To$)

' Open the input file in binary mode
InFile = FREEFILE
OPEN From$ FOR BINARY AS #InFile

' Open the output file
' (truncate it if it exists)
OutFile = FREEFILE
OPEN To$ FOR OUTPUT AS #OutFile
CLOSE #OutFile

' Reopen the output file in binary mode
OPEN To$ FOR BINARY AS #OutFile

' Copy the file
DO WHILE NOT EOF(InFile)
Buffer$ = INPUT$(4096, 1)
PUT #OutFile, , Buffer$
LOOP

' Close the files
CLOSE #OutFile
CLOSE #InFile

END SUB

Reply to this message
Name:
Message:
Please enter this number:
No HTML allowed. You may use BB-code in your posting.
Members
Login
Register
QB45 Members
Member List