Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everybody !
I'm a new user for the awesome tool QlikView and i have a few questions about it.
=if(Country='France','FR',
if(Country='Austria','AUS',
Country))
=switch Country
case 'France'
'FR';
case 'Austria'
'AUS';
default
Country;
end switch
For the files, i've thought about the FileSize function but .... not working ...
LET vFileName = 'file1.txt';
LET vSize = filesize($(vFileName));
if($(vSize)>0,MsgBox('ok'),MsgBox('ko'));
I think it's enough for a first post 😉
For the switch statement, a full command must be placed for each case/scenario. Let me edit your code so it becomes more like this...
=switch Country
case 'France'
LER Country = 'FR';
case 'Austria'
LET Country = 'AUS';
default
LET Country = Country;
end switch
in your filesize function, try removing the dollar expansion in your if so it becomes like
if(vSize>0, etc. etc.)
Hi,
For the filesize function, try putting the filename variable in single quotes as it is a string value:
LET vSize = filesize('$(vFileName)');Thanks rainong, but i don't think its working
=switch Country
case 'FR'
LET Country = 'France';
case 'UK'
LET Country = 'UnitedKinkgdoms';
default
LET Country = Country;
end switch
it displays an empty list box.... 😐
And, for your other answer,
//LET vFileName = 'file1.txt';
LET vSize = filesize('file1.txt');//$(vFileName));
if($(vSize)>0,
MsgBox('ok','cool'),
MsgBox('ko','dead')
I see Frank,
it does seem like msgbox is causing the issue since the vSize variable is at least populated.
Try this approach instead:
LET vFileName = 'file1.txt';
LET vSize = filesize('$(vFileName)');
if $(vSize)>0 then
let mbox1=msgbox('ok');
else
let mbox1=msgbox('ko');
end if
Thanks Jsn, it's working !! 😉
Now my next question is do you know how it is possible to "return" a value (for instance, the script didn't finish successfull and i would like to notify the publisher of this...). Moreover,does QV provide a die() function ? Indeed, the aim of this script is to check the availability of the datasources and, if the datasources are OK, it launches the next process (the QVD creation). However, if we want this to be successfull, it means QV and QV Publisher can exchange values...
Thanks Jsn 😄
The way to exit a script is with the statement:
exit script;
I believe I saw an earlier post about generating an error exit by conditionally executing a statement that will fail such as:
LOAD * FROM nofile.txt;
You can also use the TRACE script statement to write messages to the logfile.
-Rob
Well,
To stop the script execution you can use the "Exit Script" statement that can also take a when condition.
As for getting several QV reloads to work together, couldn't you use QV Publisher and dependencies? A dependency between two tasks only launches the second task if the first one finished without errors.
I tried to test the script when the file is missing.
QV crashes when i try to get the size of a missing file:
LET vFileName = 'file2.txt';
LET vSize = filesize('$(vFileName)');
if ($(vSize)>0) then
let mbox1=msgbox('ok');
else
let mbox1=msgbox('ko');
end if
Does someone know on which version are QV Publisher dependencies included ? I remember there are two Publisher versions, Standard & Enterprise Editions .
Thanks for your help...
ANd about the switch syntax, can someone help me ? 😉
<pre>=switch Country
case 'FR'
LET Country = 'France';
case 'UK'
LET Country = 'UnitedKinkgdoms';
default
LET Country = Country;
end switch