terrypin Posted May 11, 2010 Report Share Posted May 11, 2010 I found several old threads on the general issue of whether save/restore variables are worth bothering with, probably the most comprehensive being this: http://pgmacros.invisionzone.com/index.php?showtopic=4176 But for an application like the one below (which I've simplified for discussion) I really see no reason why this facility shouldn't work. Where am I going wrong please? I'm tempted to abandon save/restore entirely anyway and go 100% to registry read/write, regardless of the level of simplicity/complexity. But my curiosity is piqued now. I have these two macros. Count names Variable Set Integer %Count% to 99 Text Box Display: End of submacro // Displays Count. Variable Save: Save Integer Variables // Save Count. If I run that macro on its own, I get the correct result of 99 for Count displayed. Use Count Macro Run: Count names Variable Restore: Restore Integer Variables // Restore Count Text Box Display: In main macro // Display Count But that gives Count = 0. Yet all works fine if I use the registry instead: Count names (registry) Variable Set Integer %Count% to 99 Text Box Display: End of submacro // Displays Count. Write Registry Value "%Count%" into HKEY_CURRENT_USER\Terry Work Area\Integer\Count // Write Count. Use Count (registry) Macro Run: Count names Read Registry Value "HKEY_CURRENT_USER\Terry Work Area\Integer\Count" into %Count% // Read Count Text Box Display: In main macro // Display Count Edit: Sorted! I'll leave the rest of the post as it might help someone sometime. I've no idea why, but in Count names somehow the option 'Make this variable available to macros' for the variable Count had become unchecked from its normal default state. -- Terry, East Grinstead, UK Use Count.mex Count names.mex Quote Link to comment Share on other sites More sharing options...
paul Posted May 11, 2010 Report Share Posted May 11, 2010 But for an application like the one below (which I've simplified for discussion) I really see no reason why this facility shouldn't work. Where am I going wrong please? Your submacro Count Names has declared the integer variable %Count% as Local, because you haven't ticked the "Make this variable available" box! Local variables are not saved. Quote Link to comment Share on other sites More sharing options...
terrypin Posted May 11, 2010 Author Report Share Posted May 11, 2010 Your submacro Count Names has declared the integer variable %Count% as Local, because you haven't ticked the "Make this variable available" box! Local variables are not saved. Yes, thanks Paul, spotted a little later, hence the edit. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.