Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
vadimtsushko
Partner - Creator III
Partner - Creator III

Request for change in vL.FileExist function.

Hi all.

I've recently found that vL.FileExist function is unsufficiently robust in QDF.

Consider that snippet from QVD-Generator-Example of 1.Example container (QDF version 1.4.0).

// Folder for output QVDs use

// Use QlikView Deployment Framework Variable $(vG.QVDPath)

LET vL.QVDPath = '$(vG.QVDPath)';

// Check if folder exists by using function call vL.FileExist

call vL.FileExist ('$(vL.QVDPath)*')

if vL.FileExist = 'false' then; trace '### DF Did not find $(vL.QVDPath), exit script'; sleep 5000 ;exit script; endif;

Apparently we should be calm about QVD folder existence after that check. But if I deliberately remove 2.QVD folder from 1.Example container script still moves futher.

Some debugging shows that if I physically remove 2.QVD directory, vG.QVDPath variable becomes empty and effectively we call vL.FileExist function with parameter '*' - and that always return true. That is not good, because function would return same falsely positive result if I for example misspell path variable:

call vL.FileExist ('$(vG.QvdPath)');

or even

call vL.FileExist ('$(vG.ABRACADABRA));

would return true.

On the other hand we cannot simply omit trailing star when check for QDF paths, because they all have a trailing '\' and vL.FileExist always return false on directory path with trailing '\'.

So my proposal is twofold:

1. Change vL.FileExist so that it remove trailing '\' from parameter if it present.

2. Change examples and docs to discurage using * in vL.FileExist paramteter.

Proposed variant of function with added  lines 2-4

sub vL.FileExist (vL.Root)

  if Right('$(vL.Root)',1) = '\' then

    LET vL.Root = Left(vL.Root,Len(vL.Root)-1);

  endif

  if IsNull(filesize('$(vL.Root)')) = -1  then

  SET vL.FileExist='false';

    else

  SET vL.FileExist='true';

  endif

  set vL.Root=;

end sub;

vG.QVDPathvG.QVDPath

4 Replies
Magnus_Berg
Employee
Employee

Thanks Vadim, we will validate and add your addition

Best Regards

Magnus

Magnus_Berg
Employee
Employee

Thanks again Vadim, I have validated your modification but found out that the biggest problem with this example is the trailing *.

This will create a false true if a variable is null for example:
call vL.FileExist ('$(NullVariable)*);

Will return true as the function will search for * in the current app location (relative path).

I've added a warning into development guide and will remove * in all examples.

Best regards

Magnus

vadimtsushko
Partner - Creator III
Partner - Creator III
Author

Magnus, I believe this is interrelated problem.

For example you cannot simply remove * from that QVD-Generator-Example.qvw because

call vL.FileExist ('$(vL.QVDPath)')

would return false even in normal situation when 2.QVD folder actually exists. Because vG.QVDPath variable  ends with '\'.

So it should be firstly function change and then change in all examples and docs.

Magnus_Berg
Employee
Employee

Agree, did that as well

The fix is out now (still 1.4.0).

Cheers