I need to declare a variable inside an IF statement and then use it outside the statement. It's a range variable, so I can't declare the variable first (where it would have session scope) and set its value inside the IF statement. It works if I set global scope, but that's like killing a fly with an anvil. Is there an alternative?
Here's what I'm doing now:// Declare InputBook someplace here
loop(sIndex, 1, 6) {
@global = 1;
if (sIndex == 6) {
range InputSheet = [%(InputBook$)](1:5)!;
string OutputSheetName$ = "All";
};
else {
range InputSheet = [%(InputBook$)]$(sIndex)!;
string OutputSheetName$ = InputSheet.name$;
};
@global = 0;
// Use InputSheet and OutputSheetName
};
I'm using OriginPro 8.5 SR1 on Windows 7.