/*
Array Variables.c
Declare and initialize an array and display a couple of its elements.
http://learn.parallax.com/propeller-c-start-simple/array-variables
*/
#include "simpletools.h" // Include simpletools
int main() // main function
{
int p[] = {1, 2, 3, 5, 7, 11}; // Initialize the array
print("p[0] = %d\n", p[0]); // Display what p[0] stores
print("p[3] = %d\n", p[3]); // display what p[3] stores
}
/*
Make a Decision.c
If a condition is true, display a second message.
http://learn.parallax.com/propeller-c-start-simple/make-decision
*/
#include "simpletools.h" // Include simpletools
int main() // main function
{
int a = 25; // Initialize a variable to 25
int b = 17; // Initialize b variable to 17
print("a = %d, b = %d\n", a, b); // Print all
if(a > b) // If a > b condition is true
{
print("a is larger \n"); // ...then print this message
}
}
I played a bit with GEAR-V14.07.03 but it sometimes crashes (at least on Debian).
For stuff that needs not more periphery than a serial and EEPROM I prefer SpinSim. But that's not perfect too: Try PropForth or some other really complex stuff in it... :-(
(The attached picture is not from a crash of GEAR. It shows a Mandelbrot image being calculated and shown on a VGA screen simulated by GEAR.)
Listen to Jon he certainly knows what he's talking about. I spent a bunch of time, reading about, talking about, and thinking about writing code and the only thing I wasn't doing was actually writing code.
Funny thing is I started a project which I have not completed to try to teach myself to code and ended up writing code and was having so much fun learning that I completely forgot about my original project. I have been trying every command just to see what happens, the worse thing that can happen is I damage a board or two but in the big scheme of things who cares as long as I'm learning something, right?
Sure enough, open up VS code. Type something. Then close it. It saves everything without asking. When you open it up again everything is there, just the way you left it.
Can I screw up my programs this way?
Perhaps. That almost never happens. And if it does there is no harm done. All my projects live it git repositories so I can use git to get back to the last working version any time. I find git amazingly helpful that way, even for the smallest projects.
Comments
Finished lesson 3 last night.
This lesson is Variable Arrays.
Anybody using Gear Propellor Debugger Emulator?
Publison
It does not like it is being developed really.
Looks like Viewport is the way to go.
Anybody have a good email for Viewport?
Link on site isn't working.
http://onerobot.org/
It is very powerful, but it has not been updated in at least 6 years.
Hanno, the author also did 12Blocks on his site, and the software for the Parallax Scope:
https://www.parallax.com/product/32220
It's a great price at $99. I paid $249.00 when it first came out.
Here's the lesson on Array Variables
Will run it and read explanation.
Finished up Array Variables
Here's code for Make a Decision.
For stuff that needs not more periphery than a serial and EEPROM I prefer SpinSim. But that's not perfect too: Try PropForth or some other really complex stuff in it... :-(
(The attached picture is not from a crash of GEAR. It shows a Mandelbrot image being calculated and shown on a VGA screen simulated by GEAR.)
We will just use Propeller 'as is'.
If in almost 20 years Parallax has not seen fit to add a simulator or a hardware debugger then 'Oh well'.
It is a teaching system and hobbyist platform like Picaxe.
So we will be learning and hobbying!
I think it's fine the way it is.
In this first tutorial they keep hitting you over the head with PRINT statement.
They're saying 'Debug with PRINT'.
:
Funny thing is I started a project which I have not completed to try to teach myself to code and ended up writing code and was having so much fun learning that I completely forgot about my original project. I have been trying every command just to see what happens, the worse thing that can happen is I damage a board or two but in the big scheme of things who cares as long as I'm learning something, right?
Thanks!
Okay.Will do!
In this 'Make a Decision' lesson.
It covers 'Relational Operators'.
What is this first character.
!= Not equal to
Is that an exclamation mark or a bar?
Cluso
Thx!
Hard to make out what it is for some reason.
Cluso
Thanks again!
Will finish this lesson tonight.
I like the little 'Build Status' output window down the bottom.
I'm surprised this statement picked up the 'a' variable value the way it's written.
EDIT
How do you turn on highlighting in this editor?
I like the templates in the My Projects directory.
What is Simple program and C++ program mean?
Found a bug.
I swapped values for a and b.
To get it to fail test and never execute block of code.
'Close All'. It did not ask 'Do you want to save?'. It just saved it.
That's not very good. You can screw up your sample programs.
My favorite editor today is Microsoft's Visual Studio Code: https://code.visualstudio.com/
Sure enough, open up VS code. Type something. Then close it. It saves everything without asking. When you open it up again everything is there, just the way you left it.
Can I screw up my programs this way?
Perhaps. That almost never happens. And if it does there is no harm done. All my projects live it git repositories so I can use git to get back to the last working version any time. I find git amazingly helpful that way, even for the smallest projects.
You are right. It is a good feature when your coding along.
Right now though I would prefer the examples had the 'Do you want to save?'.
Starting next lesson. Make Several Decisions.
I like these tutorials!
Okay. We're up to 'Make Several Decision's '.
Yes I do like these tutorials.
IF...ELSE...ELSE is fun.
Running the code will be delayed.
Due to real world tasks.
Target time window is tomorrow. Probably PM.