Create loop with parameter verification

I have scenario with one request, but every time response is new with new parameters
I have to save parameters, ensure that its not null and past new parameter in new request

So my scenario is one loop, witch run till needed parameter is in response
My idea is check is needed parameter exist and if yes - save it and use for new loop, if no - exit from loop.

I still very uncomfortable with Scala, so i try create something like that, but it didn’t compile

val request_new_dictionary = doIf(session => session(“dictionary_sync2”).exists) {
exec(http(“request_new_dictionary”)
.post("""/test/test""")
.headers(headers_Content_Length_0)
.param(""“request”"", “”" “”")
.check(
xpath("/response/dictionary/@sync_ts").find.saveAs(“sync”)
{
doIf(session => session(“sync”).as[String].length() > 0)
saveAs(“dictionary_sync2”)
}
)
)
}

// checking that a session attribute exists (but I think you need the opposite: loop until it exists)
doIf(session => session.contains(“dictionary_sync2”))

// extract, yet don’t fail if the attribute is missing: dontValidate, see https://github.com/excilys/gatling/blob/master/src/sphinx/http/http_check.rst#verifying

xpath("/response/dictionary/@sync_ts").dontValidate.saveAs(“sync”)

still didn’t compile:
15:17:42.826 [ERROR] i.g.a.ZincCompiler$ - C:\Projects\test\user-files\simulations\MainScenario.scala:77: missing arguments for method doIf in trait ConditionalStatements;
follow this method with _' if you want to treat it as a partially applied function 15:17:42.832 [ERROR] i.g.a.ZincCompiler$ - doIf(session => session.contains("dictionary_sync2")) 15:17:42.833 [ERROR] i.g.a.ZincCompiler$ - ^ 15:17:42.969 [ERROR] i.g.a.ZincCompiler$ - C:\Projects\test\user-files\simulations\MainScenario.scala:87: missing arguments for method doIf in trait ConditionalStatements; follow this method with _’ if you want to treat it as a partially applied function
15:17:42.969 [ERROR] i.g.a.ZincCompiler$ - doIf(session => session(“sync”).as[String].length() > 0)
15:17:42.969 [ERROR] i.g.a.ZincCompiler$ - ^
15:17:43.235 [ERROR] i.g.a.ZincCompiler$ - two errors found
Compilation failed
Press any key to continue . . .

I’d say you forgot the doIf block content

doIf(session => session.contains(“dictionary_sync2”)) {

// something
}

Stéphane, sorry to disturb, but I still has problem with loop compilation. I have no more ideas for how to solve this.
Now it is in last doIf block
val request_new_dictionary = //foreach ("${dictionary_sync2}", “dictionary_sync2”){
doIf(session => session.contains(“dictionary_sync2”)){
//doIf(session => session(“dictionary_sync2”).as[String].length() > 0){
//doIf((“dictionary_sync2”).exists){
exec(http(“request_new_dictionary”)
.post("""/bifrost/mobile""")
.headers(headers_Content_Length_0)
.param(""“request”"", “”" “”")
.check(
xpath("/response/dictionary/@sync_ts").find.dontValidate.saveAs(“sync”)
{
doIf(session => session(“sync”).as[String].length() > 0){
session => session.saveAs(“dictionary_sync2”)
}}
)
)
}

And I got error
11:31:21.501 [ERROR] i.g.a.ZincCompiler$ - C:\Projects\Test\user-files\simulations\MainScenario.scala:88: missing parameter type
11:31:21.507 [ERROR] i.g.a.ZincCompiler$ - session => session.saveAs(“dictionary_sync2”)
11:31:21.508 [ERROR] i.g.a.ZincCompiler$ - ^
11:31:21.639 [ERROR] i.g.a.ZincCompiler$ - one error found
Compilation failed
Press any key to continue . . .

Why are you trying to have some weird doIf block in a check?!
Do that AFTER executing request.

Or another way is set parameter to null before saving:
asLongAs(session => session(“dictionary_sync2”).
as[String].length() > 0){

exec(http(“request_new_dictionary”)
.post("""/test/test""")
.headers(headers_Content_Length_0)
.param(""“request”"", “”" “”")

// there I need set parameter “dictionary_sync2” to null
.check(
xpath("/response/dictionary/@sync_ts").exists

xpath("/response/dictionary/@sync_ts").find.saveAs(“dictionary_sync2”)
)
}

I try {exec(
session => session.set((“dictionary_sync2”).as[String] → “”))}
But it didn’t compile

Because another way it always return last saved string for “dictionary_sync2” as variable and request loop endlessly