Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a series of script tabs each of which creates a qvd. This is all fine.
I want to be able to quickly select which parts of the script to reload and which parts not. I have been /*...*/ the bits I don't want.
Don't like that, so I have created a variable for each script section in the document, e.g. 201011AC can be 0 or 1.
I have tried to use IF...END IF around my script dependent upon 201011AC, e.g. :
IF 201011AC = 1 THEN
...
END IF
But this does not work and I get a "Script line error" for the IF statement line.
What do I need to do to get this to work?
Thanks
Russell
Hi
If you set your variable in the app e.g. by an action or macro then the variable is directly available in the load script.
I have made a small example.
2 different INLINE loads are made depending on the variable value.
Regards
Jürg
Hi
I use a folder for my fact QVD's and create a list of the available files in a list box.
// available QVD files
// -------------------
For each File in filelist('$(QVDPath)\PunDay*.qvd')
namepos = index('$(File)','_') + 1;
AvailableDays:
LOAD mid('$(File)',$(namepos),10) as AvailableDay
, Weekday(date#(mid('$(File)',$(namepos),10),'yyyy-mm-dd')) as AvailableWeekday
Autogenerate 1;
Next File; <div>
</div><div><div>Sub LoopSelections()</div><div></div><div>Control = ActiveDocument.Variables("vControl").GetContent.String </div><div>'msgbox "Control: " & Control</div><div>Set oLB = ActiveDocument.getsheetobject(Control)</div><div>sDates = ""</div><div></div><div>'msgbox GetFieldSelections("AvailableMonth")</div><div></div><div>' loop the ListBox items and create a comma separated variable with the entries</div><div>sFiles = ""</div><div>For iLoop = 0 To oLB.GetRowCount - 1</div><div></div><div> ' item selected</div><div> Set oCell = oLB.GetCell(iLoop,0)</div><div> ' MsgBox "cell: " & oCell.Text & " state: " & oCell.State</div><div> </div><div> If oCell.State < 3 Then</div><div> ' for month selections use the first day of the month</div><div> if len(oCell.Text) = 7 then</div><div> sFiles = sFiles & oCell.Text & "-01,"</div><div> else</div><div> sFiles = sFiles & oCell.Text & ","</div><div> end if </div><div> End If</div><div>Next</div><div></div><div>ActiveDocument.CreateVariable("vLoadFiles")</div><div>ActiveDocument.GetVariable("vLoadFiles").SetContent sFiles,false </div><div>ActiveDocument.Reload</div><div></div><div>End Sub</div><div>
</div><div><div> Let vNofFiles = substringcount('$(vLoadFiles)', ',');</div><div> </div><div> For iLoop = 1 to vNofFiles</div><div> </div><div> // build the file name in the form PunDay_YYYY-MM-DD</div><div> Let vCurrName = vType & '_' & SubField('$(vLoadFiles)', ',', iLoop) & '.QVD'; </div><div>... </div><div>
We use this technique a lot.
Let _DoThisPart = 0;
...
If _DoThisPart = 1 Then
// code that should only be used if _DoThisPart equals 1
End If // If _DoThisPart ...
I don't now if the problem is that your variable name starts with a digit?
Hi Göran K,
Thanks for the post, but it does not get around my problem.
I want a document variable, which can be altered by the user, to be determining whether the script is run or not.
Your suggestion would still require the user to amend the variable within the script, i.e. change to Let _DoThisPart = 1.
When I try to refer to any document variable, all I get is a string of the script, e.g.:
SET vRun = ActiveDocument.Variables("200809AC");
vRun is initialised as "ActiveDocument.Variables("200809AC")"
I have tried it with variable names beginning with v, but it makes no difference!
HELP!!?!?
I don't know if this helps but I think I am right in syaing that QlikView does not understand the concept of ActiveDocument when it is running the script, so you assignment to a variable in run time to affect the load script I don't think will work.
Not sure if there is any workaround for this, sorry.
Hi
If you set your variable in the app e.g. by an action or macro then the variable is directly available in the load script.
I have made a small example.
2 different INLINE loads are made depending on the variable value.
Regards
Jürg
Thank you Juerg, this is the perfect solution to my problem.
Couple of points for anyone else following this thread:
name your variables starting with a letter not a number
remember to add a trailing semi-colon to the end if statement!