I have never worked with a procedural programming language before and it’s somewhat unsettling.
Here is what I’m trying to write in C++.
#include<iostream>
using namespace std;
void sayNumber(int a); //function says a number
int randNumb(); //function generates a random number
void sayRand(); //function takes both functions above and runs them together
int main()
{
sayRand();
return 0;
}
void sayNumber(int a)
{
cout << a; //SayNumber(${a})
return;
}
int randNumber()
{
foo = rand() % 10 + 1; //RAND (1, 9)
return foo;
}
void sayRand()
{
int bar = randNumber();
sayNumber(bar);
return;
}
The best I can come up with in dialplan is:
[test]
exten => foo,1,NoOp()
same => n,Set(j=${RAND(1,2)})
same => n,Set(k=${j})
exten => bar,1,NoOp()
same => n, Set(l=8)
GotoIf(${j}=1?foo:bar)
;--I want this to be a switch statement were k or l is printed based on the result of j but I have no idea how to make this work
--;
same => n,SayNumber(${k}) ;This would be under foo
same => n,SayNumber(${l}) ;This would be under bar
Lastly can you use variables to navigate the priorities?
For example does something like this work:
exten => foo,1,NoOp()
same => n,Set(i=3)
same => ${i},SayNumber(${i})