IF statements used in script are written a bit differently than if on a chart. If I'm understanding what you're trying to do here, I think this is what you need written differently (lines 3 and 26-28):
FOR a=1 TO 2 LET vCOD_CONTROLE = $(a); LET vPath = If($(a)=1,'MI_csv','Ultragaz QVD'); RS_SYSTEM: load $(vCOD_CONTROLE) AS COD_CONTROLE, $(vCOD_CONTROLE)&'|'&OID_SYSTEM AS OID_SYSTEM, $(vCOD_CONTROLE)&'|'&OID_GROUP AS OID_GROUP, NAME_SYSTEM, SSN_REMOTE_SYSTEM, MIN_REMOTE_SYSTEM, NUM_CONCENTRATORS, NUM_PORTS_CONCENTRATORS, CUT_RELIG_FLAG, ADDRESS_SYSTEM, ADDRESS_NUMBER_SYSTEM, NEIGHB_SYSTEM, CITY_SYSTEM, UF_SYSTEM, CEP_SYSTEM, STATUS, $(vCOD_CONTROLE)&'|'&ID_SYSTEM_TYPE AS ID_SYSTEM_TYPE FROM [lib://$(vPath)/RS_SYSTEM.qvd] (QVD); IF $(a)=2 THEN store RS_SYSTEM into [lib://MI Ultragaz/RS_SYSTEM.qvd]; ENDIF Next exit script
I already did this "If" other times and works. here a example that works in other place in my code
If((PEEK(VALOR)- VALOR)=0,OID_METER) AS EXCLUIR,
ORDER BY OID_METER,DATA,TEMPO DESC ;
This "If" works and have the same structure of the other.
You're mixing two different IFs.
1. What you use in your latest example, is a conditional function
if(condition, expression if true, expression if false)
2. The solution you needed in your opening question is the script control statement
IF ... THEN ... ELSE ... ENDIF.
You cannot replace one with the other.