Beginner question.

I have just started to learn / program in the Arduino environment and language. Is there any way to write functions or call sub routines... right now I have a mess if if statements and while statements and it is becoming BASIC like spaghetti code. Thank you in advance!

Yes, functions are quite widely used. Some examples:

void setup(){
// code that runs once
}
void loop(){
// code that runs over and over
challenger1();  // a function that is called - have to check on whether the ; is needed or not.
}
void challenger1(){
// code that is called from setup() or loop()
}

WOW! Thank you for the fast help!

One last question... can it (or will it even make a difference) compile with external files that house all my UDFs? Or will it not even make a difference (in other words... just keep everything on one physical file)?

I don't know what you mean by UDF.
I use the Tab feature of the IDE (the Down arrow over near the upper right corner) to break down the code some.
That makes a series of .ino files that are treated as alphabetically listed sections of code.
Left most tab is the file itself, then I use a_presetup, b_setup, c_loop1, d_loop2, e_functions, etc.
Each tab will be a .ino file in the top name folder.

SamBrownADK:
I have just started to learn / program in the Arduino environment and language. Is there any way to write functions or call sub routines... right now I have a mess if if statements and while statements and it is becoming BASIC like spaghetti code. Thank you in advance!

Google "C++ tutorial", and go through the first few chapters. You don't need the weird object stuff, but you do need to know the basics of the language: control stuctures, types, operators.

SamBrownADK:
One last question... can it (or will it even make a difference) compile with external files that house all my UDFs? Or will it not even make a difference (in other words... just keep everything on one physical file)?

User Defined Function, I am guessing.

The arduino programming environment will compile all .ino and .cpp files in the sketch directory and then it will link them. If file A calls a function in file B, file A needs a declaration of the function that it is calling. The usual way to do this is to put declarations of the public functions in file B into a header file named "B.h", and to include that header file in file A by using an #include directive.

So yes.

The programming environment also supports libraries, which you can build yourself. If you use some bit of hardware in multiple sketches, you can write some stuff dealing with that item, bundle those files into a library, put them in the libraries directory and use them as you can any other library. C++ also has "namespaces" to help manage naming collisions.

C++ is a big language and ecosystem. Operating systems - Linux, MacOX, Windows - are written in C/C++. It's part of the infrastructure of computing since the 70's, it's not missing anything obvious. The answer to "Can you X in C?" is almost always either "Yes, of course." or "why would anyone want to do that?".

"The workaround is to make all the file names start with numbers or single letters so you can control the order. "
Did you not notice the a_, b_, c_, etc?
I don't believe the IDE accepts numbers to start file names.
Apparently it doesn't like spaces in file names either now, I get these funny errors when 1.8.0 starts now complaining about files I'm not even opening.

Old school C programmer here (1980's). Just started learning C++.

Regardless, I break my projects into multiple .cpp (and .h) files. I think the file-level variable and function scope control is useful and important as projects get larger and more complex. I don't like the way Arduino IDE mashes all the .ino files together before compilation. That's why my projects only have one .ino file.

Perhaps just a preference thing. YMMV.

Multiple project files don't have to have the .ino extension. You can also name them with .cpp, .c and .h if you want. The IDE doesn't care. But your setup() and loop() functions must be in a file with .ino extension.

The IDE will try and compile any file with .c, .cpp, .h extensions in the same folder as the original .ino file. Files with other extensions like .txt are ignored.