Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

2.6a vs 2.8.1 Primitive Replace Test 09 Jun 2021 23:02 #18757

  • jpmoschi
  • jpmoschi's Avatar
  • Topic Author


  • Posts: 76
  • 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


    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 
    Attachments:

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Jun 2021 15:56 #18769

    • robert
    • robert's Avatar


  • Posts: 3446
  • 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
    local pblock := {|| 
                  FieldPutAlias(Alias(),"m02domicil","domicil ")  
                  FieldPutAlias(Alias(),"m02nombre","nombre ")
                  return 0
                  }

    also as
    local pblock := {||  FieldPutAlias(Alias(),"m02domicil","domicil ") , FieldPutAlias(Alias(),"m02nombre","nombre ")}

    Then you do not need the return statement.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Jun 2021 15:58 #18770

    • robert
    • robert's Avatar


  • Posts: 3446
  • Juan,
    I have an idea.
    Can you change the code to:
    DbEval(pblock, pconditionFor, {||TRUE})

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Last edit: by robert.

    2.6a vs 2.8.1 Primitive Replace Test 10 Jun 2021 16:33 #18771

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • 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 ConsoleApplication1\Program.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?
    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

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Jun 2021 17:45 #18773

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • It runed ok, the replace test is approved!!
    Thanks Robert

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Aug 2021 16:27 #19307

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • 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
    Attachments:

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Aug 2021 17:42 #19308

    • Chris
    • Chris's Avatar


  • Posts: 3843
  • 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.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 10 Aug 2021 18:34 #19309

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Hi Chris

    i think it´s the same DBEval() problem i described here:

    github.com/X-Sharp/XSharpPublic/issues/673

    It works in the VO dialect, but fails in the Foxpro dialect.

    Karl-Heinz

    Please Log in or Create an account to join the conversation.

    Last edit: by Karl-Heinz.

    2.6a vs 2.8.1 Primitive Replace Test 11 Aug 2021 02:12 #19312

    • Chris
    • Chris's Avatar


  • Posts: 3843
  • Hi Karl-Heinz,

    Ah thanks, so no need to log a new ticket, I have now updated your report with more info.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8.1 Primitive Replace Test 13 Aug 2021 10:06 #19336

    • robert
    • robert's Avatar


  • Posts: 3446
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1