Let's write the EVL() function for X#...
Posted: Fri May 08, 2020 5:26 pm
Expression2 can be strong typed.
Zdenek
Zdenek
Code: Select all
FUNCTION EmptyString(testString AS STRING) AS LOGIC
IF testString == NULL .OR. testString:Length == 0
RETURN TRUE
ENDIF
FOREACH VAR c IN testString // this enumerates the characters in the string and is very fast
SWITCH c
CASE 32
CASE 9
CASE 13
CASE 10
NOP // these are all empty, so continue
OTHERWISE
RETURN FALSE
END SWITCH
NEXT
RETURN TRUE
There is very little benefit in strong typing Expression2 because is returned in a USUAL.Zdeněk Krejčí wrote:Expression2 can be strong typed.
Zdenek
But look at it from vfp POV:Btw I noticed that VFP allows this:and returns the "abcde". So the type of the 2 expressions does not have to be the sameCode: Select all
? EVL("abcde", 1234)
This returns 1234Code: Select all
? EVL(" ", 1234)
Code: Select all
Function FieldAppender(tcCsvFldList, tcOptionalAppendTo)
tcOptionalAppendTo = evl(tcOptionalAppendTo, "DefaultIfEmpty")
for ...
next
return tcOptionalAppendTo
= FieldAppender("VNam, NNam, Adr")
Code: Select all
Function FieldAppender(tcCsvFldList as String) as String
return FieldAppender(tcCsvFldList, "DefaultIfEmpty")
Function FieldAppender(tcCsvFldList as String, tcOptionalAppendTo as String) as String
.....
Code: Select all
Function Evl(t1 as Integer, t2 as Integer) : Integer
#if CC_WritePruneLog
= AddPruneLine(Program(Program(-1)-1), "Evl() with Integer")
#endif
if t1=0
return t2
endif
return t1
Code: Select all
iif(t1=0, t2, t1)