How to get next item from resource

How can I get the next item from the config resource?

TAKEONE FROM "id" => @myString

The above code is giving me the same item I want to get the next item what is the code to get the next one?

  1. Create a file like this and put it in the OB2 root

immagine

  1. In the config settings set up a new resource like this

immagine

  1. Write this in the LoliCode section
TAKEONE FROM "id" => @firstString
LOG @firstString

TAKEONE FROM "id" => @secondString
LOG @secondString

It will output exactly what you want

immagine

Note: These statements are supposed to be used inside loops.

@Ruri If I use this statement TAKEONE FROM "id" => @myString in multirun job so, whenever I call it, will it return the next one?

Yes, there is a lock on the TakeOne method so only 1 bot should be able to access it, and the resource is shared across all bots so once a bot consumes a line it will not be available for others. No 2 bots should be able to get the same value, unless you’re using a random resource, in which case it will choose randomly and might choose the same line, or if the resource lines are exhausted and it loops back to the start.

1 Like

Anyway, to declare a global variable like at the start of job int i = 0 and with each job done it increases the value of i by one {i++}

I don’t have time to write this but it’s really easy to do, please try yourself and post the code if it doesn’t work after a few tries.

1 Like