PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Compile & ExecuteProcess - Part II - Very confused
Compile & ExecuteProcess - Part II - Very confused
Débuté par Guillermo, 19 juin 2005 18:47 - 3 réponses
Posté le 19 juin 2005 - 18:47
Iam confused... the following code works correctly if I put the code into a Button
//***************************************************************************
micampo1 is currency
micampo2 is currency
i is int
FOR i = 1 TO HNbRec(DEMO_Novedades)
HRead(DEMO_Novedades,i)
HReadSeek(DEMO_Conceptos,DEMO_Conceptos.ConceptoID,DEMO_Novedades.ConceptoID)
IF HFound(DEMO_Conceptos) THEN
micampo1 = DEMO_Conceptos.ConceptoValor
ELSE
micampo1 = 0
END
micampo2 = micampo2 + (micampo1 * DEMO_Novedades.ConceptoCant)
END
Info(micampo2)
//***************************************************************************
Ok, now I want to process this code with Compile & ExecuteProcess
Formuleo = "micampo1 is currency" +CR+ ...
"micampo2 is currency"+CR+ ...
"i is int"+CR+ ...
"FOR i = 1 to HNbRec(DEMO_Novedades)"+CR+ ...
" HRead(DEMO_Novedades,i)"+CR+ ...
" HReadLast(DEMO_Conceptos)"+CR+ ...
" HReadSeek(DEMO_Conceptos,DEMO_Conceptos.ConceptoID,Demo_Novedades.ConceptoID)"+CR+ ...
" IF HFound(DEMO_Conceptos) THEN"+CR+ ...
" micampo1 = DEMO_Conceptos.ConceptoValor"+CR+ ...
" ELSE"+CR+ ...
" micampo1 = 0"+CR+ ...
" END"+CR+ ...
" micampo2 = micampo2 + (micampo1 * DEMO_Novedades.ConceptoCant)"+CR+ ...
"END"+CR+ ...
"result(micampo2)"
Note the HReadLast(DEMO_Conceptos), if this line is omitted, the compile & execute display the following message
Error in LaFormula process, line 6.
HReadSeek function called.
<0> item not found in file.
Thanks ... Guillermo
Posté le 20 juin 2005 - 12:37
HReadLast() needs a order to determin the last record. No view or 'order by' is used so windev has no 'last used index'.
Try fill the second parameter with a index-field.
tip:
Copy your procedure to clipboard (ToClipboard(Text)) and past it back in a test button, easier to check the code.
Iam confused... the following code works correctly if I put the code into a Button
//***************************************************************************
micampo1 is currency
micampo2 is currency
i is int
FOR i = 1 TO HNbRec(DEMO_Novedades)
HRead(DEMO_Novedades,i)
HReadSeek(DEMO_Conceptos,DEMO_Conceptos.ConceptoID,DEMO_Novedades.ConceptoID)
IF HFound(DEMO_Conceptos) THEN
micampo1 = DEMO_Conceptos.ConceptoValor
ELSE
micampo1 = 0
END
micampo2 = micampo2 + (micampo1 * DEMO_Novedades.ConceptoCant)
END
Info(micampo2)
//***************************************************************************
Ok, now I want to process this code with Compile & ExecuteProcess
Formuleo = "micampo1 is currency" +CR+ ...
"micampo2 is currency"+CR+ ...
"i is int"+CR+ ...
"FOR i = 1 to HNbRec(DEMO_Novedades)"+CR+ ...
" HRead(DEMO_Novedades,i)"+CR+ ...
" HReadLast(DEMO_Conceptos)"+CR+ ...
" HReadSeek(DEMO_Conceptos,DEMO_Conceptos.ConceptoID,Demo_Novedades.ConceptoID)"+CR+ ...
" IF HFound(DEMO_Conceptos) THEN"+CR+ ...
" micampo1 = DEMO_Conceptos.ConceptoValor"+CR+ ...
" ELSE"+CR+ ...
" micampo1 = 0"+CR+ ...
" END"+CR+ ...
" micampo2 = micampo2 + (micampo1 * DEMO_Novedades.ConceptoCant)"+CR+ ...
"END"+CR+ ...
"result(micampo2)"
Note the HReadLast(DEMO_Conceptos), if this line is omitted, the compile & execute display the following message
Error in LaFormula process, line 6.
HReadSeek function called.
<0> item not found in file.
Thanks ... Guillermo
Posté le 21 juin 2005 - 03:24
Theo:
Yes, HreadLast need a second parameter, but is not the case in my question.
Why, if HReadLast is not codified the compile instruction work correctly, but Execute doesn't work ?

I put the code into a button (as you say), and work fine, without HReadLast.

I will attempt with the suggestion of Piet, about the "quotes for the hyperfile file- and keynames."
Regards Guillermo
Posté le 21 juin 2005 - 10:29
Guillermo
during executing in the button the Analysis is present, this isn't the case in the compiled code.
HTH
Raimund
Theo:
Yes, HreadLast need a second parameter, but is not the case in my question.
Why, if HReadLast is not codified the compile instruction work correctly, but Execute doesn't work ?

I put the code into a button (as you say), and work fine, without HReadLast.

I will attempt with the suggestion of Piet, about the "quotes for the hyperfile file- and keynames."
Regards Guillermo



http://www.invitec.com