Incrementing Global Variable

Hello all, I’ve lost my mind trying to increment a global variable and am seeking your help to find it :confused:

I have this set in extensions.conf:

[globals]
NONEXISTENT=0

Then in the dialplan:

exten => NONEXISTENT,1,Set(GLOBAL(NONEXISTENT)=${INC(GLOBAL(NONEXISTENT))})

Returns this:

func_math.c:401 crement_function_read: Failed to obtain variable GLOBAL(NONEXISTENT), bailing out

But the variable certainly exists:

exten => NONEXISTENT,1,NoOp(${GLOBAL(NONEXISTENT)})

Returns:

0

For my life I can’t seem to figure out why I can’t increment a global variable.

Any advice appreciated :grimacing:

I think you are pushing the limits there. Why not just add 1 to the variable and set it to the result?

Thanks for the reply, I also tried:

exten => NONEXISTENT,1,Set(GLOBAL(NONEXISTENT)=${INC(${GLOBAL(NONEXISTENT)})})

And got:

func_math.c:401 crement_function_read: Failed to obtain variable 0, bailing out

I meant ......$[${NONEXISTENT}+1}

Big thanks, that’s what I ended up doing. Just didn’t see a reason the other wouldn’t work.

Cheers :slight_smile: