Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables Not Working In A For Loop

I have been trying to loop through a collection of qvd files to extract field data from them.  However, I keep getting the following error:  "Syntax error, missing/misplaced FROM: QVD_METADATA:"  In the script body displayed in the error message, I also see that the variables have vanished from the places where I placed them in the script (not in the script itself, just in the script body displayed in the error message).

It appears the variables are not being created or assigned values.  But, I can't see where the problem lies.  Does anyone have any experience with this?  Here is the code I am using:

QVD_DATA:

LOAD

   *

  , Date(Today(), 'DD-MMM-YYYY') AS UPDATE_DATE_QVD_METADATASET

;

LOAD

  [QV File Name],

     [QVD Full Path]

FROM

$(vInputFile1)

(ooxml, embedded labels, table is [Data Links]);

Let vRowNum = NoOfRows('QVD_DATA'); /*Get total number of rows for the loop to do its thing*/

For i = 1 To $(vRowNum)

  Let vQvdPath = FieldValue([QVD Full Path],$(i)); /*Assign each qvd file path to a variable to be used as the path in the metadata extraction load*/

  Let vFileName = FieldValue([QV File Name],$(i));

  QVD_METADATA:

  LOAD

     1                      as FieldCount,

     $(vFileName)   as [File Name],

     FieldName              as [Field Name],

     BitOffset              as [Bit Offset],

     BitWidth               as [Bit Width],

     Bias                   as [Bias],

     NoOfSymbols            as [No Of Symbols],

     [NumberFormat/Type]    as Type,

     [NumberFormat/nDec]    as Dec,

     [NumberFormat/UseThou] as UseThou

  FROM $(vQvdPath) (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

Next i

16 Replies
jsakalis
Contributor III
Contributor III

Hi Eugene,

     Try putting quotes around $(vFileName):     '$(vFileName)'   as [File Name],

cwolf
Creator III
Creator III

There will be spaces in the $(vQvdPath) and $(vFileName) has to be in quotes. Try this:

QVD_METADATA:

  LOAD

     1                      as FieldCount,

     '$(vFileName)'   as [File Name],

     FieldName              as [Field Name],

     BitOffset              as [Bit Offset],

     BitWidth               as [Bit Width],

     Bias                   as [Bias],

     NoOfSymbols            as [No Of Symbols],

     [NumberFormat/Type]    as Type,

     [NumberFormat/nDec]    as Dec,

     [NumberFormat/UseThou] as UseThou

  FROM [$(vQvdPath)] (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

vinieme12
Champion III
Champion III

Debug your script to see which one of the variables isn't evaluating

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

Thank you, John and Christian, those are good suggestions.  However, the same error keeps getting thrown.  It has something to do with the variables not getting evaluated, because they are not being created or initialized.  If, after execution, I go and look at the variables using 'Settings/Variable Overview', the vRowNum variable is there.  But, the vFileName and vQvdPath variables are not there.

Not applicable
Author

The vQvdPath and vFileName variables are not assigned any values, and the [QV File Name] and [QV Full Path] fields from the QVD_DATA load at the start of the script also have NULL values.  Something isn't loading right in the Load portion of the For loop.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Well, it's quotes, quotes and some more quotes. You're nearly there.

The two variables that aren't being created appear in a LET assignment with function FieldValue. Those don't seem to be working, correct? You specify the field content as first parameter, but the QV Desktop help carries an example of how this function should be called:

20160726 FieldValue Help.jpg

See? The field name should be specified as a string. Quotes. Damn quotes...

Good luck,

Peter

vinieme12
Champion III
Champion III

What is vRowNum evaluating to, does your code even enter the for loop?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

on the top right corner of the screen , below file menu Click on Debug and Step into your code line by line to check

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

vRowNum evaluates to 1347, which is the correct number of rows.  vQvdPath and vFileName evaluate to NULL.  After these are evaluated the script error is then thrown.