Calling other programs inside a sketch

Hello,

After searching through the internet, as well as seeing this post:

https://forum.arduino.cc/index.php?topic=255775.0

I still am not sure as to how to include a sketch inside another sketch

Basically, in one program I want to run an if statement that runs code X else code Y, but don't want to include a very large amount of code, instead just one line to call that program. I'm not exactly sure as to how to do this, and would greatly appreciate it. If you need more clarification, I would greatly appreciate it.

Thanks!

All of the code in your program must be loaded into program memory at compile time. Program code cannot be fetched from anywhere else after compilation.

Each of the different actions needs to be in a function within a single program. You can think of a function as being equivalent to "another program".

Have a look at how the code is organised in Planning and Implementing a Program

...R

Tbot1000:
Basically, in one program I want to run an if statement that runs code X else code Y, but don't want to include a very large amount of code, instead just one line to call that program.

hopefully you understand sub-functions (e.g. setup() and loop()). you can put all the code X code in one sub-function and the code Y code in a separate sub-function. your main code (in loop() can conditionally (using an if/else) call either the code X subfunction or the code Y subfunction.

Yeah, I do understand. I just wish there was a better way, but thanks anyways.

I just wish there was a better way,

can't say much more without seeing code