many errors when compiling the C program

I'm newbie in C programming and i am trying to drive my arduino, but I found there errors:

sketch_mar05d:84: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:85: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:86: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:87: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:88: error: expected constructor, destructor, or type conversion before '=' token
sketch_mar05d:92: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:93: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:94: error: expected constructor, destructor, or type conversion before '(' token
sketch_mar05d:97: error: expected unqualified-id before 'for'
sketch_mar05d:97: error: expected constructor, destructor, or type conversion before '>' token
sketch_mar05d:97: error: expected constructor, destructor, or type conversion before '--' token

here is the code: http://physicsforums.com/showthread.php?t=583892
I'm sorry I cant post he code all here because words limitation.

Thank you before

I haven't seen Gosub used in many many years and not in Arduino so I can't tell what might be wrong there except that they simply might not work in v1.0 I did notice you use if/endif instead of if { }. I'm not sure if this syntax works in the IDE or not. In traditional C if loops, an equal to comparison is done with a double ==. This may or may not be causing problems as well since I am unfamiliar with using a VB style if/end if syntax in the arduino IDE.

I did notice some missing ';'.

g_pinCommLatch1=LOW
g_pinCommLatch2=LOW
g_pinCommLatch3=LOW

Every one of the errors you are getting are related to a syntax error where you have fumble fingered something or left out something. Fix those 3 and see if it starts to shorten your list.

Did you copy this code from somewhere or write it yourself?

I only ask because this is A LOT of code to not have built many times to catch these types of errors in pieces instead of catching all the errors in one build which makes it much more difficult to track down the problems.

Tombol:

GoSub Blinks
 
  if switchPin1=1 and a=1 then
  GoSub Counter1
  a=0
  elseif switchPin1=0 and a=0 then
  a=1
  end if

if switchPin2=1 and b=1 then
  GoSub Counter2
  b=0
  elseif switchPin2=0 and b=0 then
  b=1
  end if
 
  if switchPin3=1 and c=1 then
  GoSub Counter3
  c=0
  elseif switchPin3=0 and c=0 then
  c=1
  end if

if resetPin1=1 and a=1 then
  GoSub reset1
  end if

if resetPin2=1 and a=1 then
  GoSub reset2
  end if
 
  if resetPin3=1 and a=1 then
  GoSub reset3
  end if

GoSub Show1
GoSub Show2
GoSub Show3
GoSub SendSerialData1
GoSub SendSerialData2
GoSub SendSerialData3
delay(1000
GoSub Tombol

It doesn't compile because this is Basic, not C.

To Sacman:
I write it by myself, by using the logic from my supervisor final project. I thought he used C language.
To Nick Gammon:
Oh thank you finally I know this is Basic, heu :smiley:

To All:
Every arduino program, I have found that they use void(), it means it has no return value.
One reason why I force to use GoSub is because it has return value, and in my complicated program, I need to return..

Do you have any idea what syntax I can use in order to have return value? :smiley:

Here is a short few texts on functions, parameters and return values.

http://www.cplusplus.com/doc/tutorial/

To pYro_65:
But I'm working with C not C++,so?

creativen:
To All:
Every arduino program, I have found that they use void(), it means it has no return value.
One reason why I force to use GoSub is because it has return value, and in my complicated program, I need to return..

Better start studying C++, I think. The Arduino IDE uses C++ (not C). Also only void functions return no value. To return a value you put some other word (like int) in place of void. eg.

int foo ()
  {
  return 42;
  }

In any case, functions return, whether or not they return a value.

To Nick Gammon:
Oh I think it uses C and not C++,thank you for your worth info, recommendation book to download for C++?

Can you give example in what part of the void I must put the 'int'?
And why you return 42? why not 43?where the return goes?

Why 42? Why indeed ...

As for the other questions, try Googling "C++ tutorial".

heuu, well I must start from beginning again for C++
Thank you all very very very very much, at least now I know where I should go rather than stay fixing crazy code now.

again i found problems starting to learn C++:

I write this code in my compiler Arduino IDE:

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

Then it show this:

sketch_mar05a.cpp:1:20: error: iostream: No such file or directory
sketch_mar05a.cpp: In function 'int main()':
sketch_mar05a:5: error: 'cout' was not declared in this scope

is it C or C++?or is there any wrong with the compiler?

Right. Well these examples assume you are running on a Unix or similar system where you have stdin and stdout. (That is, in effect, the keyboard and the screen). Since you don't have a keyboard or screen on the Arduino you have hit a problem.

Try looking at some of the example sketches in the IDE. For one thing, they "predefine" main for you, so even using main is a no-no.

Your sketch could be rewritten as:

void setup ()
  {
  Serial.begin (115200);
  Serial.println ("Hello, world");
  }

void loop () {}

To be more C++ like, you can use the streaming library from:

http://arduiniana.org/libraries/streaming/

Then your sketch can look like:

#include <Streaming.h>

void setup ()
  {
  Serial.begin (115200);
  Serial << "Hello, world" << endl;
  }

void loop () {}

In this case "Serial" behaves somewhat like "cout".

AWESOME!!!

I turned 42 this year. So many people just don't get it when i tell them I am the answer to Life the Universe and Everything.

Hmm, both codes you gave me is much different for newbie like me...
I think to save time, can I just directly learn the pattern for the IDE rather than C++ then convert to IDE C++...?

Hmmm, where I can learn C++ for Arduino IDE?
I'm so sorry coz I ask too many...

AWESOME!!!

I turned 42 this year. So many people just don't get it when i tell them I am the answer to Life the Universe and Everything.

woo hooo! You are...

I think to save time, can I just directly learn the pattern for the IDE rather than C++ then convert to IDE C++...?

I'm struggling to pick the meaning out of that sentence.

The IDE (Integrated Development Environment) is just a way of editing, compiling and downloading Arduino sketches, which are simply sawn-off C++ programs.

creativen:
I think to save time, can I just directly learn the pattern for the IDE rather than C++ then convert to IDE C++...?

Absolutely.

Here is a good Arduino programming book from a regular poster on this forum.

http://arduino.cc/forum/index.php/topic,79407.0.html

Thank you all friends!