New feature - inline casting

LucaMs

Expert
Licensed User
Longtime User
You can do it because you have two monitors side by side and you can see half of the line on the first and the rest on the second ?
 

LucaMs

Expert
Licensed User
Longtime User
You can do it because you have two monitors side by side and you can see half of the line on the first and the rest on the second ?
B4X:
Private Sub Button1_Click
   Label1.Text = IIf(IsNumber(TextField1.Text) = False, "Invalid number", _
                     IIf(TextField1.Text > number, "My number is smaller", _
                         IIf(TextField1.Text < number, "My number is larger", "Well done!!!")))
End Sub
 
Last edited:

Ilya G.

Active Member
Licensed User
Longtime User
Will this also be in the next release?
 

LucaMs

Expert
Licensed User
Longtime User
B4X:
    Dim Index As Int = Sender.As(B4XView).Tag
It was useful to me right away.


BTW IIF too!!!

[for a small program that will make me a few thousand euros every month, even less than 10, perhaps ?]


P.S. IIF another time, right now:
B4X:
Dim Sign as int = IIf(EventData.PrimaryButtonPressed, 1, - 1)
(I'm not sure I've given the variable a proper name but that's okay )
 
Last edited:

NGUYEN TUAN ANH

Active Member
Licensed User
I think B4X should make everything clear, logic and coherence would be better, especially for newbies, although it might have to write more commands.
 

aeric

Expert
Licensed User
Longtime User
I think B4X should make everything clear, logic and coherence would be better, especially for newbies, although it might have to write more commands.
I think B4X already is what you said except for the last part of your statement, which I don’t agree. B4X is the most not verbose programming language I ever see without compromising the easiness for beginners.
 

aeric

Expert
Licensed User
Longtime User
I think B4X already is what you said except for the last part of your statement, which I don’t agree. B4X is the most not verbose programming language I ever see without compromising the easiness for beginners.
My first programming language is C in school, it took me so long to understand the for-loop. When I learn VB6 I love how simple it is to write a for-next loop. B4X shares the similar syntax and that’s what I like about the language.
C:
for (i=0; i<10; i++){
    // do something
}
B4X:
For i = O to 9
    'Do something
Next
 

alwaysbusy

Expert
Licensed User
Longtime User
@Erel Just an observation I had while testing the BANano Tanspiler support for the new .As functionality:

B4X:
' here I was expecting some kind of warning in the B4J compiler as I'm casting a Future (from GetCSS) to a String (I forgot the .Value after the GetCSS).
Log("JQAS: " & row2c1.As(JQueryElement).GetCSS("background-color").As(String).IndexOf("128"))

Is Future a special case or is this because every Object can be converted to a String (e.g. for Logging)?

Here for example, I do get a correct warning #22, and even an expected Compile error:
B4X:
Dim jq As MyFirstClass
jq.Initialize("test")
Log(jq.mysecond.As(MyFirstClass)) '<-------- here I get a warning #22 because mysecond is of the type MySecondClass

B4X:
B4J Version: 9.10 BETA #2
Parsing code.    (0.01s)
    Java Version: 11
Building folders structure.    (0.54s)
Compiling code.    (0.27s)
Compiling layouts code.    (0.06s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    Error
B4J line: 29
Log(\
src\com\ab\b4jsdemo\main.java:90: error: incompatible types: mysecondclass cannot be converted to myfirstclass
anywheresoftware.b4a.keywords.Common.Log("test: "+BA.ObjectToString(((com.ab.b4jsdemo.myfirstclass)(_jq._mysecond /*com.ab.b4jsdemo.mysecondclass*/ ))));

Alwaysbusy
 

Sergio Castellari

Active Member
Licensed User
Hola,

Si, y en el foro de ooHG también. Seguramente por que el espiritu del grupo es igual q B4X.
Saludos cordiales,
Sergio

translation
Yes, and on the ooHG forum as well. Surely because the spirit of the group is equal to q B4X. Kind regards,
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…