Here is the code. Hopefully now that you can see it too, it wil be clear that the include file couldn't be read twice (I am referring to my post below).
djsfantasi:
But how would it "read the file twice"? Wouldn't that imply there were two includes? There aren't. The error appears by changing one character. Change the "h" to a "c" in the filename...
My question remains, why am I receiving an error, when I attempt to include a file with a .c extension?
Here is the main program. The includes are near the top; the last include is "CallTest1.h" .
#include <SPI.h>
#include <SD.h>
#define randomPin 2
#define soundPin 3
#define PlayMove 0
#define PlayScript 1
#define StartScript 2
#define EndScript 3
#define JumpTo 4
#define Label 5
#define SyncPoint 6
#define EndSync 7
#define ScriptPause 8
#define Say 9
#define RandomMove 10
#define RandomPause 11
#define CallScript 12
#define EndWait 13
#define NetWait 14
#define OneOnly 15
#define ActionSeq 16
;
// setup move commands
#include "MoveCommands.h"
byte MoveIndex=0;
int Player;
int MaxPlayers=0;
int LocalIndex;
int PlayerStep[32];
unsigned long PlayerEndWait[32];
int SyncPoints[32];
byte SyncPointIndex=0;
unsigned int SyncPointStatus=0;
unsigned long SoundEndWait=0;
byte Selections;
int minPause;
int maxPause;
int timePause;
int ScriptStep=0;
const char* scbase[]={"#3P"};
const char* qs[]={"VA"};
boolean NotDone=true;
int ScriptAction[127];
int ScriptDescription[127];
int ScriptOption[127];
int ScriptStack[127];
int ScriptSize;
int MainScript;
int EndMain;
int ix; //debug
void setup()
{
PlayerEndWait[0]=0ul;
Serial.begin(9600);
randomSeed(analogRead(randomPin));
// setup tokenized program
#include "CallTest1.h"
}
void loop()
{
// omitted to avoid post size limits //
}
Here is the include "MoveCommands.h".
const char* MoveCommand[] =
{ "#0P1500#1P1500#2P1000#3P570#4P1500#5P2400#6P510#8P1500#9P1500#10P1500#11P1400T1000",
"#2P1100",
"#0P2000 #1P1100 T100",
"#2P750",
"#2P1000",
"#2P1000 T3000",
"#2P1500 T2000",
"#2P1200",
"#2P2000",
"#2P2000 T3000",
"#0P1500 #1P1500 T100",
"#0P1100 #1P1100 T100",
"#0P2000 #1P2000 T100",
"#0P1100 #1P1100 T1500",
"#0P1500 #1P1500 T1500",
"#0P2000 #1P2000 T1500",
"#9P1000S2000 T500",
"#9P2250S2000 T500",
"#8P2250S1667 T500",
"#8P1500S1667 T500",
"#8P750S1667 T300",
"#11P1200S1000 T750",
"#11P1800S1000 T750",
"#10P1100S1667 T750",
"#10P1900S1667 T750",
"#9P860S3000 #11P2500S1500",
"#9P900S2500 #11P1200S1500 #8P900S3000 #10P900S2500",
"#9P1500S2000 #11P1500S1000 T500",
"#9P2200S3000 #11P870S1500",
"#10P1100S1667 #8P2250S1667 T500",
"#10P1500S1667 #8P1500S1667 T500",
"#10P2200S1667 #8P750S1667 T500",
"#8P1500S1667 #9P1500S2000 #10P1500S1667 #11P1500S1000 T500",
"#8P1500S1667 #9P1500S2000 #10P1500S1667 #11P1500S1000 T1500",
"#5P1200 T100",
"#5P1850 T100",
"#5P2500 T100",
"#6P1500 T100",
"#6P950 T100",
"#6P650 T100",
"#6P1500 T100",
"#5P1200 #61850 T100" ,
"#5P1850 #6P950 T100",
"#5P2500 #6P650 T100",
"#4P2200",
"#4P1500",
"#4P750",
"#4P2200T1000",
"#4P1500T1000",
"#4P750T1000",
"#9P1500S2000 #11P1500S1000 #8P1000S1667 #10P1000S1667 T300",
"#9P2100S2000 #11P1800S1000 #8P1000S1667 #10P1000S1667 T300",
"#9P2100S2000 #11P1800S1000 #8P1500S1667 #10P1500S1667 T300",
"#9P2100S2000 #11P1800S1000 #8P2000S1667 #10P2000S1667 T300",
"#9P1500S2000 #11P1500S1000 #8P2000S1667 #10P2000S1667 T300",
"#9P900S2000 #11P1200S1000 #8P2000S1667 #10P2000S1667 T300",
"#9P900S2000 #11P1200S1000 #8P1500S1667 #10P1500S1667 T300",
"#9P900S2000 #11P1200S1000 #8P1000S1667 #10P900S1667 T300",
"#3P570",
"#3P600",
"#3P680",
"#3P790",
"#3P1005",
"End" };
And finally, the include "CallTest1.h". This is the file that the compiler gives me duplicate definition errors, if I make the extension .c instead of .h.
ScriptSize= 12;
MainScript= 9;
ScriptAction[ 1] = 0;
ScriptDescription[ 1] = 9;
ScriptOption[ 1] = 200;
ScriptStack[ 1] = 2;
//
ScriptAction[ 2] = 8;
ScriptDescription[ 2] = 100;
ScriptOption[ 2] = 100;
ScriptStack[ 2] = 3;
//
ScriptAction[ 3] = 0;
ScriptDescription[ 3] = 5;
ScriptOption[ 3] = 200;
ScriptStack[ 3] = 4;
//
ScriptAction[ 4] = 8;
ScriptDescription[ 4] = 100;
ScriptOption[ 4] = 100;
ScriptStack[ 4] = 5;
//
ScriptAction[ 5] = 0;
ScriptDescription[ 5] = 9;
ScriptOption[ 5] = 200;
ScriptStack[ 5] = 6;
//
ScriptAction[ 6] = 8;
ScriptDescription[ 6] = 100;
ScriptOption[ 6] = 100;
ScriptStack[ 6] = 7;
//
ScriptAction[ 7] = 0;
ScriptDescription[ 7] = 5;
ScriptOption[ 7] = 200;
ScriptStack[ 7] = 8;
//
ScriptAction[ 8] = 3;
ScriptDescription[ 8] = 0;
ScriptOption[ 8] = 0;
ScriptStack[ 8] = 0;
//
ScriptAction[ 9] = 12;
ScriptDescription[ 9] = 1;
ScriptOption[ 9] = 0;
ScriptStack[ 9] = 10;
//
ScriptAction[ 10] = 8;
ScriptDescription[ 10] = 1500;
ScriptOption[ 10] = 1500;
ScriptStack[ 10] = 11;
//
ScriptAction[ 11] = 4;
ScriptDescription[ 11] = 9;
ScriptOption[ 11] = 0;
ScriptStack[ 11] = 12;
//
ScriptAction[ 12] = 3;
ScriptDescription[ 12] = 0;
ScriptOption[ 12] = 0;
ScriptStack[ 12] = 0;
//