iOS Question B4I B4A cross Platform if then else

fabio.mevoli

Member
Licensed User
I'm new in B4I
I write:
#if B4A
If area2(area2.Length-2) = 1 Then
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-C"
Else
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-O"
End If
#Else If B4I
If area2(area2.Length-2) = 1 Then
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-C"
Else
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-O"
End If
#End If

In B4I I got an error: EXPECTED NON CODE BLOCK, but with B4A everthings works well.
 

aeric

Expert
Licensed User
Longtime User
Please use code tags when posting on forum
e.g
[code]#If B4A

#Else If B4i

#End If[/code]

By the way, the code is same for both conditions. You don't need to use #If B4A etc.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
I'm new in B4I
I write:
#if B4A
If area2(area2.Length-2) = 1 Then
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-C"
Else
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-O"
End If
#Else If B4I
If area2(area2.Length-2) = 1 Then
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-C"
Else
Model_box.Text = "W480"
Type_box.Text = "DSC-MOB-O"
End If
#End If

In B4I I got an error: EXPECTED NON CODE BLOCK, but with B4A everthings works well.

I suppose area2 is an array. I cannot understand why is this happening. This is a long shot but you may have to use lower case letters in the '#' statements.


B4X:
#if b4a

#else if b4i

#end if
 
Upvote 0

fabio.mevoli

Member
Licensed User
Another strange thing one rerror highlighted is in English and one is in Italian.
Array definition:
#If B4A
Private area1(11) As Byte
Private area2(32) As Byte
#Else If B4I
#Else If B4I
Public area1() As Byte
area1 = Array As Byte(0,0,0,0,0,0,0,0,0,0,0)
Public area2() As Byte
area2 = Array As Byte(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
#End If
 

Attachments

  • b4i_1png.png
    b4i_1png.png
    129.7 KB · Views: 38
  • b4i_2png.png
    b4i_2png.png
    129.3 KB · Views: 38
Upvote 0

aeric

Expert
Licensed User
Longtime User
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private area1(11) As Byte
    Private area2(32) As Byte
End Sub

B4X:
area1 = Array As Byte(0,0,0,0,0,0,0,0,0,0,0)
area2 = Array As Byte(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
You don't need to use conditional symbols.
 
Upvote 0
Top