Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

I'm using NXT-G to program my robot to do few tasks autonomously for so many possibilities. When using C programming, we can call a function from different file into the main program. So, I wonder if it is possible to write a program that can run another program for one possibility and run another program for other possibility?

share|improve this question
add comment

1 Answer 1

As far as I remember there is no possibility within NXT-G to programmatically execute another program. Moreover, as I understand it the default firmware simply doesn't have that possibility (the command to start a program is a direct command which must be sent via bluetooth and can't be used in a program). Maybe other programming languages using other firmware can do it, but I don't know about that.

However, you could encapsulate certain parts of your program in your own blocks, which I would say are similar to C functions. As such, it will simplify your main program, and you can reuse blocks in different programs (but the blocks themselves are included in the program file, it's not like a library which would be a different file). You should probably read a tutorial on how to make your own blocks to decide if it's a valid solution for you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.