Parse data only with specific keycheck condition

Hello,

I have a simple question,

I have made a config with success & failure keys.
The problem is when i have to parse the data. The data is almost similar in Failure & Success both so i want to know how can i use a IF statement in lolicode to only parse data when there is success. I need the if else statement for the below Keycheck Code

BLOCK:Keycheck
LABEL:Check
  banIfNoMatch = False
  KEYCHAIN SUCCESS OR
    INTKEY @capacity GreaterThan 0
  KEYCHAIN RETRY OR
    INTKEY @capacity EqualTo 0
ENDBLOCK

When there is a keycheck block, the bot will continue if (by default) the status is SUCCESS or NONE. So in your case, the bot will continue reading blocks after the keycheck and it will compute the parse.

If you really cannot set up a good FAIL key, then you can use this

IF STRINGKEY @data.STATUS EqualTo "SUCCESS"
// Put your parse block here (remove the // at the start obviously)
END

This worked.

One more question sir

Here is my case i am using a variable named “capacity”

As it is recursive. I only want to parse data where the variable is recursive.

For example

WHERE capacity is not equal to 0 then
parse blocks
end

Is it possible??

Below is the code for the variable.

BLOCK:Parse
LABEL:Available Capacity
input = @data.SOURCE
leftDelim = ““available_capacity”:”
rightDelim = “,“min_age_limit”:18”
RECURSIVE
MODE:LR
=> VAR @capacity
ENDBLOCK

BLOCK:Keycheck
LABEL:Check
banIfNoMatch = False
KEYCHAIN SUCCESS OR
INTKEY @capacity GreaterThan 0
KEYCHAIN RETRY OR
INTKEY @capacity EqualTo 0
ENDBLOCK

Ah by the way, forgot to mention.
In OB2 you need to declare the variable before the IF and then assign its value inside the IF, otherwise it will just live inside the scope of the IF statement.

So put a ConstantString block before the IF and set the variable capacity with empty value, then fill it inside the IF statement through the parse block.

As for your second question, you can use the Count Occurrences block and then make an IF based on that, for example let’s say you have your number of occurrences in a variable called occurrences

IF INTKEY @occurrences GreaterThan 0
// Your parse block here
END
1 Like

Sir you did not get my point.

In my case INTKEY has many recursive occurances. So i want a code like where ever there is an occurance it should be a capture else it should be a retry.

The loop should be like infinite till there is an occurance to capture

You didn’t read what I wrote. I said to use a Count Occurrences block NOT a Parse block.

I am unable to make a block to count occurances. Could you just help me with an example to it. I will manage the IF statement after that.

Thanku so much for helping me

immagine