Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MMReplace - Addon for MMEdit Version 5
Author | Message | ||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
MMReplace version 5 MMReplace.exe is a utility written in PureBasic which supports the addition of several new Directives which can be used while developing code in MMEdit Version 5. It is integrated into MMEdit by calling it from within the MMEdit Action menu.The history and original MMReplace that supports MMEdit3 and MMEdit4 is found here.. MMEdit Version 5 is detailed in this TBS thread. Integration into MMEdit5 Three items are added to the Actions menu. MMReplace --> MMCC F6 This calls MMREPLACE.EXE which processes any DIRECTIVES, deletes comments, blank lines and loads the program via MMCC (Maximite Control Centre) MMReplace --> MMEdit This calls MMREPLACE.EXE which processes any DIRECTIVES and sends the code and comments back to MMEdit as a new file. Find Line No. This calls FINDLINENO.EXE which prompts for an error line no to be input, and this line is then located in the original source file, taking into account comments and directives which were not sent as part of the loaded code. (This is done via sending keystrokes an does not expect SUBs/Functions to be folded) The key DIRECTIVES See the attached PDF for full details and other directives, but here are the key directives. #REPLACE longname shortname At load time all occurrences of longname are replaced with shortname. This can save program memory when the program is loaded/stored and can give small increase in execution speed when variables are resolved, but still allow the use of descriptive variable names in the code.e.g Another use is to decrease the number of discrete variables required by using an array to store similar variables, while still allowing your code to have meaningful names. e.g. Another use is to reduce the memory taken by discrete short strings by placing them in an array which can have the string length set to < 255, while also keeping you code meaningful. e.g. #DEFINE #IFDEF #IFNDEF #ELSE #ENDIF These directives allow conditional loading of sections of the code,by branching on the #DEFINE variables set. This allows one source to be maintained and the respective #DEFINE directives uncommented to load the desired code. This can include including the appropriate 'target port\com7:115200 setting for MMCC to send to the appropriate connected device. Multiple nested #DEFINE statements can give good control over what is loaded. The one source can hold multiple test cases and these can be enabled as required. Alternate commands required by different devices can be conditionally selected e.g. #LIBRARYSTART #LIBRARYEND #LIBRARYLOAD Allows management of Library code where it is supported. #ENDCODE This directive also helps support a single source file for the project. This directive is placed at the end of the valid MMBasic code and marks the end of code to be loaded. This allows other relevant code/notes to be stored after the directive but in the same source file. e.g. associated Annex code, Arduino libraries to reference during development, other notes etc. these do not affect the load time. 'target winbasic\ autorun is a special case The winbasic\ option for the MMCC ‘target directive is a special case handled by MMReplace and is not part of MMCC. It will only work with windows. It will find an open MMBasic for Windows window and paste the code into.It will give an error message if the window cannot be found. Once the MMBasic for Windows window is found: • The code to be loaded is placed in windows clipboard • A CNTRL C is sent to stop any running program • CLS is sent via keystrokes to clear the screen • AUTOSAVE filename is sent via keystrokes to the window • CNTRL V is sent to paste the contents of the clipboard • F1 (or F2 if autorun is part of the ‘target) is sent to save and optionally run the program This should be considered experimental. Works well on my machine, but there are some timings between the keystroke up/down events which may not suit all situations. The default is 50 microseconds. The directive below will allow some tuning if keystrokes are missed. delay is the new value to be used. #WINDELAY delay The filename used to save the code is the same as the filename in MMEdit DOCUMENTATION and INSTALLATION The attached pdf explains in more detail and the zip file contains the files required and installation instructions. The PureBasic source is included, but will require a licensed copy as it uses calls to the WIN32 API and this is not availalble in the free version. MMReplace5.pdf MMReplace5Distribution.zip MMEdit5, MMCC, TeraTerm and MMReplace Interworking This diagram shows the relationship of the various components. Latest F4 Latest H7 |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi disco4now, Many thanks for the updated #REPLACE for MMEdit5, which I will run under Windows 10 on my desktop PC. I have been following the "MMReplace5.pdf" instructions that came with the 2 .exe files in your .zip download. I have added the "MMReplace" and "findlineno" .exe files to the C:/Program Files/MMedit5 folder, but am confused about the rest of the installation. The "notportable.inf" file in the C:/Program Files/MMedit5 folder, only has the line :- "This file indicates that the installation is "Portable" !!! I don't have an "MMEdit.inf" in the C:/Program Files/MMedit5/Data folder for the Action Options. I don't have a C:/Users/username/AppData/Local/MMedit5 folder for data, ( In my case presumably "C:/Users/Paul/AppData/Local/MMedit5".), so I have no file to place or replace the [External programs] data in. As a trial I have edited in the list of # directives into the "Micromite_Plus.tkn" file in the C:/Program Files/MMedit5/Data folder, but they are not highlighted yet when editing an MMBASIC program. ( Syntax selected as "Micromite Plus".) Please could you provide me with some further guidance to get your very useful directives up and running ! With best regards, Paul. Nothing so constant as change. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
If you are running the installed version of MMEdit rather than portable, you can find your data folder by Help/about in MMEdit. The actual path will depend on the name you were logged in as when installing MMEdit. MMEdit looks for the existence of the 'portable.inf' file in the program folder to know that it is a portable installation. It doesn't look at the contents of the file, just that it exists. The file 'notportable.inf' serves no purpose. It handy for me to leave there to make it easy to convert from installed to portable. The C:/Program Files/MMedit5/Data folder is there as a backup for the data installed in the true data folder found in Help/About Jim VK7JH MMedit  MMBasic Help |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi TassyJim, Thanks for your reply. The Help/About gives the Data folder at "C:/Users/Paul/AppData/Local/MMedit5", but this folder doesn't exist on my system !! ( I am the only user of this system.) With best regards, Paul. Nothing so constant as change. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
In windows explorer, select View/Show/ show hidden files. While you are there select show file extensions. That's for W11, I think W10 has the options in the same location. When you find it, put the extra directives in a file named user.tkn instead of adding them to the other tkn files. That way, they won't get lost with any updates. Jim VK7JH MMedit  MMBasic Help |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi TassyJim, You are spot-on with the "Hidden" files - box now ticked. ( I do know about the existence of "Hidden" files but the penny didn't drop this time !!) The [External] substitution has now been made, and the "Action" list is complete. I have added the extra directives into a "User.tkn" file, but selectiing it from the Syntax tab doesn't have the expected effect. I anticipated that just the added directives would be highlighted in this case, but that doesn't seem to occur. (My User.tkn file doesn't have the 2 heading lines of a version number (?) and a "mmdeviceoptions " number other .tkn files have.) I have added the directives into the individual .tkn files, which seems to work OK. I updated the .tkn files in both the Data and Program folders for completeness. It was somewhat of a challenge getting round the Administrator priveledge required to edit a file in a "Program files" folder. ( Not sure why I don't have that !) I set the default Action in the "Preferences - External programs" to "Ext1 = MMReplace --> MMEDIT", then accidentally tried to index <0, and found that this corrupted its [External programs] entry in the "MMEdit.inf" file to the "Ext0 = MMReplace --> MMCC" setting. ( There was now 2 of those.) Daft thing to do, but thought you might like to know ! Testing "Crunch" now has an unfortunate effect on #REPLACE spacing characters, resulting in no #REPLACE action :- #replace Fn$ G$(1) ' Function Crunch'ed becomes :- #replace Fn$G$(1) not :- #replace Fn$ G$(1) Or :- #replace Prm_Tch_Chng.F% 0 ' Flag Crunch'ed becomes :- #replace Prm_Tch_Chng.F%0 not :- #replace Prm_Tch_Chng.F% 0 The "Program" tab sequence "Remove comments" - "Remove indents and trailing spaces" - "Remove blank lines" has the desired effect for #REPLACE to work. With thanks to you and disco4now, Paul. Nothing so constant as change. |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
I think you may not have the latest MMEdit5 file. Jim did fix the Preferences - External programs" to "Ext1 = MMReplace --> MMEDIT", then accidentally tried to index <0 thing in latest versions. The appending of the user.tkn was also only added in the later versions so would also explain why it did not seem to work. I will update the install instructions to include Jim's tips above next update. Regards Gerry Latest F4 Latest H7 |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
The current version of MMEdit shows the user.tkn file in the menu list. This is actually a bug that has been squashed and will not appear in the next update. As long as the user.tkn file is in the data folder, it will get added to all lists - provided a flag has ben set. This flag is Allow user keywords = 1 in mmedit.inf and should have defaulted to true. 1 = true, 0 = false.Eventually, I will put setting that flag into "Preferences", but not yet. If you do look at the mmedit.inf file, remember to do so with MMEdit shut down. The file gets updated when you close the program down so any changes you make while MMEdit is running will be lost. Jim VK7JH MMedit  MMBasic Help |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi disco4now and TassyJim, I have MMEdit5 v5.0.0 installed from <www.c-com.com.au/MMedit5.htm> on the 12-Jul-22, which I believe to be up-to-date ? Is there any possibility of having a look at the over-enthusiastic "Crunch" effect on the #REPLACE parameter spacing corruption ? Thanks for your work, with best regards, Paul. Nothing so constant as change. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
There have been many updates since 12th July. The only thing I can do is ignore lines starting with #REPLACE and perhaps other directives. I will give it some thought. Jim VK7JH MMedit  MMBasic Help |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi TassyJim, The 3-part sequence described above was successful as an alternative to Crunch :- "Program" tab sequence "Remove comments" - "Remove indents and trailing spaces" - "Remove blank lines" and had the desired effect for #REPLACE to work, as a possible fix ? With best regards, Paul. Nothing so constant as change. |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
MMReplace version 5 Update The PDF has improved installation instructions and updates to take into account MMEdit5 updates. The MMREPLACE.exe now supports #INCLUDE directive to allow loading include files and takes into account changes/improvements to MMEdit5. e.g. 'comments allowed at start of 'target line. All files are in the zip attached. MMReplace5.pdf MMReplace5Distribution.zip This is my newfile.txt that is added when I open a new file in MMEdit. I just uncomment the desired #DEFINE to connect to the various devices. Latest F4 Latest H7 |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Haven't tried this yet but it looks really cool Many thanks indeed Craig |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
Gerry, I changed the way 'newfile' is treated. It is now saved in the inf file. I had limited it to 10 lines. I can easily raise that to 50 or 60 lines and will include that in the next update. After that the only difference for you is - blank lines will be skipped and effectively removed from the new text. A single ' is enough to keep the spacing. To make things easier for users who can't find the data folder, I am adding a menu item to save a copy of their inf files to any location. They will be a backup for their use and something to send me for fault tracing. The first lines in the inf files now contain the data folder location, just the same as the help/about menu. It might help you help users of your add-on. Jim VK7JH MMedit  MMBasic Help |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
Hi Jim, I was wondering how I deleted those lines, could not remember doing it. 60 lines should be good. The newfile.txt is open/locked when MMEdit is open, and can't be opened elsewhere or as a file from within MMEdit. Not sure if this is intentional or its just not being closed after it is read. Regards Gerry PS. Blank lines as the start of the file (two here) result in less lines being stored as the key for the line in the inf file being incremented so that New file line1 = New file line2 = are not in the inf file as it starts at New file line3 = e.g. [New File Text] New file line3 = '========================================================= New file line4 = ' Set the #DEFINE to get the corrected target for MMCC New file line5 = '=========================================================== New file line6 = '#DEFINE F4MICK 'ARMMITE F4 with ER 5" Display COM7 New file line7 = '#DEFINE F4IPS 'ARMMite F4 with SPI LCD COM11 New file line8 = '#DEFINE H7P144 'Armmite H7 144 Pins COM8 New file line9 = '#DEFINE H7P100 'Armmite H7 100 Pins COM10 New file line10 = #DEFINE PICO 'PicoMite COM14 Edited 2022-09-10 08:26 by disco4now Latest F4 Latest H7 |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
New file text is now retained internally once read from the inf file. To edit it, start a new file, edit then 'save new intro' It was hard limited to the first 10 lines of the file. I have changed it to not skip line numbers when writing to the inf file (which only happens when you close MMEdit) Update will be this afternoon, hopefully. Jim Edited 2022-09-10 08:44 by TassyJim VK7JH MMedit  MMBasic Help |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
»»»»» MMReplace -New Features ««««« ■Now available for Linux ■Now embeds Picomite PIO Assembler (PIOASM) See Picomite PIO Assembler thread for details of its use. Linux install files. MMReplace5LINUX.zip Windows install files. MMReplace5Windows.zip Note: These files updated on 19th Jan 2023. If you have previously downloaded them before this date please download again. Contains revised install instructions to minimise the risk of overwrite any existing items in the Action menu. The new MMReplace for Windows and Linux has a number of fixes. Also for 19th update. .nostart directive fixed, previously corrupted the output Source now also in the Linux file. Note: Source is not required.Provided for anyone curious to see it. Edited 2023-01-31 14:29 by disco4now Latest F4 Latest H7 |
||||
Print this page |