Jump to content
Macro Express Forums

Best way of storeing a per macro setting..


Recommended Posts

Hello all, I am writing a new macro that will use information stored in each macro to generate a second file for launching that macro.  I have been trying to figure the best way for storing this info along with each macro.  The way that currently comes to mind is to put a specially formatted comment line at the top of the macro, and use my new macro to parse all macros in a given .mex for these comment lines.  Unfortunately, I am unable to find a way to parse all macros, or read them from another macro at all.

 

I was hoping someone could point me in the correct direction, or possibly suggest a better way of storing this info (trying to avoid a third file that has to be edited manually).

Link to comment
Share on other sites

Information isn't stored inside macros..........

 

Hello all, I am writing a new macro that will use information stored in each macro to generate a second file for launching that macro.  I have been trying to figure the best way for storing this info along with each macro.  The way that currently comes to mind is to put a specially formatted comment line at the top of the macro, and use my new macro to parse all macros in a given .mex for these comment lines.  Unfortunately, I am unable to find a way to parse all macros, or read them from another macro at all.

 

I was hoping someone could point me in the correct direction, or possibly suggest a better way of storing this info (trying to avoid a third file that has to be edited manually).

If you have a macro that sets a variable with a specific value, then that value can be retrieved using one of the "Save Variable" commands in the source macro, and "Restore Variables" command in the calling macro.

 

Other options include storing the information in a .txt file on your hard drive. Or an .ini file. Or using the Write to and Read from Registry commands.

 

By the way: Thanks for stealing my icon ;) I've been looking for an excuse to change mine anyway.

Link to comment
Share on other sites

Information isn't stored inside macros..........

 

 

If you have a macro that sets a variable with a specific value, then that value can be retrieved using one of the "Save Variable" commands in the source macro, and "Restore Variables" command in the calling macro.

 

Other options include storing the information in a .txt file on your hard drive. Or an .ini file. Or using the Write to and Read from Registry commands.

 

By the way: Thanks for stealing my icon ;) I've been looking for an excuse to change mine anyway.

 

Lol, sorry :-P

 

 

I was hoping for a quick and easy way to store this info with the macro it goes with, and read it from outside that macro without having to run every macro.  Will the Save/Restore Variable work if the original macro has never been run?

Link to comment
Share on other sites

No simple way to do it.

.........................................

As far as I know there is no place in the macro where you could save the macro information so that it would be accessible from the outside by accessing the MEX file. However you could Export > Output Macro Information and access stuff in the macro. EG I would write a macro that would Output Macro Information and export only the macro name and script. Then you could have a comment in the first time and create a macro to parse the output file. Or just use the macro name. The downside is that you would have to run this every time you create a new macro.

 

I've done something similar to this to search for text across all macros. If you're interested I could make you a macro like I described for pretty cheap.

Link to comment
Share on other sites

No simple way to do it.

.........................................

As far as I know there is no place in the macro where you could save the macro information so that it would be accessible from the outside by accessing the MEX file. However you could Export > Output Macro Information and access stuff in the macro. EG I would write a macro that would Output Macro Information and export only the macro name and script. Then you could have a comment in the first time and create a macro to parse the output file. Or just use the macro name. The downside is that you would have to run this every time you create a new macro.

 

I've done something similar to this to search for text across all macros. If you're interested I could make you a macro like I described for pretty cheap.

 

Ah, that was probably what I was looking for, I will look into it.  Thank you very much, you help is appreciated  :lol:

Link to comment
Share on other sites

Hello all, I am writing a new macro that will use information stored in each macro to generate a second file for launching that macro. I have been trying to figure the best way for storing this info along with each macro. The way that currently comes to mind is to put a specially formatted comment line at the top of the macro, and use my new macro to parse all macros in a given .mex for these comment lines. Unfortunately, I am unable to find a way to parse all macros, or read them from another macro at all.

I designed a facility to handle exactly this requirement in the PGM Functions library. Each macro contained lines of comments similar to the following at its top:

// PF:{ Math - Abs }
// PN:Number
// PA:Num
// PT:D
// PD:ParameterDecimal1
// PW:  ***** DO NOT CHANGE ANY OF THE LINES ABOVE AND INCLUDING THIS ONE! *****

which were used to name the macro, and describe its "parameters". I then wrote a macro to read these comments for each macro and produce entries in the registry, which were used by a "system" macro to allow the calling of all our macros with parameters.

For example, you could invoke the function in this example by storing a string variable "{ Math - Abs }, -20" in the registry at a specific location, then invoke the function "{ PGM Function }" to process the command.

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...