IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Best way of storeing a per macro setting.., Is there a way to parse all macros for a special comment line?
Warrentheo
post Nov 5 2009, 11:59 AM
Post #1


Newbie
*

Group: Members
Posts: 5
Joined: 4-November 09
From: Earth, where you from?
Member No.: 4,519



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

Go to the top of the page
 
+Quote Post
Scasper
post Nov 5 2009, 01:09 PM
Post #2


Expert
****

Group: Members
Posts: 543
Joined: 10-November 07
Member No.: 2,634



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

QUOTE (Warrentheo @ Nov 5 2009, 09:59 AM) *
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 wink.gif I've been looking for an excuse to change mine anyway.


--------------------
Steve CasperMacro Lover

"If wishes were horses, we'd all be eating steak." - Jayne Cobb
Go to the top of the page
 
+Quote Post
Warrentheo
post Nov 5 2009, 01:32 PM
Post #3


Newbie
*

Group: Members
Posts: 5
Joined: 4-November 09
From: Earth, where you from?
Member No.: 4,519



QUOTE (Scasper @ Nov 5 2009, 11:09 AM) *
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 wink.gif 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?

Go to the top of the page
 
+Quote Post
Cory
post Nov 5 2009, 01:46 PM
Post #4


Master
*******

Group: Members
Posts: 1,897
Joined: 17-February 05
From: Fallbrook, CA
Member No.: 281



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.


--------------------
Cory Jackson
Fallbrook, California
Bluepoint Design
Go to the top of the page
 
+Quote Post
Warrentheo
post Nov 5 2009, 01:59 PM
Post #5


Newbie
*

Group: Members
Posts: 5
Joined: 4-November 09
From: Earth, where you from?
Member No.: 4,519



QUOTE (Cory @ Nov 5 2009, 11:46 AM) *
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  laugh.gif


Go to the top of the page
 
+Quote Post
paul
post Nov 5 2009, 04:14 PM
Post #6


Expert
****

Group: Members
Posts: 476
Joined: 4-July 04
Member No.: 10



QUOTE (Warrentheo @ Nov 6 2009, 03:59 AM) *
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:
CODE
// 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.


--------------------
Paul
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



Lo-Fi Version Time is now: 22nd November 2009 - 04:54 PM