Page 1 of 1
2.6a vs 2.8.1 Primitive Replace Test
Posted: Wed Jun 09, 2021 9:02 pm
by jpmoschi
Good morning forum, I am trying to jump from 2.6a to the last revision but i have primitive problems.
The next is a part of conseptual tests passed in revision 2.6a that fail in the last one
Attached a screen capture error catched in the code line below a fail comment
Best regards
Juan
Code: Select all
method TestReplace
private stext
STORE SqlConnect("MSSQLTEST") to _handle
LRESULT:= SqlExec(_handle , "select * from m02clie","m02clie")
IF LRESULT >0
DBGoTop()
stext:= ""
MALIAS:= ALIAS()
DO WHILE (!Eof())
FieldPutSelect(Alias(),"M02NOMBRE" , "CAMBIADO "+ LTrim(Str(RecNo())))
DbSkip()
ENDDO
// until here the test is passed!!!!
local pblock := {||
FieldPutAlias(Alias(),"m02domicil","domicil ")
FieldPutAlias(Alias(),"m02nombre","nombre ")
return 0
}
local pconditionFor:= {|| (Mod(RecNo(),2)=0) }
// FAIL!!! next line produce error, see the screen capture
if DbEval(pblock, pconditionFor )
stext:= "ok"
DbEval({|| stext:= stext + chr(13)+ m02domicil +"-" + m02nombre})
else
stext:= "er"
endif
endif
2.6a vs 2.8.1 Primitive Replace Test
Posted: Thu Jun 10, 2021 1:56 pm
by robert
Juan,
I am not sure what you are trying to do in the code on the bottom.
Without the rest of the code example database I find it hard to see where the problem is.
The error messages seems to indicate that somewhere in the code the runtime tries to convert a LOGIC value to a CODEBLOCK. This may be dependent on the contents of the table, or of private / public memvars that were defined before this code runs.
I see that your pblock returns a value of 0. Why is that ?
In the RDD system this return value is ignored, but if the value is a LOGIC and FALSE then the do while loop that processes all records will abort.
Btw: you can write this
Code: Select all
local pblock := {||
FieldPutAlias(Alias(),"m02domicil","domicil ")
FieldPutAlias(Alias(),"m02nombre","nombre ")
return 0
}
also as
Code: Select all
local pblock := {|| FieldPutAlias(Alias(),"m02domicil","domicil ") , FieldPutAlias(Alias(),"m02nombre","nombre ")}
Then you do not need the return statement.
Robert
2.6a vs 2.8.1 Primitive Replace Test
Posted: Thu Jun 10, 2021 1:58 pm
by robert
Juan,
I have an idea.
Can you change the code to:
Code: Select all
DbEval(pblock, pconditionFor, {||TRUE})
Robert
2.6a vs 2.8.1 Primitive Replace Test
Posted: Thu Jun 10, 2021 2:33 pm
by jpmoschi
Robert, thanks for your attention
I changed with your suggestion and the result is the same.The error :
System.InvalidCastException
HResult=0x80004002
Message=No se puede convertir un objeto de tipo 'System.Boolean' al tipo 'XSharp.ICodeblock'.
Source=XSharp.RT
StackTrace:
at XSharp.RT.Functions.DbEval(__Usual[] Xs$Args)
at ConsoleApplication1.Exe.Functions.Start() in ConsoleApplication1Program.prg:line 31
Next the Program.prg (the only program in the Console Application project)
Look , i omitted the for block and the error not change. Do you want that i send you the datatable schema with 2 example rows to run the code?
Code: Select all
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
FUNCTION Start() AS VOID STRICT
? "Hello World! Today is ",Date()
private _handle
STORE SqlConnect("BITEST4") to _handle
local LRESULT
private stext
LRESULT:= sqlexec(_handle,"Select top 100 * from M02CLIE ","M02CLIE")
IF LRESULT
DBGoTop()
stext:= ""
MALIAS:= ALIAS()
DO WHILE (!EOF())
FieldPutSelect(Alias(),"M02NOMBRE" , "CAMBIADO "+ LTRIM(STR(RECNO())))
DBSKIP()
ENDDO
/*local pblock := {||
FieldPutAlias(Alias(),"m02domicil","domicil ")
FieldPutAlias(Alias(),"m02nombre","nombre ")
return true
}
local pconditionFor:= {|| (Mod(RecNo(),2)=0) }
*/
local pblock := {|| FieldPutAlias(Alias(),"m02domicil","domicil ") , FieldPutAlias(Alias(),"m02nombre","nombre ")}
if DbEval(pblock )
stext:= "ok"
DbEval({|| stext:= stext + chr(13)+ m02domicil +"-" + m02nombre})
else
stext:= "er"
endif
endif
?stext
close
WAIT
RETURN
2.6a vs 2.8.1 Primitive Replace Test
Posted: Thu Jun 10, 2021 3:45 pm
by jpmoschi
It runed ok, the replace test is approved!!
Thanks Robert
2.6a vs 2.8.1 Primitive Replace Test
Posted: Tue Aug 10, 2021 2:27 pm
by jpmoschi
Good morning guys, don't forget this old reported bug.
The primitive dbEval() must be forced cbforcondition and cbwhilecondition arguments to avoid an error. Look the attached image
FUNCTION DbEval(cbExecute AS USUAL := NIL,cbForCondition AS USUAL := NIL, cbWhileCondition AS USUAL := NIL, nNext AS USUAL := NIL,nRecord AS USUAL := NIL,lRest AS USUAL := NIL) AS LOGIC[/code]
thanks
Juan
2.6a vs 2.8.1 Primitive Replace Test
Posted: Tue Aug 10, 2021 3:42 pm
by Chris
Hi Juan,
Sorry about that, this bug must have slipped. At the moment Git is not behaving well, but will log it as soon as possible, so it will not be forgotten. Btw, in my tests it seems that when specifying both for and while blocks, the error does not happen anymore, but the records are not processed correctly either. It's a bug in the FoxPro dialect only, as it is working well in the VO dialect.
2.6a vs 2.8.1 Primitive Replace Test
Posted: Tue Aug 10, 2021 4:34 pm
by Karl-Heinz
Hi Chris
i think it´s the same DBEval() problem i described here:
https://github.com/X-Sharp/XSharpPublic/issues/673
It works in the VO dialect, but fails in the Foxpro dialect.
Karl-Heinz
2.6a vs 2.8.1 Primitive Replace Test
Posted: Wed Aug 11, 2021 12:12 am
by Chris
Hi Karl-Heinz,
Ah thanks, so no need to log a new ticket, I have now updated your report with more info.
2.6a vs 2.8.1 Primitive Replace Test
Posted: Fri Aug 13, 2021 8:06 am
by robert
Juan, Karl-Heinz, Chris,
This problem is caused by the fact that in the FoxPro dialect the default value of a USUAL is .F. and not NIL.
The IsNil() function recognizes that a usual value is uninitialized, but apparently the DbEval() code checks for uninitialized parameters in a different way.
I'll fix this for the next build.
Robert