[OpenSIPS-Users] If statement Syntax issue

osiris123d duane.larson at gmail.com
Sat Dec 12 18:43:50 CET 2009


I am not getting those errors now.  I am not sure what changed.  I am running
OpenSIPS 1.6.  I don't know why I got those errors at first.  Sorry.




Bogdan-Andrei Iancu wrote:
> 
> Hi,
> 
> I just tried the following piece of script:
>         $var(current_day) = $time(%u);
>         $avp(s:mobile_time) = "0815221515";
> 
>         if ( $var(current_day) >= $(avp(s:mobile_time){s.substr,8,1}) &&
>         $var(current_day) <= $(avp(s:mobile_time){s.substr,9,1}) )  {
>                 xlog("boo far\n");
>         }
> 
> And it worked with no error - could you also try?
> 
> BTW, what opensips version are you using?
> 
> Regards,
> Bogdan
> 
> osiris123d wrote:
>> This is how $var(current_day) is set
>> $var(current_day) = $time(%u);
>>
>> With $avp(s:mobile_time) I do
>> avp_db_load("$ru/username","$avp(s:mobile_time)");
>> and the avp is set to 
>> 0815221515
>>
>> 0815 being the Time of day the phone can be called, 2215 being the stop
>> period when the phone will not be called, and 15 with 1 = monday and 5 =
>> friday so the phone number can be called Monday through Friday.
>>
>> Thanks
>>
>>
>>
>>
>> Bogdan-Andrei Iancu wrote:
>>   
>>> Hi,
>>>
>>> In order to try to reproduce this, please post the values you use for:
>>>     $avp(s:mobile_time)
>>>     $var(current_day)
>>>
>>> I will try to you exactly the same script code and values as you to see 
>>> what I get.
>>>
>>> Regards,
>>> Bogdan
>>>
>>> osiris123d wrote:
>>>     
>>>> The left side variable is defined because I do an xlog before the if
>>>> statement and make sure the variable is correct and also an integer.  I
>>>> am
>>>> not sure if you saw my post right after my first message, but here it
>>>> is
>>>> again
>>>>
>>>> Ok so I did some more testing and I see the following.  Below in my
>>>> first
>>>> post the $var(current_day) value was 7.  The
>>>> $(avp(s:mobile_time){s.substr,8,1}) value was 1 and
>>>> $(avp(s:mobile_time){s.substr,9,1}) value was 5.  Well if I changed the
>>>> value of $(avp(s:mobile_time){s.substr,9,1}) to be 7 I don't see those
>>>> errors and the if statement is true and moves on like it should.  So
>>>> are
>>>> those errors the normal output when an operator is not true?  I would
>>>> figure
>>>> that you would never see those errors if its true or not. 
>>>>
>>>>
>>>> So everything works correctly if the variables are TRUE, its only if
>>>> the
>>>> variables equal FALSE in the if statement that I get those errors in my
>>>> log
>>>> files.  So are those logs normal if one of the statements in the IF
>>>> statement are false?
>>>>
>>>>
>>>>
>>>>
>>>> Bogdan-Andrei Iancu wrote:
>>>>   
>>>>       
>>>>> Hi Osiris,
>>>>>
>>>>> Maybe the left side operand cannot be evaluated because was not
>>>>> defined 
>>>>> (the $var(current_day) ). Can you check this ?
>>>>>
>>>>> Regards,
>>>>> Bogdan
>>>>>
>>>>> osiris123d wrote:
>>>>>     
>>>>>         
>>>>>> I have the following IF statement that looks to be good syntax but I
>>>>>> am
>>>>>> getting an error
>>>>>>
>>>>>> Here is the syntax
>>>>>>
>>>>>> if ( $var(current_day) >= $(avp(s:mobile_time){s.substr,8,1}) &&
>>>>>> $var(current_day) <= $(avp(s:mobile_time){s.substr,9,1}) )
>>>>>> {
>>>>>> blah
>>>>>> blah
>>>>>> }
>>>>>>
>>>>>> The error I get is
>>>>>> CRITICAL:core:comp_scriptvar: cannot get left var value
>>>>>> WARNING:core:do_action: error in expression (l=650)
>>>>>>
>>>>>> All variables have values so I know thats not an issue and the substr
>>>>>> Transformation is also correct .  If I edit the IF statement to only
>>>>>> have
>>>>>> the following it works fine
>>>>>>
>>>>>> if ( $var(current_day) >= $(avp(s:mobile_time){s.substr,8,1}) )
>>>>>> {
>>>>>> blah
>>>>>> blah
>>>>>> }
>>>>>>
>>>>>> Any clues?
>>>>>>
>>>>>>
>>>>>>   
>>>>>>       
>>>>>>           
>>>>> -- 
>>>>> Bogdan-Andrei Iancu
>>>>> www.voice-system.ro
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.opensips.org
>>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>>
>>>>>
>>>>>     
>>>>>         
>>>>   
>>>>       
>>> -- 
>>> Bogdan-Andrei Iancu
>>> www.voice-system.ro
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>>>     
>>
>>   
> 
> 
> -- 
> Bogdan-Andrei Iancu
> www.voice-system.ro
> 
> 
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/If-statement-Syntax-issue-tp4122982p4156901.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.



More information about the Users mailing list