473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

change index between 0 and 1

Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?

Feb 15 '06 #1
30 2029
"Eric Lilja" <mi********@gmail.com> writes:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


The obvious way to do this would be to pass the index as a parameter,
but I presume you to do this independently of the caller.

Here's one approach:

void func(whatever)
{
static int index = 0;
static element_type arr[2];
/* ... code referring to arr[index] ... */
index = 1 - index;
}

For sizes other than 2, something like this:

index = (index + 1) % ARRAY_SIZE;

is more general.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 15 '06 #2
Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?

static unsigned index = 1;

return array[index^=1];

--
Ian Collins.
Feb 15 '06 #3
Eric Lilja wrote:

Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


/* BEGIN new.c */

#include <stdio.h>

void sequence(size_t first, size_t second);

int main(void)
{
unsigned flip;
size_t index;

puts("/* BEGIN new.c output */\n");
for (index = 0; index != 5; ++index) {
sequence(flip++ & 1, index);
sequence(flip++ & 1, index);
}
puts("\n\n/* END new.c output */");
return 0;
}

void sequence(size_t first, size_t second)
{
int array[][5] = {0,2,4,6,8,1,3,5,7,9};

putchar('0' + array[first][second]);
}

/* END new.c */

--
pete
Feb 15 '06 #4
pete wrote:
unsigned flip;


unsigned flip = 0;

That should have been initialized.

--
pete
Feb 15 '06 #5
On 14 Feb 2006 17:20:25 -0800, "Eric Lilja" <mi********@gmail.com>
wrote in comp.lang.c:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


static int index = 1; /* you'll see in a minute */

int values [2] = { first_value, second_value };

int get_value(void)
{
index = !index;
return values [index];
}

Initializing to 1 and performing the logical negation before use
ensures two things. First, you get the 0 element of the array the
first time, and second that the value you use for the subscript is
always 0 or 1, never out of range.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Feb 15 '06 #6
Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


void function(void)
{
static int index;
index = 1 - index;
}

Feb 15 '06 #7
Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?

how about:

index = (++index % 2); // works for powers of 2
return array[index];
Feb 15 '06 #8
Neil <Ne*******@worldnet.att.net> writes:
index = (++index % 2); // works for powers of 2


If "works" means "invokes undefined behavior", then you're
correct ;-)

Your suggestion is undefined because it modifies the value of
`index' twice between sequence points.

Here is a working suggestion in the same pattern as yours:
index = (index + 1) % 2;
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Feb 15 '06 #9

Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


Thanks for the replies, everyone, I actually had a ++index %
2-statement
(index was initialized to 0), but I had forgot to make it static so I
always ended up using the element with index 0, heh. Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.

Feb 15 '06 #10
Banfa
9,065 Expert Mod 8TB
Eric Lilja wrote:[color=blue]
Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.
It's because you have 1 * too many in

Expand|Select|Wrap|Line Numbers
  1. typedef void (* fptr)();
  2. fptr * array[] = {idle_callback, NULL};
  3.  
The type fptr is a defined as a pointer to a function and array is declared are an array of pointers to type fptr. Therefore the type of a single element of array is pointer to pointer to function.

Try declaring array as

Expand|Select|Wrap|Line Numbers
  1. fptr array[] = {idle_callback, NULL};
  2.  
Feb 15 '06 #11
Eric Lilja wrote:
Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


Thanks for the replies, everyone, I actually had a ++index %
2-statement
(index was initialized to 0), but I had forgot to make it static so I
always ended up using the element with index 0, heh. Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.


The warning description is quite explicit. You are initializing a
function pointer array element with a pointer of a different type. Look
at the declarations. fptr is declared as:

typedef void (* fptr) ();

This a pointer to a function returning void and with unspecified
parameters.

In the warning message says that idle_callback is declared as:

static void idle_callback (void);

This is a pointer to a function returning void and with no parameters.
Those types are not the same. The easiest way to remove those warnings
is to redeclare fptr as:

typedef void (* fptr) (void);

Feb 15 '06 #12

Antonio Contreras wrote:
Eric Lilja wrote:
Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


Thanks for the replies, everyone, I actually had a ++index %
2-statement
(index was initialized to 0), but I had forgot to make it static so I
always ended up using the element with index 0, heh. Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.


The warning description is quite explicit. You are initializing a
function pointer array element with a pointer of a different type. Look
at the declarations. fptr is declared as:

typedef void (* fptr) ();

This a pointer to a function returning void and with unspecified
parameters.

In the warning message says that idle_callback is declared as:

static void idle_callback (void);

This is a pointer to a function returning void and with no parameters.
Those types are not the same. The easiest way to remove those warnings
is to redeclare fptr as:

typedef void (* fptr) (void);


No, that wasn't it. That yields the same warnings. The error turned out
to be:
fptr * array[] = {idle_callback, NULL};
this should be
fptr array[] = {idle_callback, NULL};

Feb 15 '06 #13
"Eric Lilja" <mi********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


Thanks for the replies, everyone, I actually had a ++index %
2-statement
(index was initialized to 0), but I had forgot to make it static so I
always ended up using the element with index 0, heh. Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.


Try this change:
fptr array[]={idle_callback,NULL};
Feb 15 '06 #14
Eric Lilja wrote:
Antonio Contreras wrote:
Eric Lilja wrote:
Eric Lilja wrote:
> Hello, I have a function that has a static array with two elements in
> it. When the function is called the first time, it should access
> element 0, the second time it should access element 1, the third time
> element 0, the fourth element 1 etc. I can do it by having a static
> variable holding the index and and if/else-statement but is there a
> more clever way that doesn't need the if/else?

Thanks for the replies, everyone, I actually had a ++index %
2-statement
(index was initialized to 0), but I had forgot to make it static so I
always ended up using the element with index 0, heh. Now to a question
to a related problem, why am I getting the following warnings and how
do I fix
them?

typedef void (* fptr)();
fptr * array[] = {idle_callback, NULL}; /* This is the actual
two-element array. */
Warning for line above:
simple_1-5.c:24: warning: initialization from incompatible pointer type
idle_callback is declared as: static void idle_callback(void);

glutIdleFunc(array[++index % 2]);
Warning for line above:
simple_1-5.c:32: warning: passing arg 1 of `glutIdleFunc' from
incompatible pointer type

They seem harmless because my program works as expected on my system at
least, but I'd like to fix them anyway.


The warning description is quite explicit. You are initializing a
function pointer array element with a pointer of a different type. Look
at the declarations. fptr is declared as:

typedef void (* fptr) ();

This a pointer to a function returning void and with unspecified
parameters.

In the warning message says that idle_callback is declared as:

static void idle_callback (void);

This is a pointer to a function returning void and with no parameters.
Those types are not the same. The easiest way to remove those warnings
is to redeclare fptr as:

typedef void (* fptr) (void);


No, that wasn't it. That yields the same warnings. The error turned out
to be:
fptr * array[] = {idle_callback, NULL};
this should be
fptr array[] = {idle_callback, NULL};


Yup, missed that little asterisk. However, it is always a good idea
beeing explicit about the parameters when you declare function
pointers. That way the compiler can check argument types.

Feb 15 '06 #15
>> > > Eric Lilja wrote:
> > > Hello, I have a function that has a static array with two elements in
> > > it. When the function is called the first time, it should access
> > > element 0, the second time it should access element 1, the third time
> > > element 0, the fourth element 1 etc. I can do it by having a static
> > > variable holding the index and and if/else-statement but is there a
> > > more clever way that doesn't need the if/else?
> >
> > Thanks for the replies, everyone, I actually had a ++index %
> > 2-statement

Sorry, I can no longer find earlier articles in this thread, but what
about the traditional:

static int index = 0;
......
index = 1 - index;

--
Chris.
Feb 15 '06 #16

Eric Lilja wrote:
Hello, I have a function that has a static array with two elements in
it. When the function is called the first time, it should access
element 0, the second time it should access element 1, the third time
element 0, the fourth element 1 etc. I can do it by having a static
variable holding the index and and if/else-statement but is there a
more clever way that doesn't need the if/else?


int alternate(void)
{
static int v[] = {411,219};
static _Bool vi;

return v[vi--];
}

Feb 15 '06 #17
Chris McDonald wrote:
Sorry, I can no longer find earlier articles in this thread, but what
about the traditional:

static int index = 0;
......
index = 1 - index;


When I suggested this in
<dr*****************@newsread1.news.atl.earthlink. net> (11 hours before
yours) it was completely ignored, in favor of discussion of the sloppy
and obfuscated mechanism you responded to.
Feb 15 '06 #18
Ben Pfaff wrote:
Neil <Ne*******@worldnet.att.net> writes:
index = (++index % 2); // works for powers of 2


If "works" means "invokes undefined behavior", then you're
correct ;-)

Your suggestion is undefined because it modifies the value of
`index' twice between sequence points.

Here is a working suggestion in the same pattern as yours:
index = (index + 1) % 2;

Thanks
Sorry about the poor execution.
Feb 16 '06 #19
Neil wrote:
Ben Pfaff wrote:
Neil <Ne*******@worldnet.att.net> writes:
index = (++index % 2); // works for powers of 2

If "works" means "invokes undefined behavior", then you're
correct ;-)

Your suggestion is undefined because it modifies the value of
`index' twice between sequence points.

Here is a working suggestion in the same pattern as yours:
index = (index + 1) % 2;


Thanks
Sorry about the poor execution.


Too complicated. Assume a function to return alternatively 0, 1 then 0
etc. It might look like ..

int inc(void) {
static int i;
return i = i++ & 1;
}

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Feb 16 '06 #20
Joe Wright wrote:

Neil wrote:
Ben Pfaff wrote:
Neil <Ne*******@worldnet.att.net> writes:

index = (++index % 2); // works for powers of 2
If "works" means "invokes undefined behavior", then you're
correct ;-)

Your suggestion is undefined because it modifies the value of
`index' twice between sequence points.

Here is a working suggestion in the same pattern as yours:
index = (index + 1) % 2;


Thanks
Sorry about the poor execution.


Too complicated. Assume a function to return alternatively 0, 1 then 0
etc. It might look like ..

int inc(void) {
static int i;
return i = i++ & 1;
}


That return statement has undefined behavior.

unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}

--
pete
Feb 16 '06 #21
pete wrote:
Joe Wright wrote:
Neil wrote:
Ben Pfaff wrote:
Neil <Ne*******@worldnet.att.net> writes:
>index = (++index % 2); // works for powers of 2
If "works" means "invokes undefined behavior", then you're
correct ;-)

Your suggestion is undefined because it modifies the value of
`index' twice between sequence points.

Here is a working suggestion in the same pattern as yours:
index = (index + 1) % 2;

Thanks
Sorry about the poor execution.


Too complicated. Assume a function to return alternatively 0, 1 then 0
etc. It might look like ..

int inc(void) {
static int i;
return i = i++ & 1;
}

That return statement has undefined behavior.

unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}

Bless you my son. The assignment was questionable perhaps. But why
unsigned instead of int? The variable i is initialized to 0 by the
compiler and has no chance of exceeding 2. Signedness is not an issue
here. What's the problem?

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Feb 16 '06 #22
Joe Wright <jo********@comcast.net> writes:
unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}

Bless you my son. The assignment was questionable perhaps. But why
unsigned instead of int? The variable i is initialized to 0 by the
compiler and has no chance of exceeding 2. Signedness is not an issue
here. What's the problem?

But why, oh why, are people proposing these fancy
power-of-2-based-modulo-or-masking-solutions over the oft offered:

i = 1 - i;
?

--
Chris.
Feb 16 '06 #23
Chris McDonald wrote:
Joe Wright <jo********@comcast.net> writes:
unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}
Bless you my son. The assignment was questionable perhaps. But why
unsigned instead of int? The variable i is initialized to 0 by the
compiler and has no chance of exceeding 2. Signedness is not an issue
here. What's the problem?


int will cause undefined behaviour when it overflows, unsigned won't.
But why, oh why, are people proposing these fancy
power-of-2-based-modulo-or-masking-solutions over the oft offered:

i = 1 - i;
?


Because beauty is in the eye of the beholder and there may be people
who happen to like other solutions better.

The modulus solution below has the clear advantage of being scalable to
larger array sizes.

#define ARRAY_SIZE 2

int index (void) {
static int i = 0;
return i = (i + 1) % ARRAY_SIZE;
}

If I were absolutely sure that I'll never need a larger array I'd go
with another offered solution:

int index (void) {
static int i = 1;
return i = !i;
}

which in turn has the advantage that if i somehow (wild pointers,
buffer overflow...) gets a value different than 0 or 1, it will return
to sequence in the next call (the damage may have been done by now, but
that's another matter).

Feb 16 '06 #24
Joe Wright wrote:
pete wrote:
Joe Wright wrote:
Ben Pfaff wrote:
>Neil wrote:
>>
>>index = (++index % 2); // works for powers of 2
>
>Your suggestion is undefined because it modifies the value of
>`index' twice between sequence points.

int inc(void) {
static int i;
return i = i++ & 1;
}


That return statement has undefined behavior.

Bless you my son. The assignment was questionable perhaps.
What's the problem?


Your suggestion is undefined because it modifies the value of
`i' twice between sequence points.

Feb 16 '06 #25
"Antonio Contreras" <an*****@gmail.com> writes:
If I were absolutely sure that I'll never need a larger array I'd go
with another offered solution: int index (void) {
static int i = 1;
return i = !i;
} which in turn has the advantage that if i somehow (wild pointers,
buffer overflow...) gets a value different than 0 or 1, it will return
to sequence in the next call (the damage may have been done by now, but
that's another matter).


Even better, and meets the OP's requirements; thanks!

--
Chris.
Feb 16 '06 #26
Joe Wright <jo********@comcast.net> writes:
pete wrote:
Joe Wright wrote: [...]
Too complicated. Assume a function to return alternatively 0, 1 then 0
etc. It might look like ..

int inc(void) {
static int i;
return i = i++ & 1;
}

That return statement has undefined behavior.

unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}

Bless you my son. The assignment was questionable perhaps. But why
unsigned instead of int? The variable i is initialized to 0 by the
compiler and has no chance of exceeding 2. Signedness is not an issue
here. What's the problem?


In pete's solution, i is incremented every time the function is
called. The value returned by the function will always be either 0 or
1, but the value of i will increase without bound. There could be two
reasons to make it unsigned: bitwise operations on signed types are
generally to be avoided, and unsigned int has defined behavior on
overflow.

But allowing i to increase without bound is a kludge. It's much
simpler to keep i itself in the range 0..1. Something like
i = 1 - i;
return i;
is longer but *much* simpler.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 16 '06 #27
Joe Wright wrote:

pete wrote:
Joe Wright wrote:
Neil wrote:

Ben Pfaff wrote:
>Neil <Ne*******@worldnet.att.net> writes:
>
>
>>index = (++index % 2); // works for powers of 2
>
>
>If "works" means "invokes undefined behavior", then you're
>correct ;-)
>
>Your suggestion is undefined because it modifies the value of
>`index' twice between sequence points.
>
>Here is a working suggestion in the same pattern as yours:
> index = (index + 1) % 2;

Thanks
Sorry about the poor execution.

Too complicated. Assume a function to return alternatively 0, 1 then 0
etc. It might look like ..

int inc(void) {
static int i;
return i = i++ & 1;
}

That return statement has undefined behavior.

unsigned inc(void)
{
static unsigned i;

return i++ & 1;
}

Bless you my son. The assignment was questionable perhaps. But why
unsigned instead of int?


I'm letting the i variable roll over at UINT_MAX.
The variable i is initialized to 0 by the
compiler and has no chance of exceeding 2. Signedness is not an issue
here. What's the problem?


Like "Old Wolf" said:
"modifies the value of `i' twice between sequence points"

i = i++; /* No good */

Assignment is not a sequence point.

--
pete
Feb 16 '06 #28
Chris McDonald wrote:

But why, oh why, are people proposing these fancy
power-of-2-based-modulo-or-masking-solutions over the oft offered:

i = 1 - i;
?

Or even i^=1, which should be very efficient.

--
Ian Collins.
Feb 17 '06 #29
Ian Collins <ia******@hotmail.com> writes:
Chris McDonald wrote:
But why, oh why, are people proposing these fancy
power-of-2-based-modulo-or-masking-solutions over the oft offered:
i = 1 - i;
?

Or even i^=1, which should be very efficient.


Any improvement in efficiency is unlikely to be worth the loss of
clarity. Remember the Rules of Optimization.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 17 '06 #30
Keith Thompson wrote:
Ian Collins <ia******@hotmail.com> writes:
Chris McDonald wrote:
But why, oh why, are people proposing these fancy
power-of-2-based-modulo-or-masking-solutions over the oft offered:
i = 1 - i;
?


Or even i^=1, which should be very efficient.

Any improvement in efficiency is unlikely to be worth the loss of
clarity. Remember the Rules of Optimization.

Clarity is in the eye of the beholder!

--
Ian Collins.
Feb 17 '06 #31

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tee | last post by:
Hi, Does anyone know how to change an index of an object? This is what I want to do. eg: I have 5 controls in a panel. index from 0 to 4, after I remove the 3rd control (index 2), I want to...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
2
by: Ben | last post by:
Hi. I have a button that change a number of images src's when I click a button. The src's are stored in an array and I just use document.src=pics to change the src of the image. However I want...
0
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
4
by: mark | last post by:
is it possible to change an elements Z-INDEX value on an onclick event in codebehind ? id like to change the posistion of a datagrid once a button has been pressed cheers mark
3
by: wg | last post by:
I have written a class to contain tags that are loaded from a spreadsheet. I can load the value ok. But from another class I would like to change a value inside the arraylist. Here is my code (see...
27
by: Jon Slaughter | last post by:
Can I modify code that I have included using <?php include("../Index.php"); ?> The Index.php file contains links that need to be modified to work. Index.php is basically an html file uses a...
1
by: thesti | last post by:
hi, i'm going to develop a program using VB .NET. i've bound some textboxes to the same DataSource (DataSet1.Tables(0). and i enable the user to type the primaryKey of the data in the Table,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.