Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I'm loading n xml files into QV and searching for a string (which is in an auxiliary table) in a field from these xml.
The problem is that I need to stop searching for the string when I first find it, which would be something like 'exit for', and jump to the next file. Any ideas?
Thanks!
LET NumRows=NoOfRows('Criteria');
FOR each FILE in filelist (Root&'\*.xml')
FOR i=0 to $(NumRows)-1
LET vTexto=Peek('TEXTO',$(i),'Criteria');
LET vCaract=Peek('CARACT',$(i),'Criteria');
xml:
//NFe_mod1:
LOAD
Trim(Replace(Mid([NFe/infNFe/infAdic/infCpl],Index([NFe/infNFe/infAdic/infCpl],'$(vTexto)'),$(vCaract)),'$(vTexto)','')) as nr_liq,
Num(replace([NFe/infNFe/total/ICMSTot/vNF],'.',','),'#.##0,##') as vlr_xml0,
[NFe/infNFe/emit/CNPJ] as CNPJ,
FileName([FILE]) as nome_arquivo
FROM [$(FILE)](XmlSimple, Table is [nfeProc])
WHERE Index([NFe/infNFe/infAdic/infCpl],'$(vTexto)')<>0;
//NFe_mod2:
LOAD
Trim(Replace(Mid([infNFe/infAdic/infCpl],Index([infNFe/infAdic/infCpl],'$(vTexto)'),$(vCaract)),'$(vTexto)','')) as nr_liq,
Num(replace([infNFe/total/ICMSTot/vNF],'.',','),'#.##0,##') as vlr_xml0,
[infNFe/emit/CNPJ] as CNPJ,
FileName([FILE]) as nome_arquivo
FROM [$(FILE)](XmlSimple, Table is [Nfe])
WHERE Index([infNFe/infAdic/infCpl],'$(vTexto)')<>0;
***Exit For would be here*****
NEXT
NEXT FILE
May be this
I see no if then... else... when and how do you know the condition is met? I guess where is the condition?
Hi Sunny,
The condition is the string I'm searching for (in this case the variable vTexto). I have a list of a bunch of strings and I loop through then: If I find it, it should exit my first for, otherwise, it keeps on duplicating the record since I have similar strings (eg. Num:, Num, num)
I guess that is what I am unable to follow... how do the script know that the first string value has been found?
Sorry I didnt make myself clear, but that's what I'm having difficulty!
I believe it would be something like EXIT FOR when Len(nr_liq)>0 but it's not working
The reason for your exit for is not working because "nr_liq" is a Field and
the condition EXIT FOR when Len(nr_liq)>0 will not see the field nr_liq as it is not accessable out side the load statement.
You will have to use Peek function to get a record value
hth
Sasi