Jump to content
UBot Underground

How do I create containers?


Recommended Posts

How can I create a container in ubot so it's easier to organize different parts of the bot.

 

Say I have 5 commands that are used to sign into an account.

 

How can I group them in a container so that I can collapse/expand/move them all as one unit?

 

Thanks!

Link to post
Share on other sites
  • 4 weeks later...

When you set the custom command to function, the resulting function may be called and would actually return the result per se, not just perform the set of commands within, like the regular commands would do.

 

For instance, if you would write some code to get some data from a variable as its input, then perform a set of operations/calculations within, math or string related, for example... then calling that function would actually pass the result of the operations to a set command on the main program.

 

Like this - say you write a define to calculate the Round number of a decimal number, that will get an input variable:

 

set(#My_Rounded_Result, $Round(123.257), "Global")

 

If that were the case, your #My_Rounded_Result variable would have now gotten the value returned by your custom function, which would be 123.26

 

Don't hold your imagination, it is not supposed to work only math.

You can write functions to apply various operations to strings, for example... and so forth...

 

HTH...

Link to post
Share on other sites

Beware, when you program it, apart from selecting it to be a 'Function' not a 'Command' in the DEFINE node, you will also have to add an extra command at the end, specifically the RETURN command, that will instruct the function WHAT exactly to return when called...

 

Inside the RETURN command you will set the 'Local' variable (from within the DEFINE code) that will be passed outside, to the calling program:

 

RETURN(#Rounded_Value)

 

....for example.
Link to post
Share on other sites

Basically, Commands are used to perform specific tasks (does something) while Functions are used for calculating stuff (returns a value)...

 

http://learnubot.com...fine-command-2/

sorry didn't see you added a video had to scroll up the thread, watching it now

 

thanks

Link to post
Share on other sites

just tried using the define > command

 

to replace my multiple duplicate loops set to one cycle

 

You can also use a Loop set to one cycle.

 

I do that a lot.

 

Buddy

 

hahaha... want cleaner code i guess...

 

since i was using command (don't want it to return anything), i simply added the "define > command" node, with no variables, and dragged my 1 cycle loop in

 

the function didn't execute though even though it works fine as a 1 cycle loop

 

any ideas?

Link to post
Share on other sites

The DEFINE command will not execute if you don't CALL it...

 

Basically it is just a subroutine, a piece of code that needs to be told to run in order to run.

 

The fact that you have written it and it sits in your bot in between other commands, still doesn't count. It will be skipped at run time.

 

The only way to make it work is to call it from the main program.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...