Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Syntax error

Hi All,

Can anyone explain why the Script Editor is giving me a syntax error on the following:

UNIQUECITYSUPPS:

load

  distinct CITYSUPPLIER as CITYSUPPLIERA

Resident

  CONTRACTHEADERS;

let vCSRecords = NoOfRows('UNIQUECITYSUPPS');

let vSDRecords = NoOfRows('SMASTERCALENDAR');

let vCHRecords = NoOfRows('CONTRACTHEADERS');

// set up blank table.

CONTRACTDATA:

LOAD * INLINE [

CITYSUPPLIERA, SDATEA, CONTRACTNUMBERA

];

for i = 1 to $(vCSRecords)

  let vCitySupplier = chr(39) &  Peek('CITYSUPPLIERA', $(i), 'UNIQUECITYSUPPS') & chr(39);

  for j = 1 to $(vSDRecords)

  //let vCitySupplierA = Peek('CITYSUPPLIERA', $(i), 'UNIQUECITYSUPPS');

  let vThisDate = chr(39) & Peek('SDATE', $(j),'SMASTERCALENDAR') & chr(39);

  TEMPTABLE:

  noconcatenate load

  CONTRACTNUMBER,

  FAIRID,

  CITYSUPPLIER,

  VALIDFROM,

  VALIDTO

  Resident

  CONTRACTHEADERS

  where

  CITYSUPPLIER = $(vCitySupplier)

  and (VALIDFROM >= $(vThisDate) and VALIDTO <= $(vThisDate));

  let vTempRecords = NoOfRows('TEMPTABLE');

  if($(vTempRecords)=0,1,2);

  drop table TEMPTABLE;

  next;

next;

For some reason it's complaining about the first comma in the if statement at the end. Take out that if statement and everything is OK...


Thanks,

Rory.

4 Replies
maxgro
MVP
MVP

if ... then ... else ...

//  if($(vTempRecords)=0,1,2);

  if $(vTempRecords)=0 then

  seta=1;

  ELSE

  set a=2;

  endif;

Not applicable
Author

Hi Massimo,

II'm in the standard Qlikview script editor, even the help on that screen defines the if statement as 'dual If (condition, then_expr [, else_expr])'

Rory

Gysbert_Wassenaar

That if statement doesn't make sense there. What do you expect it to do? I'd expect something like:

if( $(vTempRecords)=0 then

     // do stuff

else

    // do other stuff

end if


talk is cheap, supply exceeds demand
maxgro
MVP
MVP

if(condition , then , else)   is a function


if ... then

     ...

else

     ...

endif


is a control statement


I tkhink you need the second one