Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Error in calling a subroutine

Hi all,

I have written this Sub in a sheet:

sub FilesLoad(Root,FileName,RunIdList)

  let vTableName = '$(FileName)';

  let vRunList = '$(RunIdList)';

  let vConcatenate = ;   

  sub ScanFolder(Root)           

        for each FoundFile in filelist( Root & '\*.csv') 

  if(match(subfield('$(FoundFile)','\',-3), '$(vRunList)')) then

  if (match(upper(left(mid('$(FoundFile)', index('$(FoundFile)', '\', -1) +1), len(mid('$(FoundFile)', index('$(FoundFile)', '\', -1) +1)) -19)),'$(vTableName)')) then 

                $(vTableName):   

                $(vConcatenate)   

                LOAD *  

                FROM '$(FoundFile)' (txt, codepage is 1252, no labels, delimiter is '|', msq);   

                endif

                Set vConcatenate = Concatenate;

            ENDIF    

         next FoundFile  

    for each SubDirectory in dirlist( Root & '\*' )   

        call ScanFolder(SubDirectory)   

    next SubDirectory

    STORE '$(vTableName)' into 'C:\test\$(vTableName).qvd' (qvd);   

  end sub

  call ScanFolder(Root)

end Sub

then in the previous script I call this sub:

let vRoot = 'C:\decisioning\log\dcs';

  call FilesLoad('$(vRoot)','DCS_META_DATA','1')

and I get:

Script line error:

call FilesLoad('C:\decisioning\log\dcs','DCS_META_DATA','1')

Can someone assist?

thanks,

Boris

1 Solution

Accepted Solutions
MVP
MVP

Re: Error in calling a subroutine

What do you mean with 'previous script'?

I believe you can only CALL as SUB if your script execution already passed the SUB definition.

2 Replies
MVP
MVP

Re: Error in calling a subroutine

What do you mean with 'previous script'?

I believe you can only CALL as SUB if your script execution already passed the SUB definition.

Re: Error in calling a subroutine

You need to define the subroutine ScanFolder first.

Then you can call this in the FilesLoad subroutine.

Community Browser