September 23, 2011 at 2:35 am #2798
I do a lot of search and replaces within macros, sometimes with reg exps and sometimes as literal. I am currently working on a macro which is seeming to be a little flaky. Multi Edit seems to be ignoring the flag passed to the find_text fuction. e.g.
// put all anchors on a new line
while ( find_text(‘<a’, 0, _regexp))
is merely inserting ‘$’ in front of my anchors rather than moving them to a new line. Putting ‘Reg_Exp_Stat=1’ before this code results in it executing correctly (on my computer, not on my co-workers). However, after using ‘Reg_Exp_Stat=1’, I then try and do a literal search and replace (passing 0 as a flag to find_text) and it then does a reg exp replace. So:
results in the ‘$’ being interpreted as a newwline. Infuriating.
I have not had this problem before so i am wondering if it is due to the fact that the files I am processing contain lines that are 15800+ characters long (i.e. max length).
Regardless, can someone explain to me the interaction between Reg_Exp_Stat and the _regexp flag? Does one override the other? Are there any other factors that would make their behaviour unpredictable? Code that runs fine on my machine requires modification on a co-workers machine. We are all running ME 11.00.00
Also, assuming the line length is the root cause of my problems, is there anyway to force ( from within a macro) a newly loaded file to word wrap?September 23, 2011 at 1:38 pm #9116Clay MartinKeymaster
Have you tried using _RegExp (with correct capitalization)?
Also you may want to consider capturing Reg_Exp_Stat in a temp variable, change it to what you want (0) then reassign the old value afterward. This practice helps accommodate different settings on user’s Multi-Edit configurations.
Also are you turning Refresh off before you start the search and replace, then back on afterward. This may make the difference with your large file/line length.
Hope this helps,
ClayOctober 5, 2011 at 1:07 am #9122
Capitalisation of _regexp : No, I have never used the capitalised version of _regexp, and have never (till now) had problems. In fact, a quick search of my macro source code folder shows I have used _regexp (non-capitalised) a total of 1155 times within 111 source files, never with a problem, so I think capitalisation is not an issue.
Turning Refresh off: are you suggesting that disabling "refresh" has an effect on how Multi Edit implements regular expression search and replaces?October 5, 2011 at 6:55 pm #9118Clay MartinKeymaster
I mentioned setting refresh because you indicated that you were doing this on large files/lines and refreshing the display eats up resources.
I’ve looked back over your original post and I think we should try upgrading you to the latest version of ME 11. Follow the following link to download ME11.04.
You may be encountering a bug that was fixed.
I do not understand why a macro would work differently on two machines. Are they the same operating system?October 6, 2011 at 2:12 am #9121
I work for a large government department so all of our workstations are identical, which leads me to believe the different behaviour in macro execution comes down to our indivdual settings within ME (e.g. block editing options). Our systems are all rather outdated though we will be moving to Win7 soon so hopefully this will iron out some issues.
As for upgrading to ME11.04, getting new software installed around here is a major issue so we are likely to wait until your next major version is released (ME 12?).
In the meantime I have taken to setting REG_EXP_STAT appropriately prior to a search and replace rather than depending on the _regexp flag (though I set the flag appropriately also). This seems to have resolved my issue, though I am still unsure how these two settings (Reg_Exp_Stat and _regexp) are supposed to work together, or why this has become necessary only when processing these particular files (this precaution is unecessary on any other data my macros process).
- You must be logged in to reply to this topic.