Hello MazeM,
Thank you for your contribution! I've discovered a couple of issues with ComUDF at the moment:
1) The following code fails to properly recognize 2 and 3-digit COM ports on both 1x Win7 64-bit PC and 5x Win10 64-bit laptops. Anything past the first digit is simply ignored (odd because the code seems fine to me...).
;extract $comPort from $defs
$comPort = StringLeft($def, 4) ;"com1".."com9" (com plus 1st digit)
If IsNumber(StringMid($def, 5)) Then ;"com10".."com99" (2nd digit)
$comPort &= StringMid($def, 5)
If IsNumber(StringMid($def, 6)) Then ;"com100".."com256" (3rd digit)
$comPort &= StringMid($def, 6)
EndIf
EndIf
2) Windows uses UNC paths for anything above COM9 (https://support.microsoft.com/en-us/help/115831/howto-specify-serial-ports-larger-than-com9), so any 2 and 3-digit strings generated by the code above would be invalid. It is recommended to append "\\.\" to every COM port number.
Fortunately, the following code was tested on the above systems and will remedy the issues above completely by a) utilizing StringIsDigit/StringTrimLeft instead of IsNumber/StringMid and appending a prefix of "\\.\" to any COM port between 1 and 256.
;extract $comPort from $defs
$comPort = "\\.\" & StringLeft($def, 4) ;"com1".."com9" (com plus 1st digit)
If StringIsDigit(StringLeft(StringTrimLeft($def, 4), 1)) Then ;"com10".."com99" (2nd digit)
$comPort &= StringLeft(StringTrimLeft($def, 4), 1)
If StringIsDigit(StringLeft(StringTrimLeft($def, 5), 1)) Then ;"com100".."com256" (3rd digit)
$comPort &= StringLeft(StringTrimLeft($def, 5), 1)
EndIf
EndIf
itagashu