Hi !

It's my first post and I have a question :

If i have a condition in a program (for exemple a booleean : 1 if it's "yes") on A :

for exemple if A>10 ,i =1 and else i=0.

Can I do ? :

38 0

39 STO "i"

40 RCL "Achar"

41 10

42 X<Y?

43 XEQ B

after i use my condtion...(for exemple in a formula)

and then at the end of program:

92 LBL B

93 1

94 STO "i"

Because it doesn't work for each condition I have (I have 4 condition like this in a formula).

Could you help me ?

You understood I'm a beginner in the use of this language

Thank you ,

Alexandre,

## A problem of Conditions

### Re: A problem of Conditions

Kind of ludicrous question...

Tell us more as we can’t see what’s your problem...

Tell us more as we can’t see what’s your problem...

HP33E, HP34C, HP41C, HP16C, HP28S, HP42S, HP48S, HP12C, HP35S, DM42, DM41L, DM15L, DM41X (SN#15) and HP3000 @ work during 18 yrs as IT Mgr

### Re: A problem of Conditions

Hi there,

The comparison function X<Y? and family do not compare variables, they compare values in the stack.

So, once you have run this bit:

you have the value of "i" (zero) in X.

When you now do this:

that zero gets pushed up to Y in the stack and X now contains the value of the variable "Achar".

This pushes your zero up to Z, the value of "Achar" up to Y and inserts the value 10 into X.

"If X<Y then XEQ B"

Execution as of LBL B is started but only if 10 < "Achar".

Assuming the condition was met, you move here:

This pushes your original zero up to T, "Achar" up to Z, 10 up to Y and 1 into X.

This stores 1 into "i" but leaves all the other stuff in the stack.

That explains what the functions actually do, but it doesn't solve your problem. Your problem is impossible to solve because "doesn't work" is not an accurate enough description of the problem to be able to help. What is actually happening that shouldn't be happening? What is not happening that should be happening? Have you tried any debugging by stepping through your program with SST?

The comparison function X<Y? and family do not compare variables, they compare values in the stack.

So, once you have run this bit:

Code: Select all

```
38 0
39 STO "i"
```

When you now do this:

Code: Select all

`40 RCL "Achar"`

Code: Select all

`41 10`

Code: Select all

```
42 X<Y?
43 XEQ B
```

Execution as of LBL B is started but only if 10 < "Achar".

Assuming the condition was met, you move here:

Code: Select all

```
92 LBL B
93 1
```

Code: Select all

`94 STO "i"`

That explains what the functions actually do, but it doesn't solve your problem. Your problem is impossible to solve because "doesn't work" is not an accurate enough description of the problem to be able to help. What is actually happening that shouldn't be happening? What is not happening that should be happening? Have you tried any debugging by stepping through your program with SST?

Not SwissMicros staff, just an enthusiast.

### Re: A problem of Conditions

For boolean I would suggest using a flag instead of a variable :Lestevenie wrote: ↑Sun Apr 14, 2019 6:43 amIf i have a condition in a program (for exemple a booleean : 1 if it's "yes") on A :

for exemple if A>10 ,i =1 and else i=0.

Code: Select all

```
38 CF 00 /* clear flag 00
39 RCL "Achar"
40 10
41 X<Y?
42 SF 00 /* set flag 00
```

DM42 SN: 00425