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

TOPIC:

How to wrap X# ValType() function to use for VFP VarType() function??? 27 Apr 2020 17:33 #14273

  • FoxProMatt
  • FoxProMatt's Avatar
  • Topic Author



How can I use the #command syntax to make VFP VarType() function calls to use the X# ValType() function?

Here is what I tried, but I get rrun-time errors when my code calls VarType()
.
#command VarType(<*uValue*>) => ValType(<(uValue)>)

Is also tried this:
#command VarType(<*uValue*>) => ValType(<uValue>)




If I write my own Function for VarType() top call ValType() it works fine, but I'd rather do it with the pre-compiler.
.
Function VarType(uValue)
	
    Return ValType(uValue)
  
End Function

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

Last edit: by FoxProMatt.

How to wrap X# ValType() function to use for VFP VarType() function??? 27 Apr 2020 17:42 #14275

  • robert
  • robert's Avatar


  • Posts: 3446
  • Matt,

    #command is meant for translations that span a whole statement.
    In this case you need #translate of #xtranslate, because VarType() will be in the middle of another line of code.
    I would recommend #xtranslate because otherwise also abbreviations will be matched.

    Robert
    XSharp Development Team
    The Netherlands

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

    Last edit: by robert.

    How to wrap X# ValType() function to use for VFP VarType() function??? 27 Apr 2020 17:51 #14276

    • FoxProMatt
    • FoxProMatt's Avatar
    • Topic Author



    Thanks Robert!

    This does it:
    #xtranslate VarType(<uValue>) => ValType(<uValue>)


    Can you put this into one of the next releases? Would it go into FoxProCmd.xh file?

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

    How to wrap X# ValType() function to use for VFP VarType() function??? 28 Apr 2020 21:35 #14284

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Guys,

    a question about the data types DateTime and Currency.

    Both data types can be used with FP and VO. What i donĀ“t understand are the differences i see when i toggle the dialect and check the types within a "as usual" function:
    FUNCTION TestDateTimeAndCurrency() AS VOID
    LOCAL dt AS DateTime
    LOCAL c AS Currency
     
    dt := DateTime(2000,12,2)
    c := 12.45
    
    // ok, the FP and VO dialect show the same results
    ? dt  // 02.12.2020 00:00:00
    ? c   // 12,4500
    ?
    // ok, the FP and VO dialect show the same results
    dt:GetType():ToString()  // System.DateTime
    c:GetType():ToString()   // XSharp.__Currency 
    ?
    ? "Test DateTime:"
    TestUsual ( dt )
    ?
    ? "Test Currency:" 
    TestUsual ( c ) 
    ?
    
    RETURN 
    
               
    FUNCTION TestUsual ( u AS USUAL ) AS VOID 
    
    /*	
     The VO dialect shows: 
    
    	XSharp.__Usual
    	XSharp.__Usual 
    	
      while the FP dialect shows:
      
    	System.DateTime
     	XSharp.__Currency
    
    */
    
    ? u:GetType():ToString()   
    
    RETURN 

    i hope you can follow me ;-)

    btw. according the FP docs: VarType ( <DateTime> ) returns "T" and varType ( <Currency> ) "Y"

    regards
    Karl-Heinz

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

    Last edit: by Karl-Heinz.

    How to wrap X# ValType() function to use for VFP VarType() function??? 29 Apr 2020 14:03 #14293

    • robert
    • robert's Avatar


  • Posts: 3446
  • Karl-Heinz ,

    - ValType() has been fixed.
    - The other difference is caused by the fact that in the VO dialect u:GetType() is early bound and in FoxPro late bound. And apparently the early bound code returns the GetType() of the usual itself and the late bound code returns the GetType() of the contents of the usual.
    If you change the code to:
    ? ((OBJECT)u):GetType():ToString()
    Then in both dialects you will get the type of the contents of the usual.
    This is one of those 'Edge cases'. I am not sure what the right behavior should be here...

    Robert
    XSharp Development Team
    The Netherlands

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

    • Page:
    • 1