Comment Macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
rjseastrand
Newbie
Posts: 1
Joined: Wed May 09, 2007 2:36 am

Comment Macro

Post by rjseastrand » Wed May 09, 2007 2:45 am

I was wondering if there was a way to comment the macro to make it easy to remember what it is doing for future reference and editing?

Thanks

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed May 09, 2007 3:02 am

//you can add comments with two / at the start of the line
//there are a bunch of other characters that work too, but //
//is all I can remember right now :D

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed May 09, 2007 3:49 am

Hi rjseastrand,

Have you looked in the Help file?
  1. From the Macro Scheduler Main Window, Click Help/Contents to open the Help file.
  2. Click the "Search" tab if it is not already highlighted.
  3. In the "word(s) to search for" field, type in: comments
  4. Click the "List Topics" button.
A variety of topics will be listed, here's two of interest:

------------------------------------------------------------------------------------------------------------------

Remark

Remark>Some Comment

The remark statement is ignored by the interpreter. It exists simply to allow comments to be placed in the code. In fact, any text that is not a recognised command can be used for this purpose.

Several lines of code can also be commented out in one go by using /* before and */ after the lines to be commented. E.g.:

/*
Let>r=5
Repeat>r
DDERequest>Excel,efile.xls,R%r%C2,Name,60
Let>r=r+1
Until>r=5
*/


------------------------------------------------------------------------------------------------------------------

The Complete Script

So let's review the script. I have added comments to document the script – to make it more readable and easy to follow. You can use almost anything that isn't a recognised script command for comments. There is a reserved word called Remark which can be used:

Remark>This is a comment

But I've used // to indicate my comments. Some people like to use **. Use what you feel comfortable with – as long as it isn't a recognised script command – or it will try to execute your comments. Which could be interesting!

...it continues... check the help file to read the whole thing...

------------------------------------------------------------------------------------------------------------------

Also, try the Block Comment feature recently added to the Advanced Editor...
  1. Open a script in the Advanced Editor.
  2. Highlight a couple lines you'd like to "comment out".
  3. Click Edit/Block Comment... and the lines will be commented out.
  4. If you do not wish these lines commented out, you could manually delete the /* and */ lines that have been inserted or... click Edit/Undo to reverse your last action (/* and */ lines will be removed) or just press CTRL-Z which is the keyboard shortcut for Undo.
Don't forget to search the Help file, help on almost any topic can be found there... take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts