Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #13700 > unrolled thread
| Started by | ahso <ahso47@yahoo.com> |
|---|---|
| First post | 2012-02-02 02:13 -0800 |
| Last post | 2012-02-03 00:54 -0800 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.c++
if ahso <ahso47@yahoo.com> - 2012-02-02 02:13 -0800
Re: if Ian Collins <ian-news@hotmail.com> - 2012-02-02 23:27 +1300
Re: if "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2012-02-02 11:40 +0100
Re: if ahso <ahso47@yahoo.com> - 2012-02-02 04:06 -0800
Re: if "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2012-02-02 14:50 +0100
Re: if copx <copx@gazeta.pl> - 2012-02-02 17:27 +0100
Re: if Juha Nieminen <nospam@thanks.invalid> - 2012-02-02 17:22 +0000
Re: if LR <lruss@superlink.net> - 2012-02-02 18:05 -0500
Re: if ahso <ahso47@yahoo.com> - 2012-02-03 00:54 -0800
| From | ahso <ahso47@yahoo.com> |
|---|---|
| Date | 2012-02-02 02:13 -0800 |
| Subject | if |
| Message-ID | <bfd99fe9-fc86-4563-a650-1639bcecda88@l14g2000vbe.googlegroups.com> |
Hi
I only want either first or second if but not both executed. ie. if
value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not
execute first if.
Thanks
if (R22value == 1){
DreiDimensional = 0;
function();
}
if (R23value == 1){
DreiDimensional = 1;
function();
}
[toc] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2012-02-02 23:27 +1300 |
| Message-ID | <9ov6olF4enU1@mid.individual.net> |
| In reply to | #13700 |
On 02/ 2/12 11:13 PM, ahso wrote: > Hi > I only want either first or second if but not both executed. ie. if > value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not > execute first if. That requirement contradicts its self. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> |
|---|---|
| Date | 2012-02-02 11:40 +0100 |
| Message-ID | <jgdp7m$vt3$1@news.albasani.net> |
| In reply to | #13700 |
"ahso" wrote in message
news:bfd99fe9-fc86-4563-a650-1639bcecda88@l14g2000vbe.googlegroups.com...
>
>Hi
>I only want either first or second if but not both executed. ie. if
>value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not
>execute first if.
>Thanks
>
>
>if (R22value == 1){
> DreiDimensional = 0;
> function();
>}
>
>if (R23value == 1){
> DreiDimensional = 1;
> function();
>}
It is not clear to me what you mean. As I read it, the obvious solution is:
if (R22value == 1){
DreiDimensional = 0;
function();
} else if (R23value == 1){
DreiDimensional = 1;
function();
}
[toc] | [prev] | [next] | [standalone]
| From | ahso <ahso47@yahoo.com> |
|---|---|
| Date | 2012-02-02 04:06 -0800 |
| Message-ID | <8df39f53-f39a-4620-a0d7-c9ff19daf6e4@v14g2000vbc.googlegroups.com> |
| In reply to | #13702 |
The problem is that either value can be 1. I only want to avoid running both simultanoulsy. I tried with setting within each if the other value to 0 but that's not working. I probably need to do as Fred so users have to click the first value to disable then click the second.
[toc] | [prev] | [next] | [standalone]
| From | "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> |
|---|---|
| Date | 2012-02-02 14:50 +0100 |
| Message-ID | <jge4bv$lgq$1@news.albasani.net> |
| In reply to | #13704 |
"ahso" wrote in message
news:8df39f53-f39a-4620-a0d7-c9ff19daf6e4@v14g2000vbc.googlegroups.com...
>
>The problem is that either value can be 1. I only want to avoid
>running both simultanoulsy. I tried with setting within each if the
>other value to 0 but
>that's not working. I probably need to do as Fred so users have to
>click the first value to disable then click the second.
What are types of R22value, R23value and DrieDimensional?
You use them as integer-like variables, what are their expected values?
You seem to use only the values 0 and 1, maybe you should use bool type.
It is still not clear to me what you want to do.
Maybe you could explicitly program the four cases,
which would make your intention more clear.
What do you want to do in the other two cases?
if (R22value == 1 ){
if (R23value == 1){
// R22value == 1, R23value == 1
throw Inconsistency;????
ComplainToUser ();?????
} else {
// R22value == 1, R23value != 1
DreiDimensional = 0;
function();
}
} else {
if (R23value == 1){
// R22value != 1, R23value == 1
DreiDimensional = 1;
function();
} else {
// R22value != 1, R23value != 1
throw Inconsistency;???????
ComplainToUser ();?????
}
}
[toc] | [prev] | [next] | [standalone]
| From | copx <copx@gazeta.pl> |
|---|---|
| Date | 2012-02-02 17:27 +0100 |
| Message-ID | <jgedhv$j58$1@speranza.aioe.org> |
| In reply to | #13700 |
On 02.02.2012 11:13, ahso wrote:
> Hi
> I only want either first or second if but not both executed. ie. if
> value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not
> execute first if.
> Thanks
>
>
> if (R22value == 1){
> DreiDimensional = 0;
> function();
> }
>
> if (R23value == 1){
> DreiDimensional = 1;
> function();
> }
English is not your first language, right? Seriously, your broken
English makes it hard to understand what you actually mean.
I guess you want this:
if (R23value != 1 && R22value == 1){
DreiDimensional = 0;
function();
}
if (R22value != 1 && R23value == 1){
DreiDimensional = 1;
function();
}
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2012-02-02 17:22 +0000 |
| Message-ID | <4f2ac669$0$3073$7b1e8fa0@news.nbl.fi> |
| In reply to | #13700 |
ahso <ahso47@yahoo.com> wrote:
> Hi
> I only want either first or second if but not both executed. ie. if
> value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not
> execute first if.
> Thanks
>
>
> if (R22value == 1){
> DreiDimensional = 0;
> function();
> }
>
> if (R23value == 1){
> DreiDimensional = 1;
> function();
> }
Just put an "else" before the second "if".
[toc] | [prev] | [next] | [standalone]
| From | LR <lruss@superlink.net> |
|---|---|
| Date | 2012-02-02 18:05 -0500 |
| Message-ID | <4f2b16c3$0$10052$cc2e38e6@news.uslec.net> |
| In reply to | #13700 |
ahso wrote:
> Hi
> I only want either first or second if but not both executed. ie. if
> value 1 do not execute 2 even if 2nd value ==1 but also if 2nd do not
> execute first if.
> Thanks
>
>
> if (R22value == 1){
> DreiDimensional = 0;
> function();
> }
>
> if (R23value == 1){
> DreiDimensional = 1;
> function();
> }
What you want to do isn't entirely clear to me, but perhaps this snippet
will be of use, if only as a point of departure,
void f2(const int R22value, const int R23value) {
std::cout << "(" << R22value << "," << R23value << ") ";
static const int threeDim = 1;
static const int twoDim = 0;
static const int invalidDim = -1;
const bool r2 = R22value != 0;
const bool r3 = R23value != 0;
const std::pair<bool,bool> ab(r2,r3);
const int dim =
ab == std::make_pair(false,true) ? threeDim :
ab == std::make_pair(true,false) ? twoDim :
invalidDim;
if(dim != invalidDim) {
// call function here
std::cout << "It\'s valid, it was " << dim << std::endl;
}
else {
// don't call function here
std::cout << "It was invalid" << std::endl;
}
}
[toc] | [prev] | [next] | [standalone]
| From | ahso <ahso47@yahoo.com> |
|---|---|
| Date | 2012-02-03 00:54 -0800 |
| Message-ID | <df9c5ed8-ee65-4276-8cd1-0d8366fb623f@n6g2000vbz.googlegroups.com> |
| In reply to | #13721 |
Thanks copx. I added after your code (only boolean 0/1 values):
if (R23value == 1 && R22value == 1){
R22value = 0;
R23value = 0;
}
That way users have to double click but ok.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web