Jump to content
Macro Express Forums

Save/Restore variables - should this work?


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...