Cobol not entering if, although condition is true - if-statement

I'm working on a Cobol application that is deployed on HP Nonstop. Debugging on the platform I came across the following situation:
IF LABELED-VALUE OF IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT THEN
MOVE IN-VARIABLE-2 OF PARENT-2 OF GRAND-PARENT TO OUT-VARIABLE
ELSE
MOVE IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT TO OUT-VARIABLE
END-IF
The fields are defined like this:
01 GRAND-PARENT
03 PARENT-1.
05 IN-VARIABLE-1 PIC 9(3).
88 LABELED-VALUE VALUE 000.
03 PARENT-2.
05 IN-VARIABLE-2 PIC 9(3).
01 OUT-VARIABLE PIC 9(3).
When I evaluate the expression LABELED-VALUE OF IN-VARIABLE-1 OF PARENT OF GRAND-PARENT my debugger tells me that the expression is TRUE. The value of IN-VARIABLE-1 OF PARENT OF GRAND-PARENT is 0. Consequently OUT-VARIABLE should have the respective value. But this is not the case; it has always the value IN-VARIABLE-1 and the logic always enters the ELSE. Here you can see the situation in my debugger after the execution of the code:
What I've tried so far:
Adapt the condition of the IF to check for the specific value, like IF IN-VARIABLE-1 OF PARENT OF GRAND-PARENT EQUAL ZERO THEN (ZERO is in fact the value of LABELED-VALUE)
It happens with my debugger that it displays an old version of the code but displays the execution line indicator for the most current version. This can result in the indicator being displayed in front of the wrong line. In order to avoid this I've made a change to a comment, recompiled, restarted the serverclass and reattached to the process. Doing so I in fact have obtained the most recent version of the source and I can therefore exclude this problem.
I am not a Cobol expert, though I thought that a simple IF could be manageable, but no avail. Could someone please help me out?
UPDATE:
In my debugger I can edit the values of the fields. If I overwrite the existing value 000 of IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT again with 0 or 000 before the if, then the code works correctly. WTF?

The problem was actually about how IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT is initialized. In my case most probably, it is uninitialized. In that case it is possible to fix the condition this way:
IF LABELED-VALUE OF IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT OR
IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT EQUAL LOW-VALUES
THEN
MOVE IN-VARIABLE-2 OF PARENT-2 OF GRAND-PARENT TO OUT-VARIABLE
ELSE
MOVE IN-VARIABLE-1 OF PARENT-1 OF GRAND-PARENT TO OUT-VARIABLE
END-IF

Related

Cant get my if Statement to work correctly

I'm trying to make it so that when X is selected it then calls another set of code. for example
Main Selection is Type of Settlement( 4 choses ) City2, Village, Town, Hommlet. this is in a drop down in a Name Range. however this really isn't linked to anything, and should affect any of the other outcomes.
part 2 :
=SORTN('Data Sheet'!D5:E17,1,0,'Data Sheet'!E5:E17,FALSE)
Here i have it select from a list of Races ie Human, Dwarf, Elf Ect. along with a % of chance that Race is selected. there are 3 types that will pop up and some other formulas for calculated % of each.
Hommlet TRUE
| Hommlet TRUE
What Type of Settlement?
Population 54
Races and Purcentage Within the Setttlement
% Race # of
Majority Race 91 Half-elf 99 49
Secondary Race 6.03 Genasi 3
Tertiary Race 2.97 Firbolg 97 1.6
3rd on and here is where the issue is. If the Race is "Human" THen is needs to pick from a 'list of Human names. A data base list of name i have.
=If(N7="Human",INDEX('Name Lists'!B2:B15,RANDBETWEEN(1,COUNTA('Name Lists'!B2:B15))),"None")
here is the test i did to insure it would work before i embedded more into the the If formula. i also did a logic test to see if when Human Appeared it would come back TRUE, but it always returns False. if I type the word Human in another cell and Direct above code to that cell it works.
check out thew above

Bring all values in filter except the ones in the condition

I have a list of items which I want to filter.
I created a filter that includes a regexmatch with multiple criteria e.g. mo|oa (so it will bring any item that has either mo (like mouse) or oa (goat) in the string).
=filter(A2:A10,regexmatch(A2:A10,C1))
What I want is to bring the remainder of the list. i.e. all the items that don't fall in the criteria I mentioned (do not include mo or oa).
I have 2 questions:
Is it possible to get the filter to bring the remainder of the items? If so, how?
While trying to figure it out, I used <>&C1 (the cell with the condition mo|oa).
=filter(A2:A10,regexmatch(A2:A10,"<>"&C1))
Surprisingly, it just disregarded the first part mo and showed only result that contain oa. I'm curious for the reason.
Here's a demo file:
https://docs.google.com/spreadsheets/d/1gvTN2p2W7Agw9tIfo4ZcsBlujl0Iq0Ft8h9aYuSH4NQ/edit#gid=0
Thanks!
You can use NOT for REGEXMATCH:
=filter(A2:A10,NOT(regexmatch(A2:A10,C1)))

Making two IF statements in a manual input cell which reference two different cells

Currently, I have Data Validation for cell E4, stating formula =IF(E4>1,””,1). This prohibits the user from entering any number other than 1 or zero.
I need the user to manually enter the number “1” in cell E4 if a particular action is accomplished (a numerical checkbox, essentially).
I also want the value of cell E4 to read “1” if cell B4 reads the number “3”.
I’ve read several examples of nested IF statements and can’t find any that reference two different cells to decide the value of another cell.
Can I make nested IF statements in Data Validation? I haven’t been successful in doing so.
The two formulas I need to affect cell E4 are;
IF(E4>1,””,1)
and
IF(B4=3,E4=1,””)
Any help is much appreciated.
You just need an OR statement.
=IF(OR(E4 > 1, B4 = 3),””,1)

Output using 2 conditions, second condition will use one of 2 different formulas

Currently trying to make this formula using IF/IFS , AND
currently looks like this: =IF((D7=Yes)AND(C7>2500),C7*E5)
so I am trying to check for 2 conditions
I have a cell that has a "yes, no" pull down. So it is checking for a yes
if it is yes then it should check if another cell is less than 2500.
If it is >2500, then a specific formula should be used (C7*E5)
If it was <2500, then it would use a different formula (basically the same, just E5 would be F%, fulling from a different number.
I am not sure if I am on the right track at all.
I have tried using AND, IF, IFS. I am sure I am close but not doing the right combo.
this is how you do it:
=IF(AND(D7="Yes"; C7>2500); C7*E5; C7*F5)
unless you want it like this:
=IF(D7="Yes"; IF(C7>2500; C7*E5; C7*F5); )

Google Sheet: How to replace Cell-A with number in Cell-B if the number input is lower than original Cell-B?

I am trying to find the lowest value of cell B1 that is constantly being updated.
If B1 is lower than A1, then A1 will be replaced with a new B1 value.
And if B1 is higher than A1, then A1 retain its previous updated number.
I am not sure if this can be done with function, script, or if it's even possible to do.
I have this in Cell A1
"=if(A1<B1,B1,A1)"
It's giving me error and I am guessing it's because the "value_if_false" is pointing to the cell I put the IF statement in, thus creating an infinite loop.
Please try in A1:
=if(A1>B1,B1,A1)
and turn on iterative calculation (which I would not normally recommend). Max. of 1 should be adequate.