Did the RegEx library change in some way with 6.04?
Did the RegEx library change in some way with 6.04?
Before I search until my eyes bleed: Did something happen to the RegEx-library? My Gerber module worked fine until now. I didn't change a single byte, just updated to 6.04 and now, boom, the regex calls all fail suddenly. I cannot render my Gerber files anymore.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Did the RegEx library change in some way with 6.04?
Just checked and last change was made in 6.03
Re: Did the RegEx library change in some way with 6.04?
Thanks Fred.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Did the RegEx library change in some way with 6.04?
Seems like I found the culprit, which leads to another question: I thought modules had their own scope for variables and constants. This seems to be wrong. I have an enumeration for RegExes in my module AND in the main program. Both start with 0. Does this mean, one overrides the other one? Does this also mean I ABSOLUTELY HAVE to use #PB_Any within the module, wherever it is possible to use it (RegEx, databases, controls, images...)???
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Did the RegEx library change in some way with 6.04?
It is obvious. Any menu or gadget cannot have the same number, even if they are in different windows. As far as I understand, lists that are associated with objects are created inside PureBasic. Upon completion of the program, these lists undergo a closing process. Therefore, when you bind another object to the same number, in the best case, the old object will be destroyed before being bound to the new object, and in the worst case, you get a memory leak if the object remains in memory, and the link to it through the identifier is lost.
If you are using a module then you should not use explicit numbers, you should definitely use the #PB_Any constant
As far as I know, #PB_Any uses large numbers for identifiers, so if the user creates an object starting from zero, it is protected from overriding the occupied identifier by other modules. But in any case, when using the module, it will be more reliable to use the #PB_Any constant for objects of your program.
Re: Did the RegEx library change in some way with 6.04?
I understand that, but I thought each module had its own scope, so it'd had its own list of objects and it wouldn't collide. I'll have to redo some of my modules.
Also, this isn't 100% clear from the help, though I might be the only one who didn't understand this.
Anyway, thanks for taking time and clearing this up!
Also, this isn't 100% clear from the help, though I might be the only one who didn't understand this.
Anyway, thanks for taking time and clearing this up!
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Did the RegEx library change in some way with 6.04?
I started this reply before AZJIO posted and so I'll post it pretty much as is because it presents a different view from AZJIO. Please forgive the redundant things you already know and heard from AZJIO's post.
Considering the above facts, you do not need to use #PB_Any if you don't want to. You do need to better control the enumeration process to generate unique ID's as needed. This can be done in several ways.
You can enumerate the range of ID's inside the module with a different starting point than the enumeration in the mainscope to help ensure the range of ID's don't overlap.
A better method with modules is to use a 'Common' module and a named enumeration for the RegularExpressionID's. Both the mainscope and other modules that need to generate their own unique ID's would reference the named enumeration in the 'Common' module.
Here's an example:
Did you think that if the code that executed a RegEx function was included in a module that the RegularExpressionID was unique to the module? That is definitely not true. A RegularExpressionID is also not unique to a particular thread whether or not it is generated by code running inside or outside of that thread.jacdelad wrote: ↑Wed Jan 03, 2024 11:53 pm Seems like I found the culprit, which leads to another question: I thought modules had their own scope for variables and constants. This seems to be wrong. I have an enumeration for RegExes in my module AND in the main program. Both start with 0. Does this mean, one overrides the other one? Does this also mean I ABSOLUTELY HAVE to use #PB_Any within the module, wherever it is possible to use it (RegEx, databases, controls, images...)???
Considering the above facts, you do not need to use #PB_Any if you don't want to. You do need to better control the enumeration process to generate unique ID's as needed. This can be done in several ways.
You can enumerate the range of ID's inside the module with a different starting point than the enumeration in the mainscope to help ensure the range of ID's don't overlap.
A better method with modules is to use a 'Common' module and a named enumeration for the RegularExpressionID's. Both the mainscope and other modules that need to generate their own unique ID's would reference the named enumeration in the 'Common' module.
Here's an example:
Code: Select all
DeclareModule Common
Enumeration RE_ID 1
EndEnumeration
;and other common elements
EndDeclareModule
Module Common: EndModule
Enumeration Common::RE_ID
;generate a few ID's
#REID_main_this
#REID_main_that
EndEnumeration
DeclareModule parse_mod
Enumeration Common::RE_ID
;generate a few public ID's
#REID_pm_this
#REID_pm_that
EndEnumeration
Declare output()
EndDeclareModule
Module parse_mod
Enumeration Common::RE_ID
;generate a private ID
#REID_pm_another
EndEnumeration
Procedure output()
Debug "REID's visible in parse_mod module"
;Debug #REID_main_this ;not visible
;Debug #REID_main_that ;not visible
Debug #REID_pm_that
Debug #REID_pm_this
Debug #REID_pm_another
EndProcedure
EndModule
Enumeration Common::RE_ID
;generate an additional ID
#REID_main_another
EndEnumeration
Procedure output()
Debug "REID's visible in main scope"
Debug #REID_main_this
Debug #REID_main_that
Debug parse_mod::#REID_pm_this
Debug parse_mod::#REID_pm_that
;Debug parse_mod::#REID_pm_another ;not visible outside parse_mod module
Debug #REID_main_another
EndProcedure
parse_mod::output()
output()
Re: Did the RegEx library change in some way with 6.04?
Thanks Demivec! I know about the common module, but only use it for events and eventtypes and such. Since not everyone uses this technique I'll stick with #PB_Any, which should eliminate all problems.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB