In Part 1 of our Exploring CMac Series, we covered some supporting macros for the Delimited String Editing
Dialog we are developing. In Part 2, we will be working on creating the dialog itself. There will be more
articles to follow that will continue where the previous article left off. So keep reading and when we are done, we should have a nice set
of macros that can be used in your own macros.
Now, on to the article...
We have a good start on our set of library type macros but to this point we don't have anything that we can actually see. It is now
time to start working on the editing dialog. I find it a good practice when beginning any dialog to draw out a rough sketch of how I want
it to appear on paper.
Next, since we don't currently have a dialog designer, we will write code to create the dialog. During my process, I like to see
things as quickly as possible, so I usually write some code, compile it, and then run it to see what I get. I repeat these steps many times until
I have the dialog showing they way I like it.
The basic dialog we want will have a list box. This list box will contain the list of strings, a text edit field to allow entering a
string, a couple of buttons to move a string up/down in the list box and a few more buttons to replace/add/delete a string in the list box.
Also, there will be an OK, Cancel and Help button for the main dialog.
At this time we will be adding all of the macros to the same file used in Part 1. Doing this will make it easier
to develop for in the future we might move some of the macros into another macro file.
We will call the main edit dialog macro "EditDelimitStrDlg." It will need to pass the "delimited
string" and the delimiter character and then it will need to be returned to the edited string. For testing purposes you will want
to run this macro from the "Macro Run" dialog so we will add Parse_Str function calls to the definition. These will more
than likely be removed in the final version of the macro.
Thus the prototype for this macro is:
str EditDelimitStrDlg( str InputStr = Parse_Str( "/S=", MParm_Str ), str Delimiter = Parse_Str( "/D=", MParm_Str ));
Enter the above code into the StrTools.s file and start adding the supporting code to it. Knowing that we will need
to create a window to hold the list of string, we add code to create a window.
Since we are also going to be switching between windows, we want to save the id of the current Window and the Refresh system variable so
that we can restore it back to the value it was before we entered our macro. Then we can enter code to set Refresh to False. I then
compile the code to see that it compiles and runs.
The next step is to create the dialog and test that it works.
I start by creating a simple dialog that contains a Cancel button so that I can test that the dialog can be shown and cleanly
closed. To use the dialog macro we need to #include Dialog.sh, which we insert toward the top of the file. We will
#include a number of other *.sh files to get access to the other macros we need to use.
Once the basic dialog code is written I compile it and test to see that the dialog is shown and the Cancel button closes the dialog. We
continue to add controls such as the list box, the other buttons etc. Compile and test the macro after each control is added. This
allows us to fine tune the placement of each control as it is placed in the dialog.
At this point, we should have a dialog that appears as below but doesn't do much else.
Below is a link where you can download the updated code to show the dialog.
http://www.multieditsoftware.com/TheDev/article-files/CMacCODE-part02.zip
In the next article installment we will add more functionality to the dialog.
Possibilities are limited only to your imagination and development needs!
Until the next Newsletter...
Happy Coding!
L. Dan Hughes, VP/CTO
Multi Edit Software, Inc.
danh@multieditsoftware.com
Input Your Suggestions in the
Forum:
http://www.multiedit.com/forums/viewforum.php?f=7
**Please note that you can review/search through all forum topics, but to
submit a post you must create a login identity.