I also tried doing it like this, where I just cut out the code, make a new function getfulltag(), and paste the code into getfulltag() and call getfulltag() in the space where the original code was, also not successful.
void getfulltag()
{
while ((mastFile.available()) && (!fulltag)) // runs until file ends or full tagnumber found
{
eidtest[y] = mastFile.read();
if (eidtest[y] == 13) // get rid of all \n and \r within eid number
eidtest[y] = mastFile.read();
if (eidtest[y] == 10)
eidtest[y] = mastFile.read();
if (eidtest[y] == ',') // reset EID number if ',' is found
{
eidtest[0] = '\0';
y = 0;
}
if (eidtest[y] == '!') // reset EID number if '!' is found and ++ position of current eid record
{
eidtest[0] = '\0';
y = 0;
mastFileindex++;
}
if (eidtest[y] == ' ') // get rid of spaces in ALLFLEX eid nos
eidtest[y] = '\0';
if (isAlphaNumeric(eidtest[y])) // if valid eid character, put into array
y++;
if (y == 15)
{
eidtest[y] = '\0';
fulltag = true;
}
}
}
void assignExtraInfo() // takes tag number from reader and checks it for match in mastfile.txt // runs each time a tag is read by the reader
{
eidtest[0] = '\0';
vidtest[0] = '\0';
hok[0] = '\0';
draft = '0';
fulltag = false;
match = false;
mastFileindex = 0;
y = 0;
File mastFile = SD.open(downFilename);
while ((mastFile.available()) && (!match)) // runs until eid match found between mastfile and read tag
{
getfulltag();
if (fulltag)
{
if(strcmp(EID, eidtest) == 0) // CHECK FULL TAGNUMBER IN MASTFILE AGAINST CURRENT EID
{
mastFilepos = mastFile.position();
eidtest[0] = '\0';
match = true;
int z = 0;
byte dump = mastFile.read(); // remove comma after tag number
if (dump == 13)
dump = mastFile.read();
if (dump == 10)
dump = mastFile.read();
do // IF MATCH, GIVE VALUES TO CURRENT EID'S VID, HOK, DRAFT
{
vidtest[z] = mastFile.read();
if (vidtest[z] == 13)
vidtest[z] = mastFile.read();
if (vidtest[z] == 10)
vidtest[z] = mastFile.read();
z++;
} while (vidtest[z - 1] != ',');
vidtest[z - 1] = '\0';
z = 0;
do
{
hok[z] = mastFile.read();
if (hok[z] == 13)
hok[z] = mastFile.read();
if (hok[z] == 10)
hok[z] = mastFile.read();
z++;
} while (hok[z - 1] != ',');
hok[z - 1] = '\0';
z = 0;
draft = mastFile.read();
if (draft == 13)
draft = mastFile.read();
if (draft == 10)
draft = mastFile.read();
if (draft == 49) // if draft == 1
digitalWrite(26, HIGH);
else
digitalWrite(26, LOW);
if ((hok[0] == 'B') && (hok[1] == 'W')) // determine which group was counted
BWint++;
if ((hok[0] == 'L') && (hok[1] == 'H'))
LHint++;
if ((hok[0] == 'L') && (hok[1] == 'K'))
LKint++;
if ((hok[0] == 'S') && (hok[1] == 'H'))
SHint++;
if ((hok[0] == 'S') && (hok[1] == 'K'))
SKint++;
if ((hok[0] == 'S') && (hok[1] == 'L'))
SLint++;
if ((hok[0] == 'R') && (hok[1] == 'K'))
RKint++;
}
else
{
y = 0;
eidtest[y] = '\0';
vidtest[0] = 63;
vidtest[1] = 63;
vidtest[2] = 63;
vidtest[3] = 63;
vidtest[4] = 63;
vidtest[5] = '\0';
hok[0] = 63;
hok[1] = 63;
hok[2] = '\0';
draft = '0';
fulltag = false;
}
}
}
mastFile.close();
}