Syntax error?

When I do a test compile I get an error pointing to the last line around the “endif” What am I missing? This worked until I added the last four “if” statements.

if (DW_Pop1_Up==1) then
  DW_air_pop1=0;
endif
 if (DW_Pop1_Dn==1) then
  DW_air_pop1=1;
endif
 if (DW_Pop2_Up==1) then
  DW_air_pop2=1;
endif
 if (DW_Pop2_Dn==1) then
  DW_air_pop2=0;
endif
 if (Maf_pop1_up==1) then
  Maf_air_pop1=1;
endif
 if (Maf_pop1_Dn==1) then
  Maf_air_pop1=0;
endif
 if (Maf_pop2_up==1) then
  Maf_air_pop2=1;
endif
 if (Maf_pop2_Dn==1) then
  Maf_air_pop2=0;
endif
 if (DW_transfer_F==1) then
  m2f_DW_Crossover=1;
else
  m2f_DW_Crossover=0;
endif
 if (DW_transfer_R==1) then
  m2r_DW_Crossover=1;
else
  m2r_DW_Crossover=0;
endif
 if (DW_sChain_F==1) then
  m10f_DW_sChain=1;
  M12_Corner=1;
else
  m10f_DW_sChain=0;
  if (Lower_Chains_F==0) then
    M12_Corner=0;
  endif
endif
 if (DW_sChain_R==1) then
  m10r_DW_schain=1;
else
  m10r_DW_schain=0;
endif
 if (Maf_transfers_F==1) then
  m5f_Maf_Crossover=1;
  m4f_Maf_Pop1=1;
  m6f_Maf_Pop2=1;
else
  m5f_Maf_Crossover=0;
  m4f_Maf_Pop1=0;
  m6f_Maf_Pop2=0;
endif
 if (Maf_transfers_R==1) then
  m5r_Maf_Crossover=1;
  m4r_Maf_Pop1=1;
  m6r_Maf_Pop2=1;
else
  m5r_Maf_Crossover=0;
  m4r_Maf_Pop1=0;
  m6r_Maf_Pop2=0;
endif
 if (Lower_Chains_F==1) then
  M12_Corner=1;
  m7f_Lower_MainChain=1;
else
  if (DW_sChain_F==0) then
    M12_Corner=0;
  endif
  m7f_Lower_MainChain=0;
endif
 if (Lower_Chains_R==1) then
  m7r_Lower_MainChain=1;
else
  m7r_Lower_MainChain=0;
endif
 //DW top chains
//Forward
if (DW_TopChain_f==1) then
  m1f_DW_Top_Chain=1;
else
  if (DW_TopChain_f==0) then
  m1f_DW_Top_Chain=0;
endif
//Reverse
if (DW_TopChain_r==1) then
  m1r_DW_Top_Chain=1;
else
  if (DW_TopChain_f==0) then
  m1f_DW_Top_Chain=0;
endif
 //Maf top chains
//Forward
if (Maf_TopChain_f==1) then
  m3f_Maf_Top_Chain=1;
else
  m3f_Maf_Top_Chain=0;
endif
//Reverse
if (Maf_TopChain_r==1) then
  m3r_Maf_Top_Chain=1;
else
  m3r_Maf_Top_Chain=0;
endif

Can you export your chart and attach it? (Even copy just this block to a chart to export.)
To find mis-matched if/thens like this I usually use block comments and narrow it down a piece at a time, know what I mean? We have a video in the works about this too…

I caught it. The test compile checker is frustrating. The error was 15 + lines above where indicated… My “else” statements were not quite right.
The debug part of Optoscript is pretty poor/vague.

Looks like you’re missing and endif about 13 lines from the bottom, just above the “Maf top chains” comment…

if (DW_Pop1_Up==1) then
  DW_air_pop1=0;
endif
 if (DW_Pop1_Dn==1) then
  DW_air_pop1=1;
endif
 if (DW_Pop2_Up==1) then
  DW_air_pop2=1;
endif
 if (DW_Pop2_Dn==1) then
  DW_air_pop2=0;
endif
 if (Maf_pop1_up==1) then
  Maf_air_pop1=1;
endif
 if (Maf_pop1_Dn==1) then
  Maf_air_pop1=0;
endif
 if (Maf_pop2_up==1) then
  Maf_air_pop2=1;
endif
 if (Maf_pop2_Dn==1) then
  Maf_air_pop2=0;
endif
 if (DW_transfer_F==1) then
  m2f_DW_Crossover=1;
else
  m2f_DW_Crossover=0;
endif
 if (DW_transfer_R==1) then
  m2r_DW_Crossover=1;
else
  m2r_DW_Crossover=0;
endif
 if (DW_sChain_F==1) then
  m10f_DW_sChain=1;
  M12_Corner=1;
else
  m10f_DW_sChain=0;
  if (Lower_Chains_F==0) then
    M12_Corner=0;
  endif
endif
 if (DW_sChain_R==1) then
  m10r_DW_schain=1;
else
  m10r_DW_schain=0;
endif
 if (Maf_transfers_F==1) then
  m5f_Maf_Crossover=1;
  m4f_Maf_Pop1=1;
  m6f_Maf_Pop2=1;
else
  m5f_Maf_Crossover=0;
  m4f_Maf_Pop1=0;
  m6f_Maf_Pop2=0;
endif
 if (Maf_transfers_R==1) then
  m5r_Maf_Crossover=1;
  m4r_Maf_Pop1=1;
  m6r_Maf_Pop2=1;
else
  m5r_Maf_Crossover=0;
  m4r_Maf_Pop1=0;
  m6r_Maf_Pop2=0;
endif
 if (Lower_Chains_F==1) then
  M12_Corner=1;
  m7f_Lower_MainChain=1;
else
  if (DW_sChain_F==0) then
    M12_Corner=0;
  endif
  m7f_Lower_MainChain=0;
endif
 if (Lower_Chains_R==1) then
  m7r_Lower_MainChain=1;
else
  m7r_Lower_MainChain=0;
endif
 //DW top chains
//Forward
if (DW_TopChain_f==1) then
  m1f_DW_Top_Chain=1;
else
  if (DW_TopChain_f==0) then
  m1f_DW_Top_Chain=0;
endif
//Reverse
if (DW_TopChain_r==1) then
  m1r_DW_Top_Chain=1;
else
  if (DW_TopChain_f==0) then
  m1f_DW_Top_Chain=0;
endif
 //Maf top chains
//Forward
if (Maf_TopChain_f==1) then
  m3f_Maf_Top_Chain=1;
else
  m3f_Maf_Top_Chain=0;
endif
//Reverse
if (Maf_TopChain_r==1) then
  m3r_Maf_Top_Chain=1;
else
  m3r_Maf_Top_Chain=0;
endif

I wish we had a better OptoScript editor – better code editors will match your if to endif for you with a little line or something…