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 : Regular Expressions
Page 2 of 2 | |||||
Author | Message | ||||
damos Regular Member Joined: 15/04/2016 Location: AustraliaPosts: 63 |
Thanks for this Gerry. I will give it a go. When I have used regex on C# and Python I have not needed to use a \ before the quantifiers. This will be a genuinely good enhancement to Picomite if it is small enough for Peter to include it, or supply as a C function. |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
I suspect that what you are looking for, damos, is not MMBasic. Perhaps Python on a bigger platform? As you say, MMBasic is very powerful *as a variation of BASIC*. Its true value, IMHO, is in its hardware control facilities, not data processing. I think that's true of all versions of BASIC to an extent, but particularly so for MMBasic as it was written and optimized for microcontrollers, not general purpose computers. The RP2040 is an amazing chip, but it's still a microcontroller with restricted RAM. It's a pity that's not expandable or that there isn't (yet) a version with more, but we are stuck with what there is. That means no big buffers and data tables so it's possibilities for DP usage are seriously compromised. There's no OS to farm stuff off to either. I'm very unhappy about attempting to bolt on facilities that it was never designed to handle. The underlying system isn't designed for it and you end up compromising what it's good at to end up with something that's, at best, a mediocre mongrel. I'm fine with the WebMite simply because it's a different platform, but it's highly unlikely that I'll ever have a use for one personally. If that was the only little 'mite version I'd probably move back to GCBASIC on the PIC chips. Or learn Circuit Python. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3804 |
You'd need a big reorganisation of MMBasic to get objects & collections. It will grow in size and likely slow down. Also, you'd probably need a big reorganisation of MMBasic to use FreeRTOS or other RTOS. Huge amounts of work and yes some gains. However, there's no more ROM or RAM on the RP2040 or many other available chips. The RPi people have made it clear there's likely more to come beyond the RP2040 but not when (or exactly what) so if someone wants to do the above mammoth work it could be started now. Or... and I recommend this... map (*) wanted features onto arrays and make do (probably for a few years). (*) e.g. a pre-processor and/or CSUBs. John |
||||
damos Regular Member Joined: 15/04/2016 Location: AustraliaPosts: 63 |
I tried the Regex function and it works well as Gerry stated. I also tried the INSTR function and I would describe it more as wildcard search than regular expression search. This is still very useful as it is very easy to do. I like the way the INSTR function works as it can return both the position and length of the matched string. This would support pretty much achieves everything that I need if it supported the same search terms as the REGEX function. It would be brilliant if the REGEX capability could be included into the INSTR and LINSTR functions rather than requiring a new function. This could be done by using the / markers that usually surround regular expressions. So the search parameter would work like this: "abc" returns position of "abc" in a string "a.c" returns position of a substring "a" + anything + "c" "/[0-9]\+/" returns position of any sequence of numeric digits |
||||
damos Regular Member Joined: 15/04/2016 Location: AustraliaPosts: 63 |
I have been thinking about objects in MMBASIC and I think that since the JSON function has been added the capability is already built in to the language. If you want to return a complex value from a function in C# (or Javascript) you can use dynamic objects: return new { Name: "dan", Employee: true }; In MMBASIC you could do: functionname$ = "{\"Name\": \"dan\", \"Employee\": 1 }" The caller can then use JSON$(val$,"Name") to get the name. From the example I see on page 30 on the manual (I haven't tried it yet), it looks like the JSON function actually navigates the tree as well, which is much better than the Python implementation. Setting the value of the property can be done using the improved MID$ capabilities or by reconstructing the JSON object. This capability does a long way toward basic database support as well. JSON is brilliant for storing configuration data and many small projects use JSON files as databases. In the .Net world, Entity Framework can work with JSON files directly and provide the same capabilities through LINQ that you get when using SQL Server or Oracle. |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 897 |
The info I gave above was actually tested/derived from using the INSTR function as included in the Beta6 as found in the thread below. It shows the new optional versions of INSTR and LINSTR which do what you are suggesting. PicoMite V5.07.08 betas I think what Peter gave you as the test REGEX function above is now replaced by the new optional forms of INSTR and LINSTR Gerry Latest F4 Latest H7 |
||||
Page 2 of 2 |
Print this page |