Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:32 25 Nov 2025 Privacy Policy
Jump to

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 : CMM2 V6.00.00 betas

     Page 3 of 4    
Author Message
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1060
Posted: 06:05am 20 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  Hope this helps

Thanks Peter.
I have managed to compile your code with the new settings. I spent a bit of time without upgrading to STMCubeIDE 2.0.0 but looks like it is definitely needed.

Gerry
F4 H7FotSF4xGT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10646
Posted: 08:16am 20 Nov 2025
Copy link to clipboard 
Print this post

  Quote  Running at the moment 15 minutes and no issues (my b7). Will leave it running overnight but I suspect the issue is in your environment SD card or PSU


Ran all night so I think we can conclusively confirm the issue is at your end

Gerry: I don't like the warning messages in re.c. Have you had a look at them - array index of -1?
Edited 2025-11-20 18:24 by matherp
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1060
Posted: 11:03am 20 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  
Gerry: I don't like the warning messages in re.c. Have you had a look at them - array index of -1?

Not to the point of trying to understand/fix them.
I am using this fork
https://github.com/gyrovorbis/tiny-regex-c
from this original
https://github.com/kokke/tiny-regex-c

They are a few years old.
F4 H7FotSF4xGT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10646
Posted: 01:29pm 20 Nov 2025
Copy link to clipboard 
Print this post

Gerry
Attached is a fixed version of re.c, this sorts the compilation warnings and also fixes a bug. Also below a test script for regular expressions, if you run it on with your original code you will get 1 fail

re.zip

' ============================================================================
' MMBasic Regular Expression Test Program
' Tests the INSTR() function with regex patterns (size parameter)
' ============================================================================

Print "=========================================="
Print "MMBasic Regular Expression Test Suite"
Print "=========================================="
Print

' Test counter
Dim testnum As Integer = 0
Dim passed As Integer = 0
Dim failed As Integer = 0

' ============================================================================
' Helper subroutine to run a test
' ============================================================================
Sub RunTest(testname$, text$, pattern$, expected_pos, expected_len)
 Local position, size
 testnum = testnum + 1
 
 Print "Test "; testnum; ": "; testname$
 Print "  Text: "; Chr$(34); text$; Chr$(34)
 Print "  Pattern: "; Chr$(34); pattern$; Chr$(34)
 
 position = Instr(text$, pattern$, size)
 
 Print "  Result: pos="; position; ", len="; size
 Print "  Expected: pos="; expected_pos; ", len="; expected_len
 
 If position = expected_pos And size = expected_len Then
   Print "  [PASS]"
   passed = passed + 1
 Else
   Print "  [FAIL]"
   failed = failed + 1
 EndIf
 Print
End Sub

' ============================================================================
' Test 1: Basic character matching
' ============================================================================
Print "--- Basic Character Matching ---"
RunTest("Simple match", "hello world", "world", 7, 5)
RunTest("No match", "hello world", "xyz", 0, 0)
RunTest("First char", "hello", "h", 1, 1)
RunTest("Last char", "hello", "o", 5, 1)

' ============================================================================
' Test 2: Dot metacharacter (matches any character)
' ============================================================================
Print "--- Dot Metacharacter Tests ---"
RunTest("Dot single", "abc", "a.c", 1, 3)
RunTest("Dot multiple", "hello", "h...o", 1, 5)
RunTest("Dot no match", "abc", "a.d", 0, 0)

' ============================================================================
' Test 3: Character classes [...]
' ============================================================================
Print "--- Character Class Tests ---"
RunTest("Char class match", "hello", "h[aeiou]llo", 1, 5)
RunTest("Char class range", "test123", "[0-9]", 5, 1)
RunTest("Char class alpha", "abc123def", "[a-z]", 1, 1)
RunTest("Multiple ranges", "Test123", "[a-zA-Z0-9]", 1, 1)

' ============================================================================
' Test 4: Inverted character classes [^...]
' ============================================================================
Print "--- Inverted Character Class Tests ---"
RunTest("Not vowel", "hello", "h[^aeiou]", 0, 0)
RunTest("Not digit", "abc123", "[^0-9]", 1, 1)
RunTest("Not alpha", "abc123", "[^a-z]", 4, 1)

' ============================================================================
' Test 5: Anchors (^ and $)
' ============================================================================
Print "--- Anchor Tests ---"
RunTest("Start anchor", "hello world", "^hello", 1, 5)
RunTest("Start anchor fail", "hello world", "^world", 0, 0)
RunTest("End anchor", "hello world", "world$", 7, 5)
RunTest("End anchor fail", "hello world", "hello$", 0, 0)
RunTest("Both anchors", "test", "^test$", 1, 4)

' ============================================================================
' Test 6: Quantifiers - * (zero or more)
' ============================================================================
Print "--- Star Quantifier Tests ---"
RunTest("Star zero match", "ac", "ab*c", 1, 2)
RunTest("Star one match", "abc", "ab*c", 1, 3)
RunTest("Star multiple", "abbbbc", "ab*c", 1, 6)
RunTest("Star greedy", "aaaaaa", "a*", 1, 6)

' ============================================================================
' Test 7: Quantifiers - + (one or more)
' ============================================================================
Print "--- Plus Quantifier Tests ---"
RunTest("Plus no match", "ac", "ab+c", 0, 0)
RunTest("Plus one match", "abc", "ab+c", 1, 3)
RunTest("Plus multiple", "abbbbc", "ab+c", 1, 6)
RunTest("Plus greedy", "aaaaa", "a+", 1, 5)

' ============================================================================
' Test 8: Quantifiers - ? (zero or one)
' ============================================================================
Print "--- Question Quantifier Tests ---"
RunTest("Question zero", "ac", "ab?c", 1, 2)
RunTest("Question one", "abc", "ab?c", 1, 3)
RunTest("Question multiple", "abbc", "ab?c", 0, 0)

' ============================================================================
' Test 9: Escape sequences - \d (digits)
' ============================================================================
Print "--- Digit Escape Tests ---"
RunTest("Digit match", "test123", "\d", 5, 1)
RunTest("Digit+", "test123", "\d+", 5, 3)
RunTest("Not digit", "test123", "\D", 1, 1)
RunTest("Not digit+", "test123", "\D+", 1, 4)

' ============================================================================
' Test 10: Escape sequences - \w (alphanumeric)
' ============================================================================
Print "--- Alphanumeric Escape Tests ---"
RunTest("Word char", "hello world", "\w", 1, 1)
RunTest("Word+", "hello world", "\w+", 1, 5)
RunTest("Not word", "hello world", "\W", 6, 1)

' ============================================================================
' Test 11: Escape sequences - \s (whitespace)
' ============================================================================
Print "--- Whitespace Escape Tests ---"
RunTest("Whitespace", "hello world", "\s", 6, 1)
RunTest("Whitespace+", "hello   world", "\s+", 6, 3)
RunTest("Not whitespace", "hello world", "\S", 1, 1)
RunTest("Not whitespace+", "hello world", "\S+", 1, 5)

' ============================================================================
' Test 12: Complex patterns
' ============================================================================
Print "--- Complex Pattern Tests ---"
RunTest("Email pattern", "test@example.com", "\w+@\w+\.\w+", 1, 16)
RunTest("Date pattern", "Date: 2024-11-20", "\d+-\d+-\d+", 7, 10)
RunTest("Phone pattern", "Call: 123-456-7890", "\d+-\d+-\d+", 7, 12)
RunTest("Word boundary", "the cat in the hat", " [ct]at", 4, 4)

' ============================================================================
' Test 13: Hex escape sequences \xXX
' ============================================================================
Print "--- Hex Escape Tests ---"
RunTest("Hex char", "Hello", "\x48", 1, 1)  ' H = 0x48
RunTest("Hex lower", "hello", "\x68", 1, 1)  ' h = 0x68
RunTest("Hex space", "a b", "\x20", 2, 1)    ' space = 0x20

' ============================================================================
' Test 14: Branch operator |
' ============================================================================
Print "--- Branch Operator Tests ---"
RunTest("Branch first", "hello", "hello|world", 1, 5)
RunTest("Branch simple", "b", "a|b|c", 1, 1)
RunTest("Branch neither", "test", "hello|world", 0, 0)
RunTest("Branch chars", "a", "a|b|c", 1, 1)

' ============================================================================
' Test 15: Quantifiers {n}, {n,}, {,m}, {n,m}
' ============================================================================
Print "--- Counted Quantifier Tests ---"
RunTest("Exact count", "aaaa", "a{4}", 1, 4)
RunTest("Exact fail", "aaa", "a{4}", 0, 0)
RunTest("Min count", "aaaaa", "a{3,}", 1, 5)
RunTest("Max count", "aaaaa", "a{,3}", 1, 3)
RunTest("Range count", "aaaa", "a{2,4}", 1, 4)

' ============================================================================
' Test 16: Real-world examples
' ============================================================================
Print "--- Real-World Examples ---"
RunTest("IP address", "192.168.1.1", "\d+\.\d+\.\d+\.\d+", 1, 11)
RunTest("HTML tag", "<div>content</div>", "<\w+>", 1, 5)
RunTest("Currency", "$123.45", "\$\d+\.\d+", 1, 7)
RunTest("Time format", "Time: 14:30:00", "\d+:\d+:\d+", 7, 8)

' ============================================================================
' Test 17: Edge cases
' ============================================================================
Print "--- Edge Case Tests ---"
RunTest("Empty pattern", "test", "", 1, 0)
RunTest("Pattern longer", "hi", "hello", 0, 0)
RunTest("Repeated dots", "abc", "...", 1, 3)
RunTest("First occurrence", "hello hello", "hello", 1, 5)  ' Finds first match

' ============================================================================
' Summary
' ============================================================================
Print "=========================================="
Print "Test Summary"
Print "=========================================="
Print "Total tests: "; testnum
Print "Passed: "; passed
Print "Failed: "; failed
Print "Success rate: "; Format$(passed/testnum*100, "%.1f"); "%"
Print "=========================================="

If failed = 0 Then
 Print "All tests PASSED!"
Else
 Print "Some tests FAILED - please review"
EndIf

End
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1649
Posted: 02:51pm 20 Nov 2025
Copy link to clipboard 
Print this post

On the topic of CMM2, I was kinda put-off by having to enter date/time etc., in the event of the battery dying. Is there an option to stop this from happening?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8315
Posted: 03:41pm 20 Nov 2025
Copy link to clipboard 
Print this post

What would keep the clock running with no battery and no network connection?  :)

Actually it's a good job it does this as the CMM2 doesn't store all its options in flash like the Picomite. It uses up to 4K of battery maintained RAM. This also holds saved variables. As you need to set the clock every 3-4 years after installation of a new battery it's not really a great problem.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1649
Posted: 05:20pm 20 Nov 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  What would keep the clock running with no battery and no network connection?  :)

Actually it's a good job it does this as the CMM2 doesn't store all its options in flash like the Picomite. It uses up to 4K of battery maintained RAM. This also holds saved variables. As you need to set the clock every 3-4 years after installation of a new battery it's not really a great problem.


The battery only kicks in when power is lost, right?

From the manual, I still haven't figured OPTION FLASH and OPTION RAM
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10646
Posted: 05:49pm 20 Nov 2025
Copy link to clipboard 
Print this post

OPTION FLASH allows you to choose a different starting position in flash for your program to allow wear levelling of flash writes. Not really needed in the real world.
OPTION RAM loads and runs the MMBasic program from RAM rather than flash. Useful during development to speed things up slightly and again reduce flash writes
NB: OPTION RAM is incompatible with profiling as it uses the same pre-allocated RAM area
Edited 2025-11-21 04:01 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8315
Posted: 06:01pm 20 Nov 2025
Copy link to clipboard 
Print this post

That's correct. However, if you have a power failure you'll lose not only the clock but any stored variables and options.

The CMM2isn't like the Pico.

AFAIK OPTION RAM is the default. The program is loaded from the SD card into RAM on boot and is run from there. On power loss the program is lost and will be restored from the SD card on the next boot.

If OPTION FLASH is specified the program is saved into FLASH and run from there. The program runs slightly faster like this. The program doesn't need to be reloaded on the next boot, it simply runs from flash.. There is more complexity as the same flash is used for MMBasic, so you have to specify where in flash you want to store the program and its length. It's fine for single job systems that aren't going to be changed very often, but the flash has a limited number of write cycles.

VAR SAVE saves the selected variables in the battery maintained RAM. As this isn't flash, as it is on the Pico, you can use this command freely with no danger of wearing out the flash. It's also *much* faster.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8315
Posted: 06:03pm 20 Nov 2025
Copy link to clipboard 
Print this post

I hadn't thought of using flash for multiple programs. I thought the issue was with pre-configured use by MMBasic. Thanks Peter. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10646
Posted: 06:05pm 20 Nov 2025
Copy link to clipboard 
Print this post

  Quote  AFAIK OPTION RAM is the default. The program is loaded from the SD card into RAM on boot and is run from there. On power loss the program is lost and will be restored from the SD card on the next boot.

Stop making things up. You will have me thinking you are an AI
FLASH is the default and RAM is the option
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8315
Posted: 06:17pm 20 Nov 2025
Copy link to clipboard 
Print this post

I did say AFAIK....  I'd have been absolutely definite (but wrong) if I was an AI.   :)

The manual (my 5.06.00 version with added 5.07.01 scribbles anyway) isn't terribly forthcoming on this matter.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 498
Posted: 07:47pm 20 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Running at the moment 15 minutes and no issues (my b7). Will leave it running overnight but I suspect the issue is in your environment SD card or PSU


Ran all night so I think we can conclusively confirm the issue is at your end


I changed the SD card, even though it was brand new. Lo and behold, it works.
I wouldn't have thought of that because there hadn't been any other problems.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1060
Posted: 10:27pm 20 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  Gerry
Attached is a fixed version of re.c, this sorts the compilation warnings and also fixes a bug.

Thanks have added.
There was one limitation in the original code for
Quantifiers {n}, {n,}, {,m}, {n,m}
I think is was OK for a single match, but got a bit mixed up if using it more than once. e.g. trying to match an IP address using them.e.g.
RunTest("IP address", "192.168.1.1", "\d{1,3}\.\d{1,3}\.\d{1,3)\.\d{1,3)", 1, 11)
I have not tested with your update yet.

RunTest("IP address", "192.168.1.1", "\d+\.\d+\.\d+\.\d+", 1, 11)

A tweak for the load script to give a bit more headroom for the code. Moves the data sections into flash7 with the .extra code.



 /* used by the startup to initialize data */
 _sidata = LOADADDR(.data);

 /* Initialized data sections goes into RAM, load LMA copy after code */
 .data :
 {
   . = ALIGN(4);
   _sdata = .;        /* create a global symbol at data start */
   *(.data)           /* .data sections */
   *(.data*)          /* .data* sections */

   . = ALIGN(4);
   _edata = .;        /* define a global symbol at data end */
 } >DTCMRAM AT> FLASH7


Edited 2025-11-21 08:28 by disco4now
F4 H7FotSF4xGT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10646
Posted: 10:57pm 20 Nov 2025
Copy link to clipboard 
Print this post

Gerry, tomorrow my time I'll post a revised version with groups pretty much fully implemented - isn't AI wonderful
> ? instr( "192.168.1.1", "\d+\.\d+\.\d+\.\d+",size),size
1       11
>

==========================================
MMBasic Regex Group Test Suite
==========================================

--- Basic Group Tests ---
Test  1: Simple group
 Text: "abc"
 Pattern: "(abc)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  2: Group at start
 Text: "hello world"
 Pattern: "(hello)"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  3: Group at end
 Text: "hello world"
 Pattern: "(world)"
 Result: pos= 7, len= 5
 Expected: pos= 7, len= 5
 [PASS]

Test  4: Group in middle
 Text: "hello world test"
 Pattern: "(world)"
 Result: pos= 7, len= 5
 Expected: pos= 7, len= 5
 [PASS]

--- Single Character Group Tests ---
Test  5: Single char group
 Text: "a"
 Pattern: "(a)"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  6: Single char no match
 Text: "b"
 Pattern: "(a)"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

Test  7: Multiple single groups
 Text: "abc"
 Pattern: "(a)(b)(c)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

--- Group with Metacharacters ---
Test  8: Group with dot
 Text: "abc"
 Pattern: "(a.c)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  9: Group with dots
 Text: "hello"
 Pattern: "(h...o)"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  10: Group with digit
 Text: "test123"
 Pattern: "(\d)"
 Result: pos= 5, len= 1
 Expected: pos= 5, len= 1
 [PASS]

Test  11: Group with digits
 Text: "test123"
 Pattern: "(\d\d\d)"
 Result: pos= 5, len= 3
 Expected: pos= 5, len= 3
 [PASS]

Test  12: Group with word
 Text: "hello world"
 Pattern: "(\w+)"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  13: Group with space
 Text: "hello world"
 Pattern: "(\s)"
 Result: pos= 6, len= 1
 Expected: pos= 6, len= 1
 [PASS]

--- Group with Character Classes ---
Test  14: Group with class
 Text: "abc"
 Pattern: "([abc])"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  15: Group with range
 Text: "test5"
 Pattern: "([0-9])"
 Result: pos= 5, len= 1
 Expected: pos= 5, len= 1
 [PASS]

Test  16: Group multiple class
 Text: "test123"
 Pattern: "([a-z]+)"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  17: Group inv class
 Text: "123abc"
 Pattern: "([^0-9])"
 Result: pos= 4, len= 1
 Expected: pos= 4, len= 1
 [PASS]

--- Group with Star Quantifier ---
Test  18: Group star zero
 Text: "b"
 Pattern: "(a)*b"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  19: Group star one
 Text: "ab"
 Pattern: "(a)*b"
 Result: pos= 1, len= 2
 Expected: pos= 1, len= 2
 [PASS]

Test  20: Group star many
 Text: "aaaab"
 Pattern: "(a)*b"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  21: Group word star
 Text: "test"
 Pattern: "(test)*"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  22: Group multi star
 Text: "ababab"
 Pattern: "(ab)*"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

--- Group with Plus Quantifier ---
Test  23: Group plus fail
 Text: "b"
 Pattern: "(a)+b"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

Test  24: Group plus one
 Text: "ab"
 Pattern: "(a)+b"
 Result: pos= 1, len= 2
 Expected: pos= 1, len= 2
 [PASS]

Test  25: Group plus many
 Text: "aaaab"
 Pattern: "(a)+b"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  26: Group multi plus
 Text: "ababab"
 Pattern: "(ab)+"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  27: Group word plus
 Text: "testtest"
 Pattern: "(test)+"
 Result: pos= 1, len= 8
 Expected: pos= 1, len= 8
 [PASS]

--- Group with Question Quantifier ---
Test  28: Group question zero
 Text: "b"
 Pattern: "(a)?b"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  29: Group question one
 Text: "ab"
 Pattern: "(a)?b"
 Result: pos= 1, len= 2
 Expected: pos= 1, len= 2
 [PASS]

Test  30: Group question partial
 Text: "aab"
 Pattern: "(a)?b"
 Result: pos= 2, len= 2
 Expected: pos= 2, len= 2
 [PASS]

Test  31: Group multi question
 Text: "ab"
 Pattern: "(ab)?"
 Result: pos= 1, len= 2
 Expected: pos= 1, len= 2
 [PASS]

--- Group with Counted Quantifiers ---
Test  32: Group exact count
 Text: "aaaa"
 Pattern: "(a){4}"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  33: Group exact fail
 Text: "aaa"
 Pattern: "(a){4}"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

Test  34: Group min count
 Text: "aaaaa"
 Pattern: "(a){3,}"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  35: Group max count
 Text: "aaaaa"
 Pattern: "(a){,3}"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  36: Group range count
 Text: "aaaa"
 Pattern: "(a){2,4}"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  37: Group multi exact
 Text: "ababab"
 Pattern: "(ab){3}"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  38: Group multi range
 Text: "abababab"
 Pattern: "(ab){2,3}"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

--- Sequential Group Tests ---
Test  39: Two groups
 Text: "helloworld"
 Pattern: "(hello)(world)"
 Result: pos= 1, len= 10
 Expected: pos= 1, len= 10
 [PASS]

Test  40: Three groups
 Text: "abc"
 Pattern: "(a)(b)(c)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  41: Groups with chars
 Text: "a-b"
 Pattern: "(a)(-)(b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  42: Groups and text
 Text: "test"
 Pattern: "t(es)t"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

--- Nested Group Tests ---
Test  43: Simple nested
 Text: "abc"
 Pattern: "((abc))"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  44: Nested with char
 Text: "abc"
 Pattern: "(a(bc))"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  45: Nested middle
 Text: "abc"
 Pattern: "((a)bc)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  46: Deep nested
 Text: "a"
 Pattern: "(((a)))"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  47: Multiple nested
 Text: "hello"
 Pattern: "((he)(llo))"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

--- Group with Anchor Tests ---
Test  48: Group start anchor
 Text: "hello"
 Pattern: "^(hello)"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  49: Group end anchor
 Text: "hello"
 Pattern: "(hello)$"
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  50: Group both anchors
 Text: "test"
 Pattern: "^(test)$"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  51: Anchor in group (limitation)
 Text: "hello"
 Pattern: "(^hello)"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

Test  52: End anchor in group (limitation)
 Text: "hello"
 Pattern: "(hello$)"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

--- Group with Branch Tests ---
Test  53: Group branch simple
 Text: "a"
 Pattern: "(a|b)"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  54: Group branch second
 Text: "b"
 Pattern: "(a|b)"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  55: Group branch word
 Text: "cat"
 Pattern: "(cat|dog)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  56: Group branch fail
 Text: "bird"
 Pattern: "(cat|dog)"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

Test  57: Multi branch group
 Text: "test"
 Pattern: "(abc|def|test)"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

--- Complex Group Patterns ---
Test  58: Email group
 Text: "test@example.com"
 Pattern: "(\w+)@(\w+)\.(\w+)"
 Result: pos= 1, len= 16
 Expected: pos= 1, len= 16
 [PASS]

Test  59: Date group
 Text: "2024-11-20"
 Pattern: "(\d+)-(\d+)-(\d+)"
 Result: pos= 1, len= 10
 Expected: pos= 1, len= 10
 [PASS]

Test  60: Phone group
 Text: "123-456-7890"
 Pattern: "(\d+)-(\d+)-(\d+)"
 Result: pos= 1, len= 12
 Expected: pos= 1, len= 12
 [PASS]

Test  61: URL protocol
 Text: "http://test.com"
 Pattern: "(https?://)(\w+)\.(\w+)"
 Result: pos= 1, len= 15
 Expected: pos= 1, len= 15
 [PASS]

--- Special Group Pattern Tests ---
Test  62: Empty group
 Text: "test"
 Pattern: "()"
 Result: pos= 1, len= 0
 Expected: pos= 1, len= 0
 [PASS]

Test  63: Optional group
 Text: "test"
 Pattern: "(test)?"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  64: Group with spaces
 Text: "hello world"
 Pattern: "(hello )(world)"
 Result: pos= 1, len= 11
 Expected: pos= 1, len= 11
 [PASS]

Test  65: Group with tab
 Text: "a b"
 Pattern: "(a\s+b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

--- Group Boundary Tests ---
Test  66: Group first char
 Text: "hello"
 Pattern: "(h)"
 Result: pos= 1, len= 1
 Expected: pos= 1, len= 1
 [PASS]

Test  67: Group last char
 Text: "hello"
 Pattern: "(o)"
 Result: pos= 5, len= 1
 Expected: pos= 5, len= 1
 [PASS]

Test  68: Whole text group
 Text: "test"
 Pattern: "(test)"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  69: Partial match group
 Text: "testing"
 Pattern: "(test)"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

--- Group with Escaped Chars ---
Test  70: Group with dot
 Text: "a.b"
 Pattern: "(a\.b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  71: Group with star
 Text: "a*b"
 Pattern: "(a\*b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  72: Group with backslash
 Text: "a\b"
 Pattern: "(a\\b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

Test  73: Group with bracket
 Text: "a[b"
 Pattern: "(a\[b)"
 Result: pos= 1, len= 3
 Expected: pos= 1, len= 3
 [PASS]

--- Real-World Group Examples ---
Test  74: Extract domain
 Text: "user@domain.com"
 Pattern: "@(\w+)\."
 Result: pos= 5, len= 8
 Expected: pos= 5, len= 8
 [PASS]

Test  75: Extract filename
 Text: "file.txt"
 Pattern: "(\w+)\."
 Result: pos= 1, len= 5
 Expected: pos= 1, len= 5
 [PASS]

Test  76: Extract number
 Text: "Price: $123"
 Pattern: "\$(\d+)"
 Result: pos= 8, len= 4
 Expected: pos= 8, len= 4
 [PASS]

Test  77: Extract time
 Text: "Time: 14:30"
 Pattern: "(\d+):(\d+)"
 Result: pos= 7, len= 5
 Expected: pos= 7, len= 5
 [PASS]

--- Multiple Groups with Quantifiers ---
Test  78: Two groups plus
 Text: "aaabbb"
 Pattern: "(a)+(b)+"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  79: Groups with star
 Text: "aaabbb"
 Pattern: "(a)*(b)*"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  80: Mixed quantifiers
 Text: "aaab"
 Pattern: "(a)+(b)?"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  81: Groups counted
 Text: "aabbcc"
 Pattern: "(a){2}(b){2}(c){2}"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

--- Groups with Mixed Content ---
Test  82: Group alpha num
 Text: "test123"
 Pattern: "([a-z]+)(\d+)"
 Result: pos= 1, len= 7
 Expected: pos= 1, len= 7
 [PASS]

Test  83: Group num alpha
 Text: "123test"
 Pattern: "(\d+)([a-z]+)"
 Result: pos= 1, len= 7
 Expected: pos= 1, len= 7
 [PASS]

Test  84: Group mixed
 Text: "a1b2c3"
 Pattern: "(\w)(\d)"
 Result: pos= 1, len= 2
 Expected: pos= 1, len= 2
 [PASS]

Test  85: Group words
 Text: "hello world"
 Pattern: "(\w+)\s(\w+)"
 Result: pos= 1, len= 11
 Expected: pos= 1, len= 11
 [PASS]

--- Edge Case Tests ---
Test  86: Many groups
 Text: "abcdef"
 Pattern: "(a)(b)(c)(d)(e)(f)"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  87: Repeated groups
 Text: "ababab"
 Pattern: "((ab))+"
 Result: pos= 1, len= 6
 Expected: pos= 1, len= 6
 [PASS]

Test  88: Group at boundaries
 Text: "test"
 Pattern: "^(test)$"
 Result: pos= 1, len= 4
 Expected: pos= 1, len= 4
 [PASS]

Test  89: Group no match end
 Text: "test"
 Pattern: "(test)x"
 Result: pos= 0, len= 0
 Expected: pos= 0, len= 0
 [PASS]

==========================================
Test Summary
==========================================
Total tests:  89
Passed:  89
Failed:  0
Success rate: 100.0%
==========================================
All tests PASSED!

Edited 2025-11-21 09:02 by matherp
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1649
Posted: 06:03pm 21 Nov 2025
Copy link to clipboard 
Print this post

Mick & Pete:

Thanks guys. I have the warm and fuzzy re:CMM2 again. I just won't allow the battery to ever be a show-stopper. At home, it's a minor irritation but a whole 'nother story for a piece of process equipment.

The CMM2's pros, hugely outweigh the cons 👍😎👍
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8315
Posted: 08:58am 22 Nov 2025
Copy link to clipboard 
Print this post

It's a cracking machine, Grommit!
Not at all "cheesy". :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
okwatts
Regular Member

Joined: 27/09/2022
Location: Canada
Posts: 62
Posted: 12:28am 24 Nov 2025
Copy link to clipboard 
Print this post

It will be apparent that I haven't kept up with the evolving MMBasic for the CMM2 from 5.07.02.beta11 to 6.00.00b7(from Pmather) but I ran into a problem when trying the CMM2 welcome tape on 6.0. The graphics examples fail with "phi not declared". So far all other examples have worked fine. Is it just my lack of understanding or is there some bug that was introduced?
Edited 2025-11-24 10:34 by okwatts
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1060
Posted: 06:08am 24 Nov 2025
Copy link to clipboard 
Print this post

Bug introduced with implementation of Option Escape.Will look at it.
F4 H7FotSF4xGT
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1060
Posted: 11:30am 24 Nov 2025
Copy link to clipboard 
Print this post

V6.00.00b8

CMM2 V6.00.00 Beta8 Update
REGEX updated
Fixed bug reading DATA statements that were a variable name, which gave variable not declared error.

CMM2V6.00.00Beta8.zip
F4 H7FotSF4xGT
 
     Page 3 of 4    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025