Let's write the EVL() function for X#...
Let's write the EVL() function for X#...
This discussion is good, letting me see all the things I was NOT thinking about.
I'm anxious to get the basic VFP functions working soon so that when an old VFP dog learns about X# and they do give it a try but the basic functions are not yet implemented, if will be a big let down for them, and they will there badly of VFP.
I'm anxious to get the basic VFP functions working soon so that when an old VFP dog learns about X# and they do give it a try but the basic functions are not yet implemented, if will be a big let down for them, and they will there badly of VFP.
Let's write the EVL() function for X#...
Matt,
If X# supports empty dates and datetimes (I'm not working with the machine where I have X# installed right now, so I can't verify this), then YEAR(someDate) or YEAR(someDatetime) should return 0 in case of emptiness.
If X# supports empty dates and datetimes (I'm not working with the machine where I have X# installed right now, so I can't verify this), then YEAR(someDate) or YEAR(someDatetime) should return 0 in case of emptiness.
- Zdeněk Krejčí
- Posts: 19
- Joined: Wed Sep 04, 2019 8:07 am
Let's write the EVL() function for X#...
Is it possible to use generics like c#?
Zdeněk
Zdeněk
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
Let's write the EVL() function for X#...
Yes!Zdeněk Krejčí wrote:Is it possible to use generics like c#?
Zdeněk
Code: Select all
LOCAL x AS List<String>
x := List<String>{}
x:Add("abc")
x:Add(123) // Error at compile time
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
Let's write the EVL() function for X#...
lumberjack - He's talking about using generics to implement EVL().
Let's not take this thread off on a tangent with code examples of new X# programming examples. X# must implement the EVL() function as-written without users having to change their code, so that's what I want to stay focused on here in this thread.
Let's not take this thread off on a tangent with code examples of new X# programming examples. X# must implement the EVL() function as-written without users having to change their code, so that's what I want to stay focused on here in this thread.
-
- Posts: 200
- Joined: Wed Oct 09, 2019 6:51 pm
Let's write the EVL() function for X#...
Hi Antonio,
atlopes wrote:"most" would be better. There are string functions not following that rule, but they are few - I had mentioned that missing Nullcheck in xSharp quite a while back. Uncertain if those should be implemented only in vfp dialect calling base implementation, base implementation needs to be enhanced or new implementation (for 1-3 liners, cutting out method call) are appropriate. Will check when new version is available to non-FoXers and if not done perhaps do it in 1 swoop for those I calling my attention early on.In VFP, in general, any function that accepts a .NULL. for one of its arguments returns .NULL. as a result.
...
Obvious exceptions are NVL(), ISNULL(), and VARTYPE().
regards
thomas
-
- Posts: 200
- Joined: Wed Oct 09, 2019 6:51 pm
Let's write the EVL() function for X#...
Hi Robert,
regards
thomas
interesting - might speed up my GetWord* functions if not already tweaked by Chris or you.robert wrote:The string type in .Net has a Chars property which is an indexable collection of characters in the string. No allocation is needed as far as I know to address individual characters .
The string class is written in CPP:
You can see here that it simply indexes the character in the buffer
https://github.com/dotnet/coreclr/blob/ ... ve.cpp#L52
regards
thomas
- Zdeněk Krejčí
- Posts: 19
- Joined: Wed Sep 04, 2019 8:07 am
Let's write the EVL() function for X#...
Code: Select all
FUNCTION EVL(eExpression1 AS USUAL, eExpression2 AS <T>) AS USUAL
If IsEmpty(eExpression1)
Return eExpression2
Endif
Return eExpression1
....
Let's write the EVL() function for X#...
Zdenek,
What would the benefit of this be over
FUNCTION EVL(eExpression1 AS USUAL, eExpression2 AS USUAL) AS USUAL
If IsEmpty(eExpression1)
Return eExpression2
Endif
Return eExpression1
Robert
What would the benefit of this be over
FUNCTION EVL(eExpression1 AS USUAL, eExpression2 AS USUAL) AS USUAL
If IsEmpty(eExpression1)
Return eExpression2
Endif
Return eExpression1
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Let's write the EVL() function for X#...
Robert
Code for option a)
Code for option b)
Handling of .NULL. seems a problem, really, and appearing in various places, as Thomas mentioned. I found out that I can't even issue
without raising an error.
I've been trying this for a bit in the context of Matt EVL() draft. I'm probably missing something, but since Chars is a String collection, this won't work until a) we create a new string from the Usual parameter, and thus facing a string replication problem again; or b) we have a different implementation of the EVL() function for strings.The string type in .Net has a Chars property which is an indexable collection of characters in the string. No allocation is needed as far as I know to address individual characters .
Code for option a)
Code: Select all
Case dataType == "C"
LOCAL emptyChars = " " + CHR(9) + CHR(10) + CHR(13) AS String
LOCAL testString = uValue.ToString() AS String
FOR VAR idx = 0 TO testString.Length - 1
If (emptyChars.IndexOf(testString.Chars[idx]) == -1)
Return uValue
Endif
NEXT
Return uReturnValue
Code: Select all
Function Evl (sValue AS String, uReturnValue)
LOCAL emptyChars = " " + CHR(9) + CHR(10) + CHR(13) AS String
FOR VAR idx = 0 TO sValue.Length - 1
If (emptyChars.IndexOf(sValue.Chars[idx]) == -1)
Return sValue
Endif
NEXT
Return uReturnValue
End Function
Code: Select all
? .NULL.