Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This is my Sub:
sub FilesLoad(Root,FileName,RunIdList)
let vTableName = '$(FileName)';
let vRunList = '$(RunIdList)';
let vConcatenate = ;
sub ScanFolder(Root)
for each FoundFile in filelist(Root&'\*.csv')
let vTemp= subfield('$(FoundFile)','\',-3);
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
This is how I call the sub:
set vList = 1;
set vRoot = 'C:\decisioning\log\dcs\';
call FilesLoad('$(vRoot)','DCS_META_DATA','$(vList)')
When I send it like this, it works and creates a table.
but when I send it with a list in the last param it crashes.
set vList = 1,3;
set vRoot = 'C:\decisioning\log\dcs\';
call FilesLoad('$(vRoot)','DCS_META_DATA','$(vList)')
It crashes in the Sub in the : for each FoundFile in filelist(Root&'\*.csv')
What can be wrong?
Thanks,
Boris
Boris
Have you tried calling without the $ expansions?
call FilesLoad(vRoot, 'DCS_META_DATA', vList)
HTH
Jonathan
I am suspecting the vList should have only one value. Try Like below:
Let vList = '1,3';
For i= 1 to substringcount('$(vList)' , ',' ) +1
Let vListi = subfield('$(vList)' ,',' , $(i)) ;
call FilesLoad('$(vListi)', 'DCS_META_DATA', '$(vList)')
Next i;
The error is caused by the sub line above the "for each FileFound" line.
You cannot define another subroutine within the first subroutine.
Define the inner subroutine first, then call it from the outer subroutine.