Video Transcript:
In this video I want to talk about 3 useful functions in Ubot Studio that you may not know about and cover some examples of how and when to use them. This video is going to be a bit different than normal so be sure to leave a comment if you like the format or even if you don’t like it. Your feedback is always welcome and it helps me craft better videos for you.
So let’s get to it and dive right in with #3
The third useful function is called pad text, this can be found under the text functions section. Pad text will return your original text padded with a character. This means you can add a character to the start or end of your original text. You can also ensure that the text is a certain length.
This may sound pretty useless and I think it’s often overlooked but it does have some special use cases and I want to go over one that comes up from time to time.
Let’s say that you needed to have a series of numbers 1 to 100 in our case and they always need to be 3 digits. So the first number is 001 and the next is 002 and so on.
This is when pad text is going to be useful. You can pad the numbers with a 0 character and set the desired length to be 3. Pad text does all the heavy lifting and will ensure that if the digits are less than 3 a 0 will be added to the side you specify.
While pad text may not be something you use in every bot, the next function I want to talk about is something you are going to want to use all the time.
The second useful function is actually two functions. But they are so similar that I want to talk about both of them together.
I am talking about the is blank and is number functions, both of which can be found in the bot bank under the advanced text section.
Now don’t worry if you don’t have access to the bot bank because I will show you a workaround for these. But if you do have access to the bot bank then these functions are quick and easy to use and will speed up your coding.
Is blank simply looks to see if the text to check is either blank or white space, if it is then it will return true. This is a great way to validate user input. You can ensure that your user entered something for the field you want to check.
You can also use it for other purposes such as seeing if the text you scraped is blank.
Is number will check to see if the text to check only contains numbers. This is another great function to use for input validation. If you expect your user to enter a number into a field you can use this function to ensure they entered a number and not something else.
Another use is to ensure what you are scraping is a number. If you expect a number and get something else that may be a sign that something has gone wrong and your bot can self correct itself or maybe send you an email saying something isn’t quite right.
Now I’ll show you some work around.
For is blank you can simply use a comparison function and check to see if the first value equals nothing. This is pretty quick and easy so if you don’t have access to the bot bank it’s just a little bit of extra work to do this.
However, if you want to check for a number it’s going to be a bit more involved.
What you can do is use a comparison function again, but this time in the first value you will need to use a regular expression. You can use a backslash, then the letter d for digit and then a plus sign. This will look to see if there is one or more numbers.
Then use the equals sign as the condition and for the second value put the text you want to check in there as well.
This will check to see if there is one or more numbers and if so will return them to the first value. Then if the first value equals the second we know that the text only contains numbers. If the text contains anything else then the first value will be shorter than the second.
And now I want to talk about the number one useful function you may not know about. That is subtract lists which is located under the data functions section.
Subtract lists will allow you to remove items from one list based on another. It does this by returning the unique items from the first list, so that you can add those to another list.
It’s probably easier to just show you how this works rather than trying to draw out an explanation.
So these are a few functions you may not have known about before. This video was a bit different so If you liked this format be sure to leave me a comment and let me know. Also, be sure to subscribe to this Youtube channel so you can get updates and check out Elite Botters dot com as well.
Thanks for watching and I’ll see you in the next one!