Tech Tip: Removing a component can cause a -10509
PRODUCT: 4D | VERSION: 11.6 | PLATFORM: Mac & Win
Published On: July 16, 2010
There is a known limitation for the usage of Components:
- If a component method is tokenized in the database then that component must be available in the components directory.
- If the component is not found a -10509 error will be displayed and the user is notified that a component is missing.
- If the component has been renamed, a -10509 error will be displayed :: Renaming the .4DC file of the component to the earlier name used during compilation can be a temporary workaround; you can change it's name before your next compiling of the Host database.
The error will look like this (replace the database name and component name with applicable values):
![](https://kb.4d.com:443/kbase/assets/images/76125-1.jpg)
To avoid this, you must avoid directly using a Component's method in the Host database, because they are tokenized, and require that the component is there.
One approach is to use EXECUTE FORMULA to execute shared methods.
For example, the following code has the Component method "myComp_method1" tokenized:
ARRAY TEXT($Components_at;0) COMPONENT LIST($Components_at) If (Size of array($Components_at)>0) If (Find in array($Components_at;"myComponent@")>0) C_LONGINT(count_li) C_TEXT(text_t) C_TEXT($0;out_t) count_li:=10 text_t:="Test!" out_t:=myComp_method1 (text_t;count_li) $0:=out_t End if End if |
The above example has the component method tokenized which should be avoided if you want to be able to replace or remove the component database without seeing the -10509 error.
This code can be re-written like this:
ARRAY TEXT($Components_at;0) COMPONENT LIST($Components_at) If (Size of array($Components_at)>0) If (Find in array($Components_at;"myComponent@")>0) C_LONGINT(count_li) C_TEXT(text_t) C_TEXT($0;out_t) count_li:=10 text_t:="Test!" C_TEXT($execThis) $execThis:="out_t:=myComp_method1 (text_t;count_li)" EXECUTE FORMULA($execThis) $0:=out_t End if End if |
In this case you have no shared component methods tokenized in the Host database, and you will avoid these errors.
http://doc.4d.com/4Dv11.6/help/command/en/page1007.html
which calls directly a method and passes the parameters, while EXECUTE FORMULA first starts the interpreter to tokenize the command, then analyze it, then executes it.
EXECUTE METHOD has some advantage, like that the used method is understood by 4D, so it is not reported by using "Search unused methods". A method only called by EXECUTE FORMULA is reported as unused.