Updated 031 Automatic import of custom code during compilation in JCB (markdown)

Amigo 2019-07-12 11:51:30 +02:00
parent 0348741ad0
commit 323c65fc04
1 changed files with 4 additions and 4 deletions

@ -23,17 +23,17 @@ There are some conventions and regulations that should be considered when the wa
### Limitations For Inserting And Updating [00:05:30](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m30s)
There are a few limitations. Code can not be added closer to each other than about 6 lines. If there are going to be code closer to each other and it ends and starts within the parameter of 6 lines, you end up with a problem, especially at the end. [00:06:14](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m14s) The reason is Component Builder doesn't only use the line in which this is found to remember where to place it, but actually creates a fingerprint of the code above this insertion and the code below this insertion, to accurately insert it in the future. So that code changes and then Component Builder will give you a notice and will not insert the code.<<<<<<<
There are a few limitations. Code can not be added closer to each other than about 6 lines. If there are going to be code closer to each other and it ends and starts within the parameter of 6 lines, you will end up with a problem, especially at the end. [00:06:14](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m14s) The reason is Component Builder doesn't only use the line in which this is found to remember where to place it, but actually creates a fingerprint of the code above this insertion and the code below this insertion, to accurately insert it in the future. If that code changes, Component Builder will give notice and will not insert the code. That is due to the nature of JCB. It is constantly being improved and therefore its code moves around quite a lot.[00:06:48](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m48s) It had been impossible to automate this, because code may accidentally be overwritten which was never intended.
This is because of the nature of JCB. It is constantly being improved and that therefore it's code is moving around quite a lot. There was no other way for us to try and automate this, [00:06:48](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m48s) because if we use the line it could possibly cause an accident by overwriting code you never intended it to overwrite. So the only way we could solve this was creating what we call a fingerprint. A few lines above the insertion or the replacement and a few lines below the replacement. I'll demonstrate this in our demonstration in a moment. Just a heads up about that. To insert new code you will use this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///). To replace new code or for the first time you would use that(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) [00:07:25](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m25s) At the end of the code you would add these corresponding placeholders(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) and(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) . I'll put these this little block(see video) into the comments of this tutorial. If any of you need to copy it down you could just copy it from there. When component builder adds it back, it will look like this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///23) for the inserted and this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///25) for the replaced. If you then come back all you need to do is just add that diamond(<>) in there for it to be updated in the database.
The only way to solve this was create what is called a "fingerprint", a few lines above the insertion of the replacement and a few lines below the replacement. To insert new code this will be used(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///). To replace new code or initially use that(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) [00:07:25](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m25s) At the end of the code add these corresponding placeholders(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) and(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) . This little block(see video)is placed into the comments of this tutorial. If any of you need to copy it get it from here. When Component Builder adds it back, it will look like this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///23) for the inserted and like this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///25) for the replaced. Just add that diamond(<>) in there for it to be updated in the database.
* ### Showing Example With Replace(see video)[00:08:00](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s)
Let's see this in action. So here we have that demo components main document open. I'm going to add some replacement tags here. I'm not making any changes but I could add a few lines here - ///. Maybe another comment - 'hi it worked', [00:08:34](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m34s) let's do - echo 'hi it worked' and that should do it. This is going to replace this area. +++++++++++++
Let's see this in action. So here we have that demo components main document open. I'm going to add some replacement tags here. I'm not making any changes but I could add a few lines here - ///. Maybe another comment - 'hi it worked', [00:08:34](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m34s) let's do - echo 'hi it worked' and that should do it. This is going to replace this area.
### Recompiling The Demo Component With Replace [00:08:58](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m58s)
++++++++Let's go to the compiler and compile the component. See what happens. So in the compiler I'm going to compile a component again. It successfully compiled. Now before I install it I could do a check to see whether it actually did get the code from the component. [00:09:24](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m24s)
Let's go to the compiler and compile the component. See what happens. So in the compiler I'm going to compile a component again. It successfully compiled. Now before I install it I could do a check to see whether it actually did get the code from the component. [00:09:24](https://www.youtube.com/watch?v=DFMfIl-VkSk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m24s)
### Checking The Custom Code Tab Before Installing