Filecopy in VB 1.0?
|
|
Thread rating:  |
Jan D. - 28 Dec 2006 15:58 GMT Hello all,
I want to write a small program for an old computer with Windows 3.1. Obviously, the program needs to be 16-bit, so I am using VB 1.0 to do this.
I need to make a copy of a file called "blank.txt" and then rename the copy. Renaming is not a problem, but I just can't figure out how to make a copy of a file in VB1, there doesn't seem to be a filecopy command. I assume there is such a command in later versions, but VB1 and VB6 is all I have. Any ways around this?
Thank you,
J French - 28 Dec 2006 16:32 GMT >Hello all, > [quoted text clipped - 7 lines] >command. I assume there is such a command in later versions, but VB1 >and VB6 is all I have. Any ways around this? The simplest way is to open both files in Binary mode and read/write chunks - copying the FileDateTime would require APIs
There is a CopyFile API it probably exists in Win16
Probably your best bet would be to find a list of the Win16 APIs - you'll probably need them later
Rick Rothstein (MVP - VB) - 28 Dec 2006 16:55 GMT >>I want to write a small program for an old computer with Windows 3.1. >>Obviously, the program needs to be 16-bit, so I am using VB 1.0 to do [quoted text clipped - 8 lines] > The simplest way is to open both files in Binary mode and read/write > chunks - copying the FileDateTime would require APIs I would guess you could do it all at once like this, right?
Open "<<OldFileNameWithPath>>" For Binary As #1 TotalFile$ = Space$(LOF(1)) Get #1, , TotalFile$ Close #1 Open "<<NewFileNameWithPath>>" For Output As #2 Print #2, TotalFile$ Close #2
Rick
J French - 28 Dec 2006 17:48 GMT On Thu, 28 Dec 2006 11:55:31 -0500, "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
<snip>
>I would guess you could do it all at once like this, right? > [quoted text clipped - 5 lines] > Print #2, TotalFile$ > Close #2 My problem, Rick, is that I come from the (pre) MSDOS days, so I'm really mean with memory.
Actually once you start using 100kb buffers I find that speed improvements are almost imperceptable.
One catch though :
> Print #2, TotalFile$ > Print #2, TotalFile$ ; The ';' is needed to avoid adding a CrLf (I know you know that - the explanation is for the record)
Frank Adam - 28 Dec 2006 21:01 GMT On Thu, 28 Dec 2006 11:55:31 -0500, "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
>>>I want to write a small program for an old computer with Windows 3.1. >>>Obviously, the program needs to be 16-bit, so I am using VB 1.0 to do [quoted text clipped - 18 lines] > Print #2, TotalFile$ > Close #2 I kinda recall that there was a buffer limitation of 16Ks in Win3.1(or shall we call it DOS in drags ?). Under DOS i'm pretty sure 8K chunks were the norm. Win16 may have raised that to 16 ? So i rather opt to a simple numchunks and leftover thing and keep the buffer size low to 32-64Ks max even now.
Geez, I don't believe how much of that old stuff seems like just a bad dream now and how i'm struggling to remember the details. The brain really does shut out bad experiences.. :)
 Signature Regards, Frank
Jan D. - 29 Dec 2006 00:29 GMT On Thu, 28 Dec 2006 11:55:31 -0500, "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
>I would guess you could do it all at once like this, right? > [quoted text clipped - 5 lines] > Print #2, TotalFile$ > Close #2 This works great! Thank you very much!
Neila - 28 Dec 2006 22:51 GMT Hmmmmmmm Jan, Upon entering the 9th circle of hell (VB1 on Win3.1) , dusting off numerous neurons, and wasting 100's of fruitless hours, you will slap yourself upside the head and mutter in a shaky, drunken micro-moment of preregugitation lucidity something no living human will be able to comprehend (BAWRRGGAWRRAHHHHGAAGAAGAAOOOOHHHHFUKKKMEOOHOOHARGHHH). When they come to take you away you will ask yerself WTF was I thinking (struggling with the straightjacket while using a bic lighter to burn your way out of the padded room)??? I did some work using VB4/16 on a 386 YEARS AND YEARS AGO!!! During development I thought seriously about hurling the Win31 box from the 13th floor to the street below after waiting for what seemed like HOURS for the screens to repaint. Killing my boss was another fleeting thought. NOW, One can buy a new box for dirt cheap or refurbish an old box for a little bit more than buying a new one. Developing ANYTHING for Win3.1 using VB1.0 is a complete waste of your time and might be a good reason to have yourself checked into the loony bin for observation. Consider checking with your head doctor for a different prescription. If you do go forward with this ludicrous plan be sure to hide all sharp objects, firearms and power tools. Put any pets into a kennel and ship any sigoth off to a spa. Meanwhile hit the liquor store and go hard core -beer aint gonna cut it-. Been there, Consider the economics and medical issues involved here!!! Smile, yer about to become the Ouroboros.... RCI in progress, call 911 MEDIC!!! http://en.wikipedia.org/wiki/Ouroboros RCI: http://tinyurl.com/ya4ymu DONE MY GOOD DEED FOR THE DAY (doesn't involve little old ladies or boy scouts!!!) LMAO, Neila http://roflmao.com/
> Hello all, > [quoted text clipped - 9 lines] > > Thank you, Frank Adam - 28 Dec 2006 23:23 GMT >Hmmmmmmm Jan, > Upon entering the 9th circle of hell (VB1 on Win3.1) , dusting off >numerous neurons, and wasting 100's of fruitless hours, you will slap <snip>
Damn these newbie top posters. ;-p
One of my brother in-laws still runs 3.11 at home. Do note, it's not 3.1. 3.11 was *the* stable 16 bit Windows. ;-)
 Signature Regards, Frank
Neila - 28 Dec 2006 23:56 GMT Damn Frank, Most of the aboriginis are running at least Win98SE2. And you let that backwards boy marry your sister?? Shame Shame, not ever gonna letcha watch my back!
>*the* stable 16 bit Windows. ;-) Tell that to the teksport peeps after the AA meetings! I did tekSport for one of the first apps to run under Win3.11 Our installation literally updated the OS from Win 3.0 to 3.11 (usually ;-) Those were the fun times (NOT!!! turnover was high, morale was low, developers were scared and the users were dumber than adobe bricks -too much time in the sun and alot of them acted like they were baked-).
Most of the job was convincing the novice users (all of them) that it was a problem with the POS "OS" by M$ and not my app. A good part was getting them to switch over to OS/2 (IBM marketing sure screwed up!!!). I recall one time a user (smart user) had a new 2G drive and the install program ran out of disk space (long integer wrapped and went negative). Are we having fun yet??? Neila
> >Hmmmmmmm Jan, > > Upon entering the 9th circle of hell (VB1 on Win3.1) , dusting off [quoted text clipped - 5 lines] > One of my brother in-laws still runs 3.11 at home. > Do note, it's not 3.1. 3.11 was *the* stable 16 bit Windows. ;-) Frank Adam - 29 Dec 2006 01:26 GMT >Damn Frank, > Most of the aboriginis are running at least Win98SE2. >And you let that backwards boy marry your sister?? >Shame Shame, not ever gonna letcha watch my back! If he married my sister, then he is in for a shock which will make BSODs look like a mere inconvenience.. I've only got a brother. :)
Nah, i've married his sister. Btw, he is a programmer and not a bad one either. Then again, his favorite game is Pacman, so chalk that up to the minuses.. Just shows that love is truly blind and i should have checked his PC before saying "umm, huh ? Yeah whatever" at the altar.. ;-)
<snip>
>a problem with the POS "OS" by M$ and not my app. A good part was >getting them to switch over to OS/2 (IBM marketing sure screwed up!!!). >I recall one time a user (smart user) had a new 2G drive and >the install program ran out of disk space (long integer wrapped and >went negative). >Are we having fun yet??? Always. Nothing like retelling these soothing and reassuring stories about the vast array of rock solid systems from MS, which made us all tough and hardened. Especially around times like this, what with Vista glooming on the horizon.. :)
 Signature Regards, Frank
Neila - 29 Dec 2006 23:49 GMT > >Damn Frank, > > Most of the aboriginis are running at least Win98SE2. [quoted text clipped - 9 lines] > Just shows that love is truly blind and i should have checked his PC > before saying "umm, huh ? Yeah whatever" at the altar.. ;-) As they say in some circles: [Insert favorite higher power] grant me the serenity to accept the things I cannot change; courage to change the things I can; and wisdom to know the difference... .... and may I always keep my paddle handy and my attitude maladjusted. Attitude problem??? Don't make it your problem etc....
> <snip> > >a problem with the POS "OS" by M$ and not my app. A good part was [quoted text clipped - 8 lines] > tough and hardened. Especially around times like this, what with Vista > glooming on the horizon.. :) More stories: CONTEXT was my checking MAC Freeware Word processing apps and some teksport cat was pleading with users to clearly define the problem....(well, need to be able to think clear thoughts first) My reply which did not go thru for some silly reason (I wasn't a registered luser). --- Count yourself lucky Sam., .... the cup holder/foot pedal are acting up again. I used to do tekSport back in the early to mid 90's (before Windows was "stabile") When MacIntosh was MacInToy, when DOS wasn't a TLA, OS/2 ruled the desktop, Linux wasn't, Real programmers used Mainframes but kept on tripping over their balls. Unix didn't refer to the support staff in a harem at Burning Man. Yeah, yer all freaking lucky!!!! OH,BTW, we didn't have internet access either (well, we did)... (or at least none of the users did except gvmentals and militards). Burned through lots of FAX paper and had to re-key alot of crap (er is that an O or a 0, an I,1 or l ... Yeah, life sucked back in the preneandrethal era of computer hardware/software development. Now what if the marketing peeps at IBM hadn't been RCI'ing back then? M$ and uncle Bill would be sucking hind teet!!!! Damn I hate Macs, but WinDoze sux too oh... what to do? Neila
Geo - 29 Dec 2006 15:38 GMT >I need to make a copy of a file called "blank.txt" and then rename the >copy. Renaming is not a problem, but I just can't figure out how to >make a copy of a file in VB1, there doesn't seem to be a filecopy >command. I assume there is such a command in later versions, but VB1 >and VB6 is all I have. Any ways around this? How about shelling and letting the OS do the work? Something like:- a$="copy blank.txt blank2.txt" lRet& = Shell(a$)
Geo
|
|
|