Macro question

How do you incorporate/install/add/introduce a macro that someone else has written to your CC3+?

Little tiny baby steps please - I really don't seem to be able to get this through my head even though I've read the written tutorials on this several times over.


Even better - is there a video on how to do it? I have autism, and I generally learn things about 10x faster if I can watch someone else do it first.

Comments

  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    I don't have a video, but there are two approaches:

    1)
    Put the entire macro in a plain text file, and name it whatever you want, but with the file extension .mac (for te sace of example, let us refer to it as mymacros.mac) and put it in the CC3+ data directory.
    Now, inside CC3+ you can load that macro file by typing this command on the command line
    LOADMAC mymacros.mac

    Now, all the macros in that file will be available to you. When you are done, you need to reload the default macro file with the command
    LOADMAC fcw32.mac


    2)
    Simply edit the default macro file, fcw32.mac instead, and put your macro in there. This saves you from having to keep loading the macro file and reloading the default one afterwards, but since this is the default macro file, it is also important that you don't mess it up, so create a backup before editing it.
    The file is found in the CC3+ data directory, and can either be edited with a standard text editor (like notepad), or you can edit it from inside CC3+ by going to Tools --> Macros --> Edit Macros.
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    Thank you, Remy :)

    So once I've set up a way to open Notepad by somehow adding it to either my Start menu or my toolbar (the way I do it now is right click in a folder and tell it to create a new txt file, and then double click the txt file)... and I find and open the default macro, fcw32.mac, what are the rules? I mean - what does a macro start and end with, and is there a right and wrong order?

    I am so sorry - all these questions are probably answered in your latest tutorial blog, but I have a reading comprehension problem I've decided to finally admit to. It makes me feel really stupid at times, but I only understand a written article if I already know what its talking about. It sounds perfectly mad, I know, but that's how my brain works - for me, written instructions are easy to give because I'm writing about what I already know, but I can't understand stuff I don't already know and understand very well.
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    A macro allways starts with the line
    MACRO macroname

    where macroname is the name of the macro, what you would type on the CC3+ command line to call it.

    The macro must also end with
    ENDM

    Leave one blank line between the end of one macro and the next, and the last line in the file should be a blank one, but otherwise, don't put blank lines in a macro files.

    All the lines between the MACRO and ENDM lines are just regular CC3+ commands, such as this simple macro


    MACRO drawline
    LINE 0,0 1000,1000
    ENDM
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    Thank you again! :)

    I really need this tiny nibble size help. I didn't understand before, but it seem to me that a macro is a very simple piece of code with high level commands that are more or less in English words rather than long strings of hex numbers and syntax?

    Sort of a bit like the old BASIC language, but closer to straight English?
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    Technically, a macro is nothing more than a list of regular CC3+ commands, the very same commands you manually run in the program. To write a macro, you need to know the text equivalent of the CC3+ command you wish to include, usually you can see this on the command line, when it is waiting for a new command, the previous command it ran will be seen in square brackets.

    If you look in the Tome (I recommend the new update released a few days ago), in Appendix A of most chapters, there is a list of all CC3+ commands, and their text equivalents, which describes how each command is used in a macro.
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    I am sure you have already said all this in your article, so I feel very humble that you are willing to say it all over again in total simpleton for me like this - thank you Remy :)

    I think you have given me the key to the door I needed to open before any of it made sense to me.

    I will download the new Tome and start to have a read of all these new things you have unlocked for me.
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    Posted By: LoopysueI am sure you have already said all this in your article
    Not really. I haven't made any real articles on macros. That recent article of mine on development is something completely different, and very much more complex than macros.

    I did a short intro to macros in this Command of the Week article, you may wish to have a look at it.
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    And there we have the perfect example of just how confused I really was! LOL!

    I will also have a look at that article again. I say again because I am more than likely to have read it before, but the last time I read it the words might have made sense individually while the meaning of each phrase must have gone right over my head. I lacked the key to understand it before now ;)
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    Already I have another question!

    On reading the first part of your Command of the Week article I saw that any macro I wrote or pasted into the default file might be overwritten every time there was an update to CC3+. I don't need to know how to do this yet (because I'd only get confused all over again), but would it be possible to switch between the default macro file and mymacros.mac by making a toggle button? A button that tells the system to look at what is loaded and switch to B if A is loaded, or to A if B is loaded. Can we make buttons that toggle things like that? It just occurred to me that if you could do that then you wouldn't have to keep messing around constantly updating the default macro file if you could switch from one to the other at any time by just clicking a button.

    Please don't tell me how to make a button yet. I'd probably have a stroke or something trying to understand it all. I'd just like to know if that is a possibility - a future goal.
  • Posted By: LoopysueAlready I have another question!

    On reading the first part of your Command of the Week article I saw that any macro I wrote or pasted into the default file might be overwritten every time there was an update to CC3+. I don't need to know how to do this yet (because I'd only get confused all over again), but would it be possible to switch between the default macro file and mymacros.mac by making a toggle button? A button that tells the system to look at what is loaded and switch to B if A is loaded, or to A if B is loaded. Can we make buttons that toggle things like that? It just occurred to me that if you could do that then you wouldn't have to keep messing around constantly updating the default macro file if you could switch from one to the other at any time by just clicking a button.

    Please don't tell me how to make a button yet. I'd probably have a stroke or something trying to understand it all. I'd just like to know if that is a possibility - a future goal.
    I know you can bend a macro to a button. If it's possible to bend TWO (or even three) macros to a single button, then you could make a button that would:
    1. Load the macro file
    2. Run the macro command you want
    3. Restore the original macro file
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    That's good news, Basilgass - gives me a far distant goal to achieve once I get the hang of these macro things.

    Thank you :)
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    If you want a button to execute a macro directly, I recommend putting the macro in a script file and calling that via SCRIPTM instead of loading and reloading macro files.

    A script file is like a macro file, except that it only contains a single macro that are run immediately upon calling it, the file extension is .scr, and it is just a list of commands, it doesn't contain the starting and ending MACRO and ENDM commands a macro does, but otherwise there is no difference between putting the commands in a script file vs a macro.
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    That's interesting.

    Are script files faster than macros - more lightweight on the system?

    I'm aiming more to make it possible to switch between the default macro file and my own personal one without having to down tools completely to type commands. I thought that clicking a button would be easier and faster. I'm leaning towards doing a separate .mac file of my own so that I don't have to worry about modifying the default file or having to set everything up all over again every time there's an update.
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    Script files might be marginally lighter, since they don't have to stay loaded in memory as macros does, but they will have the overhead of loading the file on each use. Then again, switching back and forth between macro files will be very similar. But in any case, I don't think the difference is large enough to be noticeable.
  • Question - what is the macro that you want added, do?
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    Shessar pointed out Joachim's river macro on another thread. I followed the link, but I was having difficulty wrapping my head around the basic concept of exactly what a macro is in CC3 and what to do with it.

    Now that Remy has so kindly explained macros in terms I can understand I think I will be ok. I just need to finish the artwork for an annual first, and then I can have a play with it all.
  • LoopysueLoopysue ProFantasy 🖼️ 40 images Cartographer
    Thanks, Remy :)

    I have a clear plan of what I want to do now.

    I will set up my own macro file and collect or write the macros I want in it, then at some point in the future I will ask how to make buttons.
  • Posted By: MonsenIf you want a button to execute a macro directly, I recommend putting the macro in a script file and calling that via SCRIPTM instead of loading and reloading macro files.

    A script file is like a macro file, except that it only contains a single macro that are run immediately upon calling it, the file extension is .scr, and it is just a list of commands, it doesn't contain the starting and ending MACRO and ENDM commands a macro does, but otherwise there is no difference between putting the commands in a script file vs a macro.
    Didn't knew the SCRIPTM trick. It works perfectly! Thanks Monsen.
  • DaltonSpenceDaltonSpence Mapmaker
    edited April 2019
    If I understand it correctly the main functional difference between scripts and macros is that you can't use conditional statements (IFs and GOTOs) in a script because you can't use labels. This means no loops or error checking, just straight linear logic. If you want to do something more complicated than directly converting user input into actions or objects you need a macro. (The same goes for hotspots which work as scripts embedded in a map.) Just remember that adding a toolbar button means messing with menu files; it might be simpler to either call the script manually from the command line or (if you plan to call certain scripts or macros often on a particular map) create a temporary hotspot control panel for frequently used functions.
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    edited April 2019
    That's not right. You can use labels and conditionals in scrips, just as in macros (and in hotspots too).

    There is no real difference between scripts and macros, except that a macro has a name and can be called with a command from the command line, while a script needs to be loaded (using SCRIPT/SCRIPTM) and it is being run immediately upon loading it.

    Adding hotspots to a map (and/or a template) instead of using toolbar buttons is always a good idea if the functions are only meant to be used with that map though.
  • Oh! In the immortal words of Emily L. "Never mind." (Was it always this way? I clearly remember reading somewhere that there were no labels in scripts. Maybe it was from another macro language and I carried it over.) This will make things very convenient, particularly when using the MULTIFILESCRIPT command.
  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    Not sure, but as far as I know, this functionality hasn't been touched. I am at work, so I don't have CC2 here to test right now though.
  • 29 days later
  • Two interesting points I recently discovered/realized:

    1. Macros used in Drawing Tools are stored as script files in the same folder with the same name as the tool and the extension ".dtm". I find them (and other macro/menu/script files) easier to edit using an external text editor with syntax highlighting for macro commands. I extracted a comprehensive list of all macro commands from the Tome of Ultimate Mapping's spreadsheet to set up the highlighting in TWO editors. (I'm attaching the zipped UDL [.xml] file for Notepad++ for anyone who is interested.)
    2. If modifying menu and macro files seems a little extreme for a personal utility function (particularly if these changes will be lost after the next update), calling a script file from a temporary hotspot on the map you are working on may be a reasonable alternative.

    I hope someone finds this useful.

Sign In or Register to comment.