Board index » cppbuilder » 2 quick questions

2 quick questions


2003-12-20 01:54:41 PM
cppbuilder85
Hi guys!
I am using BCB 6 and am a C newbie.
1. When I use the tab key to indent, it first indents by a single space,
and then I have to press the tab key again to get it to indent properly
ie. by another 4 spaces or so.
How do I set it so that I only need to press the tab key once to indent?
This is a pain in the {*word*82}when there is alot of indenting to do!
2. I can run a program using the sleep() function, however when the
program compiles, it gives:
'sleep' is obselete. (sleep() is non-Ansi by the way).
What function does BCB 6 have to implement a delay of x seconds?
It's simple for me to write my own function to do this, but I'd rather
use built-in functions.
I've tried looking up:
clock(), delay(), gettimeofday(), msleep(),
nap(), napms(), nanosleep(), setitimer(), sleep(), times(), and
usleep()
as advised by the faq for comp.lang.c, but these do not achieve a delay.
Thanks in advance!
Buck.
--
Using M2, Opera's revolutionary e-mail client: www.opera.com/m2/
 
 

Re:2 quick questions

On Sat, 20 Dec 2003 16:54:41 +1100, Buck Rogers < XXXX@XXXXX.COM >wrote:
Quote
Hi guys!

I am using BCB 6 and am a C newbie.

1. When I use the tab key to indent, it first indents by a single space,
and then I have to press the tab key again to get it to indent
properly
ie. by another 4 spaces or so.

How do I set it so that I only need to press the tab key once to
indent?
This is a pain in the {*word*82}when there is alot of indenting to do!

Oh, I forgot to metion that the third time I press tab, it idents by
about 8 spaces, and then if I press tab again, it indents by 4, and
then 1, and then 4 and then 8.
This is unworkable with nested statements/blocks.
I am spending more struggling with the tab key than with programming!
--
Using M2, Opera's revolutionary e-mail client: www.opera.com/m2/
 

Re:2 quick questions

"Buck Rogers" < XXXX@XXXXX.COM >wrote in message
Quote
How do I set it so that I only need to press the tab key once to
indent?
Right-click on the code editor, go into the Properties, and check the Block
Indent and Tab Stop fields under the General settings.
Quote
What function does BCB 6 have to implement a delay of x seconds?
Use Sleep() (uppercase 'S') rather than sleep() (lowercase 's').
Gambit
 

{smallsort}

Re:2 quick questions

In reply to the delay function, I'd use this :-
#include <time.h>
void waitawhile(int secs,bool lockapp)
{
clock_t sta=clock();
while ((clock()-sta)/CLK_TCK<nsecs) if (!lockapp)
Application->ProcessMessages();
}
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
XXXX@XXXXX.COM
"Buck Rogers" < XXXX@XXXXX.COM >wrote in message
Quote
Hi guys!

I am using BCB 6 and am a C newbie.

1. When I use the tab key to indent, it first indents by a single space,
and then I have to press the tab key again to get it to indent
properly
ie. by another 4 spaces or so.

How do I set it so that I only need to press the tab key once to
indent?
This is a pain in the {*word*82}when there is alot of indenting to do!

2. I can run a program using the sleep() function, however when the
program compiles, it gives:

'sleep' is obselete. (sleep() is non-Ansi by the way).

What function does BCB 6 have to implement a delay of x seconds?
It's simple for me to write my own function to do this, but I'd
rather
use built-in functions.

I've tried looking up:

clock(), delay(), gettimeofday(), msleep(),
nap(), napms(), nanosleep(), setitimer(), sleep(), times(), and
usleep()

as advised by the faq for comp.lang.c, but these do not achieve a delay.

Thanks in advance!

Buck.

--
Using M2, Opera's revolutionary e-mail client: www.opera.com/m2/
 

Re:2 quick questions

Mark Jacobs wrote:
Quote
In reply to the delay function, I'd use this :-

#include <time.h>

void waitawhile(int secs,bool lockapp)
{
clock_t sta=clock();

while ((clock()-sta)/CLK_TCK<nsecs) if (!lockapp)
Application->ProcessMessages();

}
This is not a good idea as it is a busy wait which means it uses 100 %
CPU time which might prevent background tasks from running and also
causes the CPU to use more energy (very inconvenient on notebooks
running from battery).
Use Sleep as Remy allready said, that way your application behaves much
more multitasking and notebook friendly.
Eelke