21.01.2013 Views

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

var is a script variable name which will acquire a new value from list for each loop execution. If var is specified<br />

after next it must be the same variable name as the one found after the corresponding for each.<br />

list := item { , item }<br />

item := constant | (expression) | filelistmask | dirlistmask<br />

constant is any number or string.<br />

expression is an arbitrary expression.<br />

mask is a filename or directory name mask which may include any valid filename characters as well as the<br />

standard wildcard characters, * and ?.<br />

condition is a logical expression evaluating to true or false.<br />

statements is any group of one or more <strong>QlikView</strong> script statements.<br />

The filelist mask syntax produces a comma separated list of all files in the current directory matching the filename<br />

mask. The dirlist mask syntax produces a comma separated list of all directories in the current directory<br />

matching the directory name mask.<br />

The value of the var variable may be changed by statements inside the loop, but this is not good programming<br />

practice.<br />

If an exit for clause is encountered inside the loop, the execution of the script will be transferred to the first<br />

statement after the next clause denoting the end of the loop. An exit for clause can be made conditional by<br />

the optional use of a when or unless suffix.<br />

Since the for each..next statement is a control statement and as such is ended with either a semicolon or endof-line,<br />

each of its three possible clauses (for each, exit for and next) must not cross a line boundary.<br />

Examples:<br />

for each a in 1,3,7,'xyz'<br />

load * from file$(a).csv;<br />

next<br />

// list all QV related files on disk<br />

sub DoDir (Root)<br />

for each Ext in 'qvw', 'qva', 'qvo', 'qvs'<br />

for each File in filelist (Root&' \*.' &Ext)<br />

Load '$(File)' as Name, FileSize( '$(File)' ) as<br />

Size, FileTime( '$(File)' ) as FileTime<br />

autogenerate 1;<br />

next File<br />

next Ext<br />

for each Dir in dirlist (Root&' \*' )<br />

call DoDir (Dir)<br />

next Dir<br />

end sub<br />

call DoDir ('C:')<br />

Back to Script Statements and Keywords (page 219).<br />

235

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!