<p></p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/smititelu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/smititelu">@smititelu</a> - that note from the docs sounds ok for me (maybe because I wrote it, although I am not sure I did). Practically wants to say that assign explicitly a value before using it, not to get the value set a while ago in another SIP message processing context.</p>
<p dir="auto">If you do:</p>
<pre class="notranslate"><code class="notranslate">request_route {
...
  while ($var(i) < 100) {
    ...
    $var(i) = $var(i) + 1;
  }
...
}
</code></pre>
<p dir="auto">The while loop gets inside once because  $var(i) is 0 first time, but then remains set to 100 for all next requests. Therefore set it to the value you want before using it:</p>
<pre class="notranslate"><code class="notranslate">request_route {
...
  $var(i) = 0;
  while ($var(i) < 100) {
    ...
    $var(i) = $var(i) + 1;
  }
...
}
</code></pre>
<p dir="auto">Feel free to change the statement in the docs, if you consider more clarifications there, but I don't see any benefit in storing an extra int field in the internal var structure.</p>
<p dir="auto">Maybe $vn() offers better the kind of variable you need. It is like $var() but can have $null value (state).</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128770857">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZPYGYL2YYB2KTNLPUTVKOBTLANCNFSM5WEMKM5Q">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZMIOGHVKVRVLLBZAOTVKOBTLA5CNFSM5WEMKM52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIND22KI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/pull/3114/c1128770857</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128770857",
"url": "https://github.com/kamailio/kamailio/pull/3114#issuecomment-1128770857",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>