WISHLIST: New Macro Commands I'd like to see
DaltonSpence
Mapmaker
There have been a lot of new commands added to CC3+ lately so I thought I add my own suggestions to the list.
ASK3BOX
- Similar toASKBOX
this command creates a dialog box with three buttons; “YES”, “NO” and “CANCEL”. Would be used with another new commandGETA3RETCODE
to get more options out of query:- 0 - “Yes” button was clicked.
- 1 - “No” button was clicked.
- 2 - “Cancel” was selected by either clicking the “Cancel” button, the “X” in the upper right hand corner of the dialog or pressing the “Esc” key.
- 3 - Command failed for another reason.
NOTE
Commands - Until the recentOPENNOTE
command the only way to use map notes was through the “Select Note” dialog (NOTES
command). It occurs to me that the text stored in map notes should be usable in other ways. These new commands can manipulate map note in a variety of ways. TheIFERR
command can be used to check if a new note already exists or an old one does not.ADDNOTE
- Creates a new note using theMSGBOX
syntax.APNDNOTE
- Adds text to an existing note using theMSGBOX
syntax. Could be used to log map activity and revisions.ASKNOTE
- Creates anASKBOX
dialog using the note name as the title and note content as the text.ASK3NOTE
- Creates anASK3BOX
dialog (see above) using the note name as the title and note content as the text.CLRNOTE
- Deletes the contents an existing map note without removing it.DELNOTE
- Deletes an existing map note by name.EDITNOTE
- Edits an existing map note by name using the “Edit Text” dialog.MSGNOTE
- Creates anMSGBOX
dialog using the note name as the title and note content as the text. For those who prefer message boxes to text windows.NEWNOTE
- Creates a new note using the “Edit Text” dialog.RUNNOTE
- Runs the macro code contained in the named note as per “OnNewMacro” and “OnOpenMacro” notes. An alternative to using macros or script files.TEXNOTE
- Same as theTEX
command except it preloads the content of the named note in the “Edit Text” dialog to be placed on the map.
TXTWINCOLOR
- I don’t like the “white on blue” color scheme of the text window. This command would let me set the foreground and background colors to any on the palette.COPYWIZ
- This command would create multilevel copies of the current map as per the last dialog of the “New Map Wizard”. This way one wouldn’t have to manually copy details of a building layout and its environs from one level to another. As a possible enhancement, instead of placing a list of map links on the maps taking up usable area, a context menu could be made that would be called from a clickable hotspot underneath (or possibly including) the level name. All files would be placed in the same directory as the current map by default unless otherwise directed.
Comments
Have you considered writing them yourself though? Writing XP's can be a bit arcane compared to many modern API's, but it is also a lot of fun. Not sure how easy the TXTWINCOLOR would be to implement by a third party without having support in the core code, but the rest of the commands should be implementable as an XP.
TXTWINCOLOR
was doable (the colors just remind me of the BSoD) and most of the documentation on writing XPs seems rather out-of-date (back to CC2 for most of it). I'm not the programmer I used to be (I feel like a dinosaur at times to be honest) and writing macro code is about my speed these days (I've already written the data collection part of aCOPYWIZ
macro but I'm stuck on the map copying/altering part) but most of the recent new commands seem to be hooking onto existing features of the program. For exampleOPENNOTE
basically emulates clicking the "Ok" button on the “Select Note” dialog (NOTES
command).DELNOTE
,EDITNOTE
andNEWNOTE
commands could be written similarly. These ideas inspired a 3 AM bout of insomnia so if they seem a bit out there, that's why.Snap
(only mine is usually about drawing something)
1. I'm speaking french. "The commands should be implementable as an XP.". What does XP stand for ? I'm guessing your speaking about macros… but what does the term XP mean ?
2. I checked a lot of tutorials (to learn the syntax and the various command), but can you point me to a tutorial or a reference where the creating of an UI dialog is explained ?
It's a CC3 add-in ( https://cc3-developer.blogspot.com/search/label/Campaign Cartographer 3 )
A graphical dialog needs to be implemented as an XP too. It can be implemented as a regular Windows SDK dialog if you know how to make those. There are other ways too, but that is the way I know.
I'll check all this… and will try to make something!
I suppose sou mean in C++ ?
Can I ask you in which application you're coding XPs ? I downloaded Visual Studio 2017 but wasn't yet able to include the fastCAD32 SDK...
To include the fastCad XP toolkit, edit your project properties and under the C/C++ --> general heading, add
C:\FCWXP\xpdev;
(change to fit your own directoriy paths obviously) to the beginning of the Additional Dependencies line.Then, in the Linker --> Input heading, add
C:\fcwxp\xpdev\fcw32.lib;
to the beginning of that Additional Dependencies line.That should be all that is required. Personally, I also like having it copy the output (.dll) file directly to my CC3+ installation directory and call CC3+ when debugging, instead of manually copying in the file each time, but that is not required to build a working setup.
--> no luck
--> no luck
Notice that I also tried your XP. I must do something wrong, because CC3+ doesn't recognize your XP too...
Now it's time to code something - or to try
By the way, can you confirm that it's necessary to use the Visual Studio 2010 toolset ? Or is it possible to use the VS2017/Windows 10 toolset ?
But if I change the Platform Toolset to VS2010, it works correctly !
And another question… In the GETA3RETCODE, I would like the function to return a value, so a MACRO code could get the answer of the ASK3BOX. Is there an example somewhere explaining how to "expose" the value ?
Exposing a variable to a macro is done using
SetVar(char *pLabel, char *pValue);
I have some logical problem here… I'm not sure to understand the way it should work.
I have a XP that is (partial code):
void XPCALL ASK3BOX(void) { int RETCODE; RETCODE = CancelBox("Questions which can by answer by YES, NO or CANCEL"); char *RETVALUE("GETA3RETCODE"); char *VALUE("0"); SetVar(RETVALUE, VALUE); CmdEnd(); }
The first question is…. Should I have the
SetVar
in the same function than the one raising the Yes,No,Cancel dialog ?Or should I create a separate function for the return value, like this ?
void XPCALL GETA3RETCODE(void) { char *RETVALUE("GETA3RETCODE"); char *VALUE("0"); SetVar(RETVALUE, VALUE); CmdEnd(); }
Finally… how do you get the returned value in the macro ? I tried Something like below, tried Calling GETA3RETCODE, etc...
MACRO ASKTEST GV result ASK3BOX IFZ result resultY IFP result resultN IFN result resultC :resultY MSGBOX yes :resultN MSGBOX no :resultC MSGBOX cancel ENDM
Also, I'm triying to convert the CancelBox returned value (int) to put it in the VALUE (char*)…
Sorry to ask so many things… but there aren't a lot of example available (if no example).
Again, thanks for all your help and patience
Basil
To use the value in the macro, just access the variable name you defined using setvar (the first parameter). That string will be a variable name you can access from the CC3+ macro.
Converting an int to a char array can be done using for example sprintf
This was also my guess… but as it wasn't working… I tried other approach.
Concerning the macro, here is a little test. The value in the XP is GETA3RETCODE
MACRO ASK3TEST ASK3BOX MSGBOX GETA3RETCODE ENDM
But I received the attached error… And also, the dialog (Yes, No, Cancel) is launched twice…
MACRO ASK3TEST ASK3BOX IFZ GETA3RETCODE yesno :yesno MSGBOX Success ENDM
The error you got will (among other things) happen if you forget the CmdEnd() at the end of the command, so check that one.
To check that the variable is actually set, you can issue the LISTVARS command.
If I run LISTVARS, the GETA3RETCODE is displaying correctly.
So I think the XP is working as intended.
But the macro doesn't… And I have the error above…
But if I use this extremely basic version, it is working.
MACRO ASK3TEST ASK3BOX ENDM
And LISTVARS displays the GETA3RETCODE value…
So, I believe there is something wrong in my macro...
The issue here is fastcad's way of retrieving command line data. Getting data from a command line is a bit more tricky than getting it from a dialog box (especially the fastcad model where some prompts can also be answered by a mouse click or have modifier keys, as opposed to a more "classic" command line where you just type a full command and have the program parse it only after you hit enter to submit the complete command line), and to get the command line to work properly, data input has a few special particularities.
The result of this is that the data collection continues unhindered even when your dialog box displays. This causes the next command to error out and you get some weird consequences.
This is basically the main reason that not all CC3+ commands can be used in a macro, even if they can be typed on the command line.
To fix this, you need to do things the fastcad way. This is especially important for macro commands, if your dialog was intended to be a standalone command, just having it as it is would have worked.
Here is some example code to how you could handle this
In fact, I wasn't using this:
FORMST(MyAPkt, "What do you say?\n\n" "Don't be afraid to pick one of the answers" ) int ask = FormSt(&MyAPkt, RSC(FD_CancelBox));
But I used directly the function "CancelBox".
Now, if I can ask you one last thing. Is it possible to pass a value the the XP function ? For example, the text display by the YES/NO/CANCEL dialog or even the dialog title ?
You need to have the XP request the data, this is what all the commands that require parameters do.
Here is an example (Demo() is the function called by the XP command, SayHello() is called from Demo())
ReqData requests data, and if the data is already available (for example specified in a parameter in a macro) it will use that, otherwise the user will see a prompt on the screen. (Or, if in a macro and it expects a parameter and it is missing, it will happily accept the command on the next line instead as the input, causing all kinds of errors)
I saw your new blog post. That's very nice !
May I ask already Something here ?
In the prompt you have shown (in the post above and I think in the blog post too), the request can only be one word.
But I'm trying to make the ASK3BOX - which would request two things:
1. A title (if this is possible).
2. A sentence (with spaces) to make the question.
Can you point me on how to do this ? Or will it be in the second post of your tutorial ?
Where did you learned them ? I tried to search in the Evolution Computing website (devs of FastCAD), but I can't get / find the documentation to make XPs.
If you want full sentences, you need to specify in your data request that spaces are allowed as part of the data (RDF_SPACEOK):
As for learning the stuff:
- The documentation is included with the Xp toolkit. It is far from complete, but there are lots of stuff in it.
- The .h files from the toolkit also contains lot of useful information
- I have read Lee Saunders' old tutorials, some which are no more available unfortunately
- And I ask people who knows more than me
I had already identified RDF_SPACEOK, but didn't thought to 'add' it to RDF_C. Thanks
RDF_C|RDF_SPACEOK