- The variable is automatically typed as the type after the IS clause
- The visibility of the variable is inside the IF branch only
- Of course you can do a similar check in an ELSEIF for another type
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FUNCTION Start() AS VOID
LOCAL oObject AS OBJECT
oObject := 123
IF oObject IS INT VAR nInt
? nInt * 2
END IF
RETURN
it just tells the compiler that if the var is indeed of the type we are checking for, to assign it to another var that is now strongly typed.
Ah, thx. Frankly spoken, i'd like it removed. There's no hint in the syntax what happens behind the scene, especially no assignment...
As you wrote to my other question: if it would spare a lot of typing...
The unfortunate thing is, that i now still don't see, why
FUNCTION csf2dbf() AS LOGIC
LOCAL cPfad, cSource, cDbf AS STRING
LOCAL lOK := FALSE AS LOGIC
LOCAL oDB AS DbServer
cPfad:= "C:DB"
cSource:= "kv_lieferad.csv"
cDbf:= "kv_Lieferad.dbf"
oDB:= DbServer{cPfad+cDbf}
? lOK := oDB:AppendDelimited(cSource, ",")
RETURN lOK
produces no error, but returns ".F." and the target stays empty
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
The DELIM and SDF RDDs are not there in the current build (they are mentioned in the "unsupported features" section in the help file). The good news is that I have implemented them and they will be included in the next build.
And w.r.t. the feature: you do not have to use it.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
robert wrote:The DELIM and SDF RDDs are not there in the current build (they are mentioned in the "unsupported features" section in the help file). The good news is that I have implemented them and they will be included in the next build.
Ah, thx, that explains my problem... Looking forward to see it, yesterday, pls
And w.r.t. the feature: you do not have to use it.
Well, that's not the point. One of imho XBase style languages biggest advantages always was its clear readability. For almost anything you don't have to have "arcane" knowlegde to understand, what is written. That is a big value in itself to keep...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
And w.r.t. the feature: you do not have to use it.
Well, that's not the point. One of imho XBase style languages biggest advantages always was its clear readability. For almost anything you don't have to have "arcane" knowlegde to understand, what is written. That is a big value in itself to keep...
I agree that the language should be readable. In the team Chris is our guardian of readability. He has already used his veto for quite some features and/or syntaxes, believe me.
But that should not stop us from adding features that make the product more usable or that increase productivity.
We get requests from users for features like this. Another similar feature that we have added (and that you almost certainly don't like) is declaring and passing an out variable at the same time.
Since features like this are fairly easy to implement (the underlying Roslyn platform already supports it) we decided to add that.
So this works now too
FUNCTION Start AS VOID
LOCAL strNumber AS STRING
strNumber := "1234"
IF Int32.TryParse(strNumber, OUT VAR iResult)
? iResult
ENDIF
IF Int32.TryParse(strNumber, OUT iResult2 AS Int32)
? iResult2
ENDIF
RETURN
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FUNCTION Start AS VOID
LOCAL strNumber AS STRING
strNumber := "1234"
IF Int32.TryParse(strNumber, OUT VAR iResult)
? iResult
ENDIF
IF Int32.TryParse(strNumber, OUT iResult2 AS Int32)
? iResult2
ENDIF
RETURN
FTR, no problem with this. With almost no knowldege about coding, i can understand, "i have a string and try to use it as a number"
I'm not sure i would use it, but one can understand what happens.
But i agree, it's always a fine line and certainly not easy to decide. Glad you are a balanced team
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)