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 : MMEdit - #REPLACE Pi-cromite ESPBasic
Page 1 of 2 | |||||
Author | Message | ||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
I use MMEdit for all my programing and would not be without it. I have written a utility that adds a few things others might find useful. I initially wanted a #REPLACE directive so I could use long meaningful variable and routine names in the initial code but have short name replace these at load time. e.g. #REPLACE longname shortname This can result in saving in flash used to store the code and faster execution. @TassieJim allows MMEdit to call an external program at Load and Run so I have written a utility program in PureBasic called MMReplace.exe which implements the #REPLACE directive before MMEdit loads the code. Using a number or #REPLACE directives in some code I an developing on an MM I have gone from 4K 6% free to 15K 25% free flash.e.g. This example below shows an increase in execution speed LIBRARY MANAGEMENT To fit the code I was working on into an MM I needed to use the library. I resisted as long as I could as I like to see all the code in one file. This was the trigger for the #LIBRARYSTART, #LIBRARYEND and #LIBRARYLOAD directives. These allow the library code to remain in the main file bounded by the two directives but to only load when the #LOADLIBRARY directive is active. This simplifies maintaining the library code and loading/refreshing it when required. This means you can place a big part of your code in the library but still see it while developing. This means the code you load each time is smaller and loads quicker while you are developing. You can adjust what you want in the library when you finish development. PI-CROMITE Then came the Pi-cromite. I found you can reliably paste the clipboard into Putty and load code into the Pi-cromite. This lead to the #PI_CLIPBOARD directive which tells MMEdit to put the code into the Clipboard instead of trying to load it when a matching pi-cromite syntax file is selected. ESPBASIC ESPBasic can also have code pasted via the browser so the #ESP_CLIPBOARD directive was added along with an ESPBasic syntax file, so MMEdit can be used to edit your ESPBasic code. ARRAYS Stored in CFUNCTION/CSUB @Nathan has posted about his simpleArrayFuncGen program which allows static array data to be stored in Cfunction/Csub instead of populating an array using the traditional DATA and READ commands. simpleArrayFunctGen forum post http://www.thebackshed.com/forum/forum_posts.asp?TID=10253&PN=7 I have added some directives so that the config file for simpleArrayFuncGen can be included in the main file and simpleArrayFuncGen can automatically be called to generate the Cfunction/Csub during Load and Run. #ARRAYSTART, #ARRAYEND , #ARRAYINCLUDE and #ARRAYGENERATE directives control this. DOCUMENTATION and INSTALLATION The attached pdf explains in more detail and the zip file contains the files required and installation instructions. 2018-04-13_103421_MMReplace.pdf 2018-04-13_103504_MMReplaceDistribution.zip Thanks Jim for MMEdit, Regards Gerry Latest F4 Latest H7 |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5906 |
This looks like a very useful option when you are pushing the 'mite memory to the limit. I have deliberately avoided a global replace function so far - it can be dangerous. I have been giving a lot of thought to the syntax files. As the number of devices and versions of MMBasic increase, the existing method of one file for each variant gets difficult to keep up with. I am planning on having a master syntax file for each version and extract the syntax for the device 'on the fly' when you select the device. I will make sure that it is backward compatible with the extras such as your ESPBasic syntax file. It will be a few weeks before I get a chance to play with your offering. Jim VK7JH MMedit MMBasic Help |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
@TassyJim Is it possible to actually have a directive(s) within MMEdit so that on a Crunch & load, it will ignore a block of code as it does for Comments? In that way, library files etc could be placed be within the main program for reference & not lose the pretty colours as you do when commented out. Just thinking ChopperP |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5906 |
That is one of the things that Gerry's solution does. Jim VK7JH MMedit MMBasic Help |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
Hi Jim I did sort of gather that but I found bit hard to follow. Will have another read of his descriptions etc. Reread & found the #ENDCODE directive, but still hard to follow. I thought that there could be something simpler like putting a "#" in the program & MMEdit ignoring the following code like it does a "'" without his prog. Will have a play & see if I can get Gerry's prog to work Thanks ChopperP |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
OK, got #ENDCODE working (after I put in the /* & */) on my CMM. Not quite as hard as it looked. I assume however that the LIBRARY directives will NOT work with the CMM as they are firstly loaded onto the SD card. Is this correct or is there a workaround? Thanks EDIT Probably the comments working rather than the #ENDCODE but still does what I want for this bit. ChopperP |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
Check you have the #ENDCODE starting in column 1. The library directives also need to start in column 1. They should just exclude the enclosed code when you Load and Run. #LIBRARYSTART code here not loaded. ... #LIBRARYEND I haven't played with a CMM so not sure how you load its library.However if you have a #LIBRARYLOAD directive before the other Library directives then only the enclosed code is loaded. Would a modified #LOADLIBRARY directive such as #LOADLIBRARY filename be of any use if it then exported the library code to a separate file so it can be transferred to the SDCard? regards Gerry Latest F4 Latest H7 |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
Hi Disco4now #ENDCODE now in column 1. Yet to be tried. Need to figure out what you are on about for the second part of above. Brain not working too good ATM. Bit of the flu I think. Understand the middle bit. Thanks ChopperP |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
I think I understand. Yes, *.lib file exports would be good. ChopperP |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
I have now allowed the #LIBRARYLOAD to take an optional filename parameter. i.e #LIBRARYLOAD filename If this extra parameter is found it will be assumed that a separate library file is to be generated with the code bounded by the #LIBRARYSTART/#LIBRARYEND directives. The .lib extension will be added if not supplied. It will be placed in the same directory as the current .bas file. My understanding is that you would then use MMEdit to xfer it to the SDCARD. As a side affect the code would also be load into the Maximite so you would have to reload again after you comment the '#LOADLIBRARY directive to load the main code back into the Maximite. I have also relaxed the requirement for directives to start in column 1. They still must be first thing on the line other than spaces. The attached zip contains only the update MMReplace.exe file. If this is successful/useful I will update the documentation and re post the whole package. 2018-04-14_213913_MMReplace.zip Regards Gerry Latest F4 Latest H7 |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
That's great Gerry. Much appreciated. Will test tomorrow. May need to comment the Main prog out as the CMM will try to run the uploaded *.bas file & probably crash (or turn off RUN after load which is not a problem) ChopperP |
||||
Paul_L Guru Joined: 03/03/2016 Location: United StatesPosts: 769 |
Excellent work Gerry. You have almost implemented a precompiler and library linker for MMBasic! If it can be integrated in MMedit somewhat tighter it could develop into a really good IDE, an honest to goodness Integrated Development Environment. SHADES OF VISUAL STUDIO!!! Keep this thing going. The improvements in resident code size, operating speed and development speed will be enormous. Paul in NY |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
Hi Gerry Sorry to say the prog didn't work at all. Just ignored everything. Noticed that it is only half the size of the first one. ChopperP |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
@TassyJim I noticed that the TEMP.BAS file disappears from the MMEdit working directory after being uploaded to the CMM. I wanted to check what was actually being sent to CMM without stopping it & using MM File. Any chance of a COPY to the CMM, rather than a move pretty please? ChopperP |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
Sorry wrong one. Try this. 2018-04-15_105045_MMReplace.zip Latest F4 Latest H7 |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
Hi Gerry. Sorry to say it didn't work with the #LIBRARYLOAD filename directive. MMEdit just loads the file as TEMP.BAS into the CMM. No saving to the directory. Code snippet below. I think it is correct #LIBRARYLOAD Start01.lib #LIBRARYSTART Sub Start_01 dim T(10) end sub #LIBRARYEND ChopperP |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
Your code snippet is correct. It created the file for me. Is the Run External Command thing checked. I checked the uploaded file and I have given you the correct file this time. Also if you put a debug.txt file (or rename debugXXX.txt in directory where mmreplace.exe lives it will pause so you can see the the console output before it closes. You need to hit enter to continue. Regards Gerry Latest F4 Latest H7 |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
I get this..Can't see a file though C:\Program Files (x86)\CCom\MMReplaceDistribution\debug.txt found - verbose mode Passed Parameter=C:\Users\Owner\Documents\CMM Working\temp.bas Array Executable=C:\Program Files (x86)\CCom\MMReplaceDistribution\simpleArrayFuncGen.exe Directive #LIBRARYLOAD found #LIBRARYLOAD Start01.lib Directive #LIBRARYSTART found #LIBRARYSTART Directive #LIBRARYEND found #LIBRARYEND TotalLines= 0 Total #REPLACE = 0 Press return to exit ChopperP |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 844 |
Can you check there is only a single space between #LIBRARYLOAD and Start01.lib in the directive #LIBRARYLOAD Start01.lib It currently cant handle more than one space or a TAB here. Latest F4 Latest H7 |
||||
Chopperp Guru Joined: 03/01/2018 Location: AustraliaPosts: 1032 |
TBS Connection playing up. Keep losing my posts. Space OK. Noted adding your MMReplace file removes the /*...*/ sections from the Basic file. Undo brings it back. If LIBRARY directives are in place (with or without the filename) & then I click on Advanced, Run External Prog, MMReplace removes everything apart from the Library file. This file can then be saved as a *.LIB file ready to be uploaded to the SD card. The original file has to be reloaded of course. This is a good compromise. Happy with that. Maybe, that's what I supposed to be doing anyway. Now to see if this will post (preview works) ChopperP |
||||
Page 1 of 2 |
Print this page |