I figured it out ... Had to declare the array size ....

 
I need to write each row in File 3 (below) to a new file (File 4)
if the Column 2 value in the row from File 3 is found in Column 4 in File 1 or File 2.
The first row from File 3 will not be placed in File 4 because Black is not
in Column 4 in File 1 or File 2. All other rows in File 3 will be written to File 4.
The file info and script is below. The program is not working properly
at the line Print(Var_4[m], " ", Var_7); because it is not printing out the write data.
Also File4 is not produced.


File 1:
8, Black, 3, Red, 5
10, Blue, 6, Green, 9
4, Red, 7, Blue, 12

File 2:
6, Yellow, 4, Orange, 4
5, Green, 3, Pink, 7
9, Red, 1, Gold, 2


File 3:
5, Black, 6, Purple
2, Blue, 4, Yellow
9, Green, 8, Red
12, Pink, 3, Orange

File 1 is a csv file with 3 rows and 5 columns
File 2 is a csv file with 3 rows and 5 columns
File 3 is a csv file with 4 rows and 4 columns


File 4 should read:
2, Blue, 4, Yellow
9, Green, 8, Red
12, Pink, 3, Orange

Script below:

int start()
{

int Var_1, Var_3, Var_5, Var_6, Var_8, count_1

string Var_2, Var_4[], Var_7, Var_9

int handle1 = FileOpen("File1", FILE_CSV|FILE_READ, ",");

for(int j=0; j<3; j++)

{
Var_1 = FileReadNumber(handle1);
Var_2 = FileReadString(handle1);
Var_3 = FileReadNumber(handle1);
Var_4[j] = FileReadString(handle1);
Var_5 = FileReadNumber(handle1);
k=j+1;
}

FileClose(handle1);

handle1 = FileOpen("File2", FILE_CSV|FILE_READ, ",");

for(j=0; j<3; j++)

{
Var_1 = FileReadNumber(handle1);
Var_2 = FileReadString(handle1);
Var_3 = FileReadNumber(handle1);
Var_4[j+k] = FileReadString(handle1);
Var_5 = FileReadNumber(handle1);
}

FileClose(handle1);

int handle2 = FileOpen("File3", FILE_CSV|FILE_READ, ",");
int count_2=0;

for(int t=0; t<4; t++)
{
Var_6 = FileReadNumber(handle2);
Var_7 = FileReadString(handle2);
Var_8 = FileReadNumber(handle2);
Var_9 = FileReadString(handle2);

m=0;
while (Var_4[m]!= Var_7 && m < 6)
{
m++ ;
Print(Var_4[m], " ", Var_7);
}

if (Var_4[m] == Var_7)
{
if (count_2==0)
{
int handle3 = FileOpen("File4", FILE_CSV|FILE_WRITE, ",");
FileWrite(handle3, Var_6, Var_7, Var_8, Var_9);
count_2 ++;
FileClose(handle3);
// Print("Step 5");
}

else
{
handle3 = FileOpen("File4", FILE_CSV|FILE_READ|FILE_WRITE, ",");
FileSeek(handle3, 0, SEEK_END);
FileWrite(handle3, Var_6, Var_7, Var_8, Var_9);
count_2 ++;
FileClose(handle3);
}
}
}

FileClose(handle2);

}
 
phillw:

I need to write each row in File 3 (below) to a new file (File 4)
if the Column 2 value in the row from File 3 is found in Column 4 in File 1 or File 2.
Please use this to post code . . . it makes it easier to read.