Share variable between functions

Hi,

      gtkdialog gui seperate buttons use seperate  functions in their GUI. A variable \(newFolderName\) is being set in one  function \(funcA\) and it needs to be called in another function \(funcB\). I  thought using global variable \(like in python\) concept should work  however it does not.

How else is it possible to do share variables between functions. ?

Example

funcA() {
	newFolderName=v01
}

funcB() {
	mkdir newFolderName
}

funcA and funcB are called as action to button

<button>
	<label>Confirm</label>
	<action>funcConfirmDisplayText</action>
</button>

<button>
	<label>Start</label>
	<action>funcStart</action>
</button>

change to mkdir $newFolderName

Oops that is already true ( it is actually mkdir $newFolderName )

You can always pass a variable to a function:

funcA(){
  echo "Hello $1"
  funcB v01-$1
}
funcB(){
  mkdir $1
}
funcA Singhai

Will echo "Hello Singhai" and create a folder named "v01-Singhai"

When you define a variable prior to functions, that value will be used.
However, if you define a variable with the same name within a function, that value will remain inside the function.

Not sure if 'special' shopt settings are required or if its regular behaviour.

Longhand on OSX 10.7.5, default bash terminal...

Not sure if this is what you are after:-

Last login: Sun Jan 26 09:38:30 on ttys000
AMIGA:barrywalker~> FuncA() { text="This is function A with a variable..."; }
AMIGA:barrywalker~> FuncB() { eval $1; echo "$text"; }
AMIGA:barrywalker~> FuncB FuncA
This is function A with a variable...
AMIGA:barrywalker~> _