I decided to change some of the most common services into global functions with overloads. The topic can be found here. As long as it is only edited and saved in source view, it should be OK. Opening it via painter will only show you one function.
Here are some of the functions:
- SizeOf - get's the size, in bytes, for primitive types and structures.
- IsNull - same as MS SQL IsNull function
- IIF - same as datawindow if() function
- IsEmptyOrNull - checks for empty or null for all datatypes
The purpose of these functions is to make code more readable while reducing footprint.
Before:
n_svc_mgr lnv_svc; n_svc_isempty lnv_check; n_svc_sizeof lnv_size
//load services
lnv_svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY); lnv_svc.of_LoadSvc(lnv_size, CSvc.SIZEOF)
bitmapinfoheader lstr
long ll_size; string ls_text
ll_size = lnv_size.SizeOf(lstr)
IF lnv_check.of_IsEmpty(ls_text) THEN ....
After:
long ll_size; string ls_text
ll_size = SizeOf(lstr)
IF IsEmptyOrNull(ls_text) THEN ....
The code is shorter now, but we have to live with these functions staying in memory. The old way ensures that the services will be destroyed as soon as the service manager goes out of scope. But since these services are more like code functions, I changed them.
I would rather focus on functions that will get used a lot. Can you think of any other candidates?