Sorry if the title is a little confusing,
I am trying to have a procedure that containts a proxy text that will be replaced after, but the only way I can create the procedure is if I declare the variable inside the procedure and that ruins my intention
// Create variable
string $vartest = "test";
// Check print
print $vartest;
// Rename the text inside the variable
$vartest = `substituteAllString $vartest "test" "test_2"`;
// Check print again
print $vartest;
// Declare a procedure / DOESN'T WORK /
proc procTest()
{
print $vartest;
}
// Test proc
procTest();
//////////////////////////////////
I need to not declare the variable inside the procedure because I want to have just one big code with all my procedures with a "proxy test" and then for each buttom I'll change the text inside the variable. Is there a clean way to do that?
Replies
proc procTest(string $varTest)<br>{<br>print $varTest;<br>}<br><br>procTest($varTest);string $scope = "This is scoped";<br>print($scope); //prints "This is scoped";<br>{<br> print($scope); //prints "This is scoped";<br>}<br><br>proc printVar() {<br> print($scope); //gives undeclared variable because there is no variable declared as $scope inside printVar()<br> string $scope = "This is scoped locally";<br> print($scope); //We can use the name scope for a variable because it's not used in the function scope<br> string $scopeTwo = "This is scoped locally";<br>}<br>printVar();<br><br>print($scopeTwo); //gives undeclared variable because there is no variable declared as $scopeTwo in the global scope<br>global string $scopeTwo; //even with global we just declared a new $scopeTwo string<br>print($scopeTwo); //this will print nothing as it's an empty string<br><br>proc printVarAgain() {<br> global string $scope;<br> print($scope); //prints "This is scoped";<br>}<br>printVarAgain();Sorry if it was a little dificult to make me understand how it works