On Jun 25, 2014, at 10:47 PM, Austin Einter <
austin.einter@gmail.com> wrote:
> Thanks, I modified as per suggestion, now script looks as below
>
> function modify_content_length(msg, length)
>
> local offset = string.find(msg, "Content-Length", 1, true)
> if(offset == nil) then
> else
> msg1 = msg:gsub("(Content%-Length%s*:%s*)\r","%1"..n.."\r")
> print("msg1 = ",msg1)
> end
>
> end
>
> msg = [=[INVITE\r\nContent-Length : \r\n\r\nv=0\r\n]=]
>
> modify_content_length(msg, string.len(msg))
>
>
> Looks now getting error because of n
>
> Error ->
>
> lua5.2: string_test.lua:7: attempt to concatenate global 'n' (a nil value)
> stack traceback:
> string_test.lua:7: in function 'modify_content_length'
> string_test.lua:15: in main chunk
> [C]: in ?
>
> Regards
> Austin
You are not defining the variable `n` to be any value, hence the error message saying you are trying to concatenate a global `n`, which is a nil value. You need to assign a value to `n` before you can concatenate it, or use a different variable.