intermediate,part 1, tab 2, featured, ubot expert,tutorial

UBot Boot Camp Intermediate Part 1 Tab 2 Documentation For The Native Browser

UBot Boot Camp

Intermediate Part 1 Tab 2

Native UBot Browser

 

Hello there UBotter!

 

 

 

In the first section we have our code that now has our named “Custom Commands” these nodes call there respective “define” command. What I mean by “call” is that it runs the code inside the named define like any other node. But your custom command is running your code instead of UBot’s internal hard coded script. These custom commands are also referred to as “sub routines” which are often blocks of code that do specific tasks outside your base script.

 

 

 

When dragging code into a define I usually work from the bottom to the top. I make my define at the bottom of the loop/nodes, as it’s easier to drag stuff into it them. Also, when I nest my function nodes I do it the same way. I open the bottom function, then click on the next function  going up and Ctrl+c or highlight with mouse and click next to it and Ctrl+c or right click and copy. If you on the function after it is highlighted then it wont work. You need to click off to the side. You can put them all into a loop then place loop inside define and drag loop into the define or put define right above the group of nodes and drag one by one. When you get use to the idea you will just start inside a define. I mean when you start out with a fresh bot you will just put your code in the define from the start.

 

 

 

 

 

If you look inside the loop you will see how much cleaner the code is to look at and instantly you know what the command is doing by its name. Another cool thing is that your custom commands can be searched so that you may use them elsewhere in other parts of your script. This is a key feature for the define command and helps reduce your code base. Another cool thing is if you have a lot of nested commands and your inner most node is like 5-8 deep it is so much easier to just make a define then looking for that part of your code. Not just that you can nest multiple define defines inside another, it is truly remarkable what you can achieve with these babies.

 

So, pretty much I just segmented this code into categories much like a file system and made the code more readable, organized and reusable. It is easier to copy and paste these code snippets into another program.

 

 

In the “Type user data” define we are passing a “parameter” variable “#NEXT LIST ITEM”. It is in all caps so I know when I look in the debugger that it is a “parameter variable” at a glance. The same goes for the list in the “Tool Box” under Variables and the search list as well. You can use lower case if you wish and underscores too. Can you guess what is gonna be passed through this parameter? I hope you are thinking $next list item! A perfect example why naming things well is
important for readable code.

 

If you don’t get it now you will when you are reading through 4,000 lines of code. Back in the loop take a look inside the custom command “Type user data”. We are simply putting(passing) the next list item into a temporary variable(parameter variable) to be used inside the respective define. So, back in our define node we don’t need the set(#user_data_NLI) command we used in tab 1 and if you look where we used the old variable they are changed to the new one.

 

 

 

 

 

The “parameter variable” “#NEXT LIST ITEM” is only good inside the define container(node), as soon as all the code has finished running that information stored is gone. This is why in the debugger it is empty all the time because it is local to the define. The same goes for any “set” or list that is set to local inside the define. Each define call gets a separate instance ID and their own memory space in RAM. Once the define is done the data in that memory slot is either replaced or removed in RAM.+

 

 

 

 

So basically that is a custom command life cycle, it just runs your code and alternatively a “custom function” will return something like true or false or some other kind of data result, like when you visit a web page it returns to you information you requested or like a search engine.

 

 

 

Well that’s it for this one except one important thing to remember when working with a define and the reason I split this into two parts. You cant have to defines of the same name in the same bot or things will go horribly wrong. Not the end of the world kind of wrong but UBot wont dig it. Same when you want to copy and paste a define into another tab. It is better to go into code view – cut – the define code, switch tabs – paste – switch back to node view before switching tabs again.

Posted in Intermediate Training.