John Brawley wrote:
> Please advise?
> I've never fully grasped scope/namespaces, but have been able to work around
> earlier problems.
> I now have a program flow situation in which I have *no choice* but to do
> this this way.
> Suppose I have something like;
>
> var1=0.0;
>
> main() {
> /*do something sane*/
> if (/*condition*/) {
> var1=7.65347; //somenumber
> }
> //use var1's new value
> }
>
> How do I get a changed variable back out of an if statement's { } block?
Declare the variable in main, but not in the if scope.
double var1;
if (/*condition*/) {
var1=7.65347; //somenumber
}
--
Ian Collins.