Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
swuehl
MVP
MVP

What do you mean with 'previous script'?

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

View solution in original post

2 Replies
swuehl
MVP
MVP

What do you mean with 'previous script'?

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

Colin-Albert

You need to define the subroutine ScanFolder first.

Then you can call this in the FilesLoad subroutine.