September 11, 2003 at 11:59 pm #3217BrentStrohParticipant
You’ve probably already discovered this via experimentation, but yes, you can use either syntax for a function with parameters declared as:
[code:32hb5ez5]void testsub(int iVal = Parse_Int("/I=", MParm_Str))[/code:32hb5ez5]
You can use any of the following:
TestSub /I=4 on the command map entry[/code:32hb5ez5]
Those are off the top of my head, so I suspect I’ve screwed something up, but that’s the general idea.September 12, 2003 at 12:06 am #3218Michal VodickaParticipant
sorry but your second example is incorrect. You can’t use testsub(“/I=4”) because it passes string value instead of int.
Command line syntax is just for RM command which is internally used by command map, Run macro dialog box etc. It is documented for sure, how else I’d know about it?September 12, 2003 at 2:45 pm #3219DanHughesParticipant
First the purpose of the macro_file statement is documented in the “Creating a macro source file” topic in the CMac Help file.
The “Macro command line parameter compatibility & default parameters” topic in the CMac Help file covers your other point.
The CMac Help file was written to be read from the beginning to get a overview of the CMac language any many topics that have been asked about is covered in the introductory material. The help file also serves as a “Reference” manual for the built-in functions, which is how most use it.
I agree that the CMac information is in bad need of being updated and that is why we are working on itSeptember 22, 2003 at 8:37 pm #3250
The documentation should have an example of a case statement with multiple matches executing the same code. Example:
make_message(‘three or four’);
It’s the regular C way of doing it (matching both 3 and 4), but I wasn’t sure until I searched Multi-Edit9/src for an example, since not everything about CMAC is identical to C (for example, operator precedence).
Also, the ‘right’ function doesn’t pay attention to the “Restrict Cursor” setting under TOOLS->CUSTOMINZE…->Editing. It moves the cursor beyond the end of line even if that box is checked. However, the ‘down’ function does pay attention to the “Restrict Cursor” setting, refusing to move the cursor below the EOF (End Of File) if “Restrict Cursor” is checked, but moving cursor below EOF if “Restrict Cusor” is not checked. This needs to be documented.September 25, 2003 at 1:56 pm #3268Clay MartinKeymaster
On a less technical note, some of the descriptions of features and tools available in MEW could be improved. As it stands many are overly breif and some make a feature sound like it is too much trouble to learn/setup for the perceived value.
Check out the following post:
Just a thought,
ClaySeptember 26, 2003 at 4:21 pm #3270
Add a chapter on how a Multi-Edit macro can call a user written external dll function written in whatever language is currently popular (C, C++, C#?) I was unaware until recently that this was possible.
Include an example of passing every type of parameter, and how to code the dll function to properly receive the parameter, and then possibly modify it. Example:
int i = 12;
real r = 3.14;
q = mydllfunc(7,i,r,s);
give an example of some C++ code that would receive these parameters, change i to 13, change r to 2.17, and do something with string s.
The string s is the biggest unknown. Is it an ASCIZ zero-terminated string, where the end of the string is marked by a 0x00 byte? Or is it an ASCIC string, where the first word, or byte (which is it?), gives the length of the string? Can our C++ code allocate memory for a string to return as s? Or do we need to create a string array s of sufficient length in the CMAC code, and pass that along with the length as an extra parameter? So many questions that could be quickly answered by an example. How to return a value for q? What if q were defined above to be a string instead of a real, how would you code the C++ to return a string?
A simple example of calling a system dll I was given a few weeks ago:
import void Sleep( DWord dwMilliseconds ) Kernel32 ‘Sleep’;
void Test( )
Function: Test the Sleep Window API
Entry : None
Exit : None
Author : Dan Hughes
Copyright (C) 2003 by Multi Edit Software, Inc
*******************************************************************( ldh )***/
Make_Message( ‘Sleeping now…’ );
Sleep( 1000 );
Make_Message( ‘Finished Sleeping’ );
} // TstSleepSeptember 30, 2003 at 10:04 pm #3303
The CMAC help file documentation for function ‘Goto_Line’ gives an example of calling macro ‘GoToLine’ which doesn’t work.
As far as I can tell macro GoToLine does not accept any parameters. CMAC gets unhappy and reports “Macro or Macro file “GOTOLINE(5″ NOT found in C:Program Files\Multi-Edit 9\ nor C:Program Files\Multi-Edit 9\MAC\” when the above line is executed.
The function ‘Goto_Line’ apparently has a bug, or the screen updating has a bug, in that a call to Goto_Line moves the editing point but not the cursor. Example:
Make_Message(‘Current line=’ + str(C_Line));
Bind this to a key, turn on line numbers, press that key, the message says “Current Line=22” but the cursor does not move. Clicking on the “Save File” icon causes the window to be properly updated and places the cursor on line 22, or switching back and forth between windows also fixes things up, or adding a ‘Redraw;’ statement after ‘Goto_Line(22)’ seems to fix things. I suggest either fix the bug or document that a ‘Redraw’ statement is necessary to get the cursor back on top of the editing point.October 7, 2003 at 1:01 pm #3322Ken WalkerParticipant
Now this is the kind of information I was hoping to get from users. Thanks to everyone for posting and keep up the good information!
Every topic that’s been posted will be covered. And rest assured, I intend to expand the current documentation by providing lots of actual code samples. I know for me, when learning a new language, sometimes example code is all I need for the concept to sink in. I will be providing in depth descriptions of procedures and functions also.
Thanks again!October 15, 2003 at 4:45 am #3357
I need more information about function ‘Read_Key’. The current example in CMAC help appears to be wrong (possibly this example was once correct for DOS CMAC and no longer correct for CMAC for Windows?):
Read_Key; /* Get keycode */
/* If Key1 == 0, then extended key was pressed */
if ( Key1 == 0 && Key2 == 59 )
Make_Message(‘You pressed F1!’);
When I press F1 I get Key1=112 and Key2=1
In Win32.sh we have:
#define VK_F1 112
so Key1 for F1 key is 112.
I’m not sure how to get the character corresponding to the key pressed.
Sometimes c = char(Key1); works, but
If I press the MINUS key – (above the letter “P” key on the keyboard), I get Key1=0xBD and Key2=1. It would make sense if Key1=0x2D (hex) since that’s the ASCII code, but I’m not sure how we get Key1=0xBD instead.
So I’m not sure how to do a simple “read a keystroke from the keyboard and if it’s a printable character key give me that character as a local string variable.”October 23, 2003 at 5:38 pm #3379
There is no mention of how to create and handle an integer array under topic “Data Types”.
Arrays are mentioned under index topic “Arrays” and “Arrays in Structures”. Apparently you can have an integer array, but you must place it inside a structure. However, if inside a structure you dimension an array as:
it is not explained if this array is from - or - or -.
Currently, experimentation is required to determine that the array is -.
It is also not mentioned if you can or can not create multi-dimensional arrays.October 24, 2003 at 12:11 pm #3381Clay MartinKeymaster
Thought I would post a link to this posed by epement. His question is about alternate keymaps but this seemed like a good time to mention the doc for doing things with mew databases, add-ons etc. could use some fluffing up. Dan had some basic stuff made up for doing add-ons, but dispite his effort it still took a lot of questions (to him) to get the process working correctly. Also many users have posted questions over the years about how (what files) to move to a new installation of MEW to restore their “configuration”. Also many users over the years (me included ) have asked about how to keep their custom menus, commands etc. intact when upgrading. (Dan and Michal have mentioned placing their db changes in a file and running that through the update macro after an upgrade)
All of this points to a need for better doc about the mew config files, how the database and update macro interact, which would include the add-on creation doc also. Tyeing the “phisical” things(menus, keys, toolbars) you see inside MEW to the actual database entries would be very useful to the novice. An expanded description of how to locate and modify db entries with a update script would be equaly important.
Boy aren’t you glad you asked for doc update requests
ClayOctober 24, 2003 at 5:33 pm #3382DanHughesParticipant
One of the features we are planning on adding in a patch release of Multi-Edit 9.10 is a settings export feature which will allow a user to export any configuration data to later be imported. The idea is to try to write “update” scripts on the export and then allow them to be put into packages which will use the normal Add-On installation routines to reinstall.
Once this is done, a user could export all of their custom setting and when a new release of Multi-Edit comes out, they would install the default version, getting all of the new feature, and then run the Add-On install of their personal packages and all of their custom setting would be added in.October 24, 2003 at 6:51 pm #3383MewUserParticipant
That sounds like a great idea!October 25, 2003 at 3:46 am #3389
I’m confused as to whether a macro with no parameters still requires a “()” in the definition or in the call. Example:
So far CMACW seems to accept both. I assume I could infer this from a careful reading of “Macro elements”. It is a question I wondered, so perhaps other new programmers to CMACW will also ask the same question.
Another broader question is how and when to use old-style parameter passing vs. new more standard parameter passing. i.e. when should I use the lengthy:
void FindFile( str fn = parse_str(“/F=”, mparm_str) )
instead of the shorter
void FindFile( str fn)
Does it slow down Multi-Edit to use the longer version above?
There’s a pretty good description under “Macro command line parameter compatibility & default parameters”. This, or a reference to this, should probably be added to the “Caveats” section since it’s a digression from standard C.November 3, 2003 at 10:57 pm #3421
Many languages define a MIN and MAX function.
In C it’s common for a programmer to define one for himself as:
#define MIN(a,b) ( ((a) > (b)) ? (b) : (a) )
#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
How to achieve a MIN & MAX function in CMAC could be discussed. Whether or not CMAC supports a C-like conditional expression operator “?” could be discussed. (Perhaps MIN & MAX functions could be added to a future release of Multi-Edit.)
- You must be logged in to reply to this topic.