| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Bad habits & file moving |
While listening to John Gardeniers Pete heard:Bad habits & file moving
G'day John
JG> #define NULL 0
PC> Shouldn't NULL be defined for you in a header file somewhere.?
PC> I'm not sure what compiler your using so maybe not.
JG> I use PCC and to keep the speed up, as much as practical (I use
JG> an XT to do my programming), I avoid header files. PCC is quite
JG> different to other compilers in as much as prototyping is rarely
JG> needed and almost everything that's a standard macro on another
JG> compiler is a function with PCC.
Why not look around for a 2nd hand copy of Quick C 2.5, it runs on an
XT and would be a step up from PCC
JG> #define TRUE 0
JG> #define FALSE !TRUE
~~~ ^^^^^^^^^^^^^^^^^^
PC> I think defining FALSE to a non-zero value would be a bad habit
PC> to get into, it would be better to always assume FALSE to be
PC> zero.
JG> One thing in favour of having TRUE=0 is that on a no error
JG> completion of a function you can simply "fall through" at the
JG> end, i.e. no explicit RETURN. I personally like using non-zero
JG> far FALSE as it allows me to test for FALSE and then act
JG> acording to what value was actually returned, much like DOS
JG> error levels.
Your relying on your compiler to clear AX for you on returning from a
function, you must also have the warnings threshhold set low as my
compiler (QC) generates a warning if i forget to add a 'return n;' in
functions that return a value.
JG> From your other reply:
JG> Next project: How to do a move without a copy if the destination
JG> is the same drive as the source. That would save quite a bit of
JG> time with large files. Any thoughts?
PC> Quite simple use the rename() function, see info below.
JG> This was actually the very first thing I tried. Both DOS
JG> (command line) and PCC failed to move the file, so I started
JG> searching for another way. On reading your reply I tried again
JG> with the same results. I then tried going straight to DOS,
JG> using assembler and AH=56H INT 21H...Bingo!
Your right it would be quite easy.
int renamefile(char _far * oldfile, char _far * newfile) {
int retval = 0;
_asm {
lds dx, oldfile
les di, newfile
mov ah, 56h
int 21h
jnc a
mov retval, ax
a:
}
return retval;
}
JG> I hope you feel good about me throwing away a couple of days of
JG> work, tracing directory entries, FATs, etc. . At least my
JG> code can now shrink by about 4 or 5 Kb and I now know a lot more
JG> about how everything on a disk is organised.
Hehe it's what i do best, I Better go buy some more spanners :-)
JG> Thank for you comments, as well as getting me back on the right
JG> track with the file move.
no problem.
-=Pete=-
--- OMX/Blue Wave v2.12
* Origin: Gates of Hell (3:713/914.16)SEEN-BY: 50/99 78/0 620/243 623/630 711/401 409 410 413 430 808 809 932 934 SEEN-BY: 712/508 515 713/111 317 601 611 615 618 700 826 888 914 714/906 SEEN-BY: 800/1 7877/2809 @PATH: 713/914 615 888 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
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™.