Android Example B4A -interpreter for Android / programming on the device

B4A-Interpreter

I've made a B4A interpreter that runs B4A-Code on Android
to write easy B4A-test programs on my Phone.
To make an app only copy the source code back to the B4A IDE and compile it to an apk file.


b4ai.png


Everbody is invited to expand this interpreter.

in this first version the interpreter can only create panels with click event and set colors

The new src is attached down here.
B4AInterpreter0_4.zip...
11.png



here is the source code from the first version (androidb4a.zip)
activity : main
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim editCode As EditText
Dim code As String
Dim bStart As Button
Dim apan As apanel  'activity panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

code=File.ReadString(File.DirAssets,"test.b4a")
editCode.Initialize("editcode")
editCode.Text=code
Activity.addview(editCode,0%x,8%y,100%x,42%y)

bStart.Initialize("bstart")
bStart.Text="Start >"
Activity.addview(bStart,0,0,28%x,8%y)

apan.Initialize
bStart_click

Activity.addview(apan.pmain,0,50%y,100%x,50%y)


End Sub
Sub editCode_click
editCode.BringToFront
End Sub

Sub RemoveViews
Dim i As Int
For i=apan.pmain.NumberOfViews-1 To 0 Step -1
  apan.pmain.RemoveViewAt(i)
Next
End Sub


Sub bStart_click
RemoveViews
Dim command As String
Dim e As Boolean
initGlobals
runSub( "Activity_Create(FirstTime As Boolean)")

End Sub

Sub runSub(command As String)
Dim e As Boolean
command=runAt(command)
Do Until e
runCode(command)
command=runAt(command)
If command.IndexOf("End Sub")>-1 Then e=True
Loop

End Sub


Sub getValues(objectProp As String)As String()
Dim apos, epos,count As Int
Dim s1,s2 As String
Dim v(10) As String
apos=objectProp.IndexOf("(")

If apos>-1 Then
  epos=objectProp.IndexOf(")")
  s1=objectProp.SubString2(apos+1,epos)
  apos=0
   Dim findEnd As Boolean
   Do Until findEnd
     epos=s1.IndexOf2(",",apos+1)

    If epos<0 Then
      findEnd=True
      epos=s1.Length
    End If
     v(count)=s1.SubString2(apos,epos)
     count=count+1
     apos=epos+1
   Loop
End If

Return v

End Sub

Sub getFunction(objectProp As String)As String

If objectProp.IndexOf("(") >-1 Then Return objectProp.SubString2(0,objectProp.IndexOf("("))
If objectProp.IndexOf("=") >-1 Then Return objectProp.SubString2(0,objectProp.IndexOf("="))

End Sub
Sub runCode(command)
Dim apos, epos, index As Int
Dim objectType,objectName, objectProp ,eventName,functionsName As String
Dim params(10) As String


objectName=command.SubString2(1,command.IndexOf("."))
objectProp=command.SubString(command.IndexOf(".")+1)
functionsName=getFunction(objectProp)
params=getValues(objectProp)
index=apan.findindex(objectName)

If functionsName="Initialize" Then
   eventName=params(0)
  initview(objectName,eventName)
End If

If functionsName="AddView" Then
params=getValues(objectProp)
index=apan.findindex(params(0))
addview(apan.p(index),params)
End If

If functionsName.IndexOf("Color=")>-1 Then
params=getValues(objectProp)
index=apan.findindex(objectName)
apan.p(index).Color=Colors.RGB(params(0),params(1),params(2))
End If



End Sub
Sub runAt(subname As String)As String
Dim apos, epos As Int
Dim findstr As String

   apos=code.IndexOf2(subname,apos)
   epos=code.IndexOf2(Chr(13),apos+subname.Length+3)
   findstr=code.SubString2(apos+subname.Length+1,epos)

Return findstr

End Sub

Sub initGlobals
'in this first Version it define all Dim .. as of the hole code
Dim apos, epos As Int
Dim findEnd As Boolean
Dim objectType,s1,objectName As String

Do Until findEnd
   apos=code.IndexOf2("Dim",apos)
   epos=code.IndexOf2("Dim",apos+1)
   If epos=-1 Then
    findEnd=True
    epos=code.IndexOf2("End Sub",apos+1)
   End If
   s1=code.SubString2(apos+3,epos)
   objectName=s1.SubString2(0,s1.IndexOf("As"))
   objectType=s1.SubString2(s1.IndexOf("As")+2,s1.Length)
   apan.makeDim(objectName,objectType)

   apos=epos
Loop

End Sub


Sub addview(o As View,pa() As String)
Dim i(4) As Int
i(0)=pa(1)
i(1)=pa(2)
i(2)=pa(3)
i(3)=pa(4)
apan.pmain.addview(o,i(0),i(1),i(2),i(3))
End Sub

Sub initview(objectName As String,eventName As String)
Dim index As Int
index=apan.findindex(objectName)
apan.Initialize2(objectName,eventName)
apan.event(index)=eventName
End Sub

Sub editcode_TextChanged (Old As String, New As String)
   code=editCode.Text
End Sub
Sub editcode_EnterPressed

End Sub
Sub editcode_FocusChanged (HasFocus As Boolean)

End Sub

class module: aPanel
B4X:
'Class module
Sub Class_Globals
Dim pmain As Panel
Dim objectCount As Int
Dim p(100) As Panel
Dim b(100) As Button
Dim tag(100) As String
Dim name(100) As String
Dim event(100) As String
Dim art(100) As String

End Sub
Public Sub makeDim(objectName As String,objectType As String)
    name(objectCount)=objectName
    art(objectCount)=objectType
    objectCount=objectCount+1
End Sub

Public Sub Initialize2(objectName As String,eventname As String)
   Dim index As Int
   index=findindex(objectName)
   p(index).Initialize("pevent")
   p(index).tag=index
   name(index)=objectName
End Sub

Public Sub Initialize()
   pmain.Initialize("acty")
   pmain.Color=Colors.Blue

End Sub
Sub acty_click
pmain.BringToFront
End Sub
Sub findindex(objectName As String) As Int
   For m = 0 To objectCount-1
    If name(m).trim=objectName.trim Then Return m
   Next
End Sub
Sub pevent_click
   Dim send As Panel
   Dim index As Int
   Dim s1 As String
   send=Sender
   index=send.tag
   s1=name(index)&"_click"
   CallSub2(Main,"runSub",s1.Trim)
End Sub

The Test Code: test.b4a (file.dirAssets)

B4X:
Sub Process_Globals

End Sub

Sub Globals
Dim p As Panel
Dim pf As Panel
Dim pg As Panel
Dim b As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)

p.Initialize("p")
p.Color=Colors.RGB(233,55,244)
Activity.AddView(p,1,133,222,111)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub p_click
pf.Initialize("pf")
pf.Color=Colors.RGB(244,33,55)
Activity.AddView(pf,252,33,222,111)
End Sub

Sub pf_click
pg.Initialize("pg")
pg.Color=colors.RGB(33,255,22)
Activity.AddView(pg,252,233,222,111)
End Sub

Sub pg_click
pf.Color=Colors.RGB(133,255,229)
p.Color=Colors.RGB(233,255,2)
End Sub
 

Attachments

  • androidb4a.zip
    8 KB · Views: 637
  • androidb4a2_7.zip
    7.3 KB · Views: 676
  • B4AInterpreter0_3.zip
    354.4 KB · Views: 852
  • B4Ainterpreter0_4.zip
    355.2 KB · Views: 567
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
COULD be nice...is it for 3.x only ?
On my 2.71 an error occurs when loading the project

BarXdroids "Notification Builder Demo" is also a good tool which saves typing time ;-)
 

GMan

Well-Known Member
Licensed User
Longtime User
Thx, this one works.
Nice tool :)
 

GMan

Well-Known Member
Licensed User
Longtime User
i added the possibilty to save the current file to dropbox (encoded with the timestamp to make it unique).
In the dropbox.bal are some options i am using different, as FTP, BlueTooth and (any)Cloud...but not used here.

i also added a menu, to call (for now only) the Panels (and besides the Backup part)

Thx again to BirneSoft - maybe it's a Williams Christ ;-)
 

Attachments

  • B4AinterpreterGMAN.zip
    344.2 KB · Views: 412
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
and just added FTP to transfer the file to a pc's B4A directory:
B4X:
Sub Globals
  Dim FTP as FTP
End Sub

' FTP
Sub FTPButton_Click
Dim ps As PhoneWakeState
ps.KeepAlive(True)
Dim filefilename As String = DateTime.Time(DateTime.Now)
filefilename = filefilename.Replace(":","")
FTP.Initialize("FTP", "yourserver", 21, "username", "passwort")
'FTP.DownloadFile("/xxx", False, File.DirRootExternal, "1.dat")
FTP.UploadFile(File.DirAssets,"test.b4a",True, "B4Ainterpreter/" & filefilename & ".b4a")
End Sub

Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    ToastMessageShow (NumberFormat2(TotalDownloaded, 0, 0, 0, True),False)
End Sub

Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow (ServerPath & " " & Success,False)
End Sub

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
  ToastMessageShow (NumberFormat2(TotalUploaded, 0, 0, 0, True), False)
End Sub
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow (ServerPath & " " & Success,False)
End Sub
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
and also added the Google CloudPrint option, which lets you print (PDF or on real paper if printer is connected), save to Google Drive and (if your developing device is registred there and connected) also there.
B4X:
' CloudPrint
Sub CloudPrintButton_Click
    Dim filefilename As String = DateTime.Time(DateTime.Now)
    filefilename = filefilename.Replace(":","")
    SendToCloud("url", "", "http://www.google.com/landing/cloudprint/" & filefilename & ".pdf")
End Sub
' CloudPrint Routines
Sub SendToCloud(MimeType As String, Directory As String, FileName As String)
                Dim HTML As String       
                Dim i As Intent               
               
                HTML = File.GetText(File.DirAssets, "CloudPrint.html")
                If MimeType = "text/plain" OR MimeType = "url" Then
                   HTML = HTML.Replace("$MIMETYPE$", MimeType).Replace("$CONTENT$", FileName).Replace("$ENCODING$", "")
                Else           
                   HTML = HTML.Replace("$MIMETYPE$", MimeType).Replace("$CONTENT$", Encode64(Directory, FileName)).Replace("$ENCODING$", "base64")
                End If

    File.WriteString(File.DirDefaultExternal, "PrintJob.html", HTML)
                i.Initialize("android.intent.action.VIEW", "file:///" & File.DirDefaultExternal & "/PrintJob.html")
    i.SetComponent("com.android.chrome/.Main") 'Uncomment this line if you want to use Chrome.
    'i.SetComponent("com.android.browser/.BrowserActivity") 'This is the default Android browser.
    i.SetType("text/html")
               
    StartActivity(i)

End Sub
Sub Encode64(Directory As String, FileName As String) As String
    Dim Data() As Byte
                Dim In As InputStream
                Dim Out As OutputStream
                Dim su As StringUtils
               
                In = File.OpenInput(Directory, FileName)           
               
                Out.InitializeToBytesArray(1024)
               
                File.Copy2(In, Out)
               
                Data = Out.ToBytesArray

    EncodedFile = su.EncodeBase64(Data)               

                Return EncodedFile
               
End Sub
 

GMan

Well-Known Member
Licensed User
Longtime User
Ahoi Björn,

i made a little GUI with a SlidingMenu to sort out the "available Modules" and a "normal" menu for the other options.
Someone with more experiences may b able to optimize the code...for me it works fine so far.
 

GMan

Well-Known Member
Licensed User
Longtime User
Ya know: there a (mostly) no stupi questions, only stupid answers ;)

FOR ME: i am often traveling by train and sometimes there is not enough space to place my notebook etc.
So, if i am bored i can make some code - may be trivial, but i like it :D
 

LucaMs

Expert
Licensed User
Longtime User
Ya know: there a (mostly) no stupi questions, only stupid answers ;)

FOR ME: i am often traveling by train and sometimes there is not enough space to place my notebook etc.
So, if i am bored i can make some code - may be trivial, but i like it :D


I have a better look at it.

Given your (not stupid ;)) answer, it should be a code generator (?)
 

GMan

Well-Known Member
Licensed User
Longtime User
Gotcha - you 've got it
 

birnesoft

Active Member
Licensed User
Longtime User
I'm also use AndroidB4A for traveling.
I don't use the designer from B4A.:rolleyes: If this tool is able to run simple code, I can do a lot of design work everywhere I am. The best on an interpreter is, that you don't have to compile. The program starts directly and it's cool to change the source code while the program is running. If your codeline don't works, step back, change it and try the line again till it works.:p
It is possible in VB and I love this easy way.
I think it is not so complicated, because B4A is very easy and logical structured. Thanks Erel:)
 

birnesoft

Active Member
Licensed User
Longtime User
Now I've made all in seperate panels and you can switch it with picture panels.

B4X:
Sub initPanels
For m = 0 To 4
    switchPanel(m).Initialize("switchPanel")
    switchPanel(m).tag=m
    Activity.AddView(switchPanel(m),0,10%y,100%x,80%y)
    switch(m).Initialize("switch")
    switch(m).tag=m
    switch(m).Color=Colors.RGB((m+3)*76 Mod 255,m*92 Mod 255,m*126 Mod 255)
    Activity.AddView(switch(m),20%x*m,90%y,20%x,10%y)
Next
switchPanel(0).LoadLayout("main")
switchPanel(3).LoadLayout ("dropbox")
switch(0).SetBackgroundImage(LoadBitmap(File.DirAssets,"home.png"))
switch(1).SetBackgroundImage(LoadBitmap(File.DirAssets,"b4a_code.png"))
switch(2).SetBackgroundImage(LoadBitmap(File.DirAssets,"b4a_app.png"))
switch(3).SetBackgroundImage(LoadBitmap(File.DirAssets,"ftp_logo.png"))
switch(4).SetBackgroundImage(LoadBitmap(File.DirAssets,"aboutus.png"))
end sub

Sub switch_click
   Dim sP=Sender As Panel
  switcher(sP.Tag)
End Sub
Sub switcher(sw As Int)
   For m = 0 To 4
      If sw=m Then switchPanel(m).Visible=True Else switchPanel(m).Visible=False
   Next
End Sub
 

Attachments

  • B4AInterpreter0_3.zip
    354.4 KB · Views: 390

GMan

Well-Known Member
Licensed User
Longtime User
Tried to solve the problem to show a b4a-file as text, but stuck - brain drain :eek:
Also impmented a webserver on port :5555 to get an additional access to download the generated file to the development computer.

As the file is too large now for upload (> 5 MB) in case of the libraries, you can get it here:
http://androids.bplaced.net/B4Ainterpreter/B4Ainterpreter203.zip
 

birnesoft

Active Member
Licensed User
Longtime User
cool, but where is the sourcecode editor?
My idea was, to save the created sourcecode on the SD-Card and read it via USB. Then I paste the code in my B4A IDE.
But its better with http to share code with others.
With this we can share sourcecode directly. Click and run...:)

And now, I want to write the interpreter-module for more kind of views.
 

GMan

Well-Known Member
Licensed User
Longtime User
writing on sd-card is also possible, the httpserver is also only for internal use (wlan) - you cant access it from the internet.
a cool solution could be, to pull (if qnted) the new module to a webside to share it with others - or someone has to manage the "official" version - otherwise it will end in a chaos :confused: in case of a bunch of versions ;)

So, take it all and we give you suggestions :rolleyes:
 

birnesoft

Active Member
Licensed User
Longtime User
Now its possiple to create Labels, Buttons, EditText, Panels and Webviews
I've made the interpretercode module separate. So it's more clear.

So it looks in the interpreter
11.png

This is the compiled apk.
12.png

This is the test Code
B4X:
Sub Process_Globals
  
End Sub

Sub Globals
Dim p As Panel
Dim pf As Panel
Dim pg As Panel
Dim b As Button
Dim e As EditText
Dim l As Label
Dim w As WebView

End Sub

Sub Activity_Create(FirstTime As Boolean)

p.Initialize("p")
p.Color=Colors.RGB(233,55,244)
Activity.AddView(p,1,73,222,111)
b.Initialize("b")
Activity.AddView(b,1,233,222,111)
e.Initialize("e")
e.Color=Colors.RGB(5,255,255)
Activity.AddView(e,1,3,422,51)
l.Initialize("l")
l.Color=Colors.RGB(233,55,244)
Activity.AddView(l,331,633,122,111)
w.Initialize("w")
Activity.AddView(w,1,333,482,311)
l.Text="okok!!"
e.Text="okyeahok!!"
b.Text="bokyeahok!!"
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub p_click
pf.Initialize("pf")
pf.Color=Colors.RGB(244,33,55)
Activity.AddView(pf,252,63,222,111)
b.Text="bahok!!"
l.Text="bokyeahok!!"
End Sub

Sub pf_click
pg.Initialize("pg")
pg.Color=colors.RGB(33,255,22)
Activity.AddView(pg,232,203,222,111)
End Sub

Sub pg_click
pf.Color=Colors.RGB(133,255,229)
p.Color=Colors.RGB(233,255,2)
End Sub


Sub b_click
b.Color=Colors.RGB(244,33,55)
l.Text="ok!!"
w.LoadUrl("http://www.b4x.com/android/forum/threads/b4a-interpreter-for-android-programming-on-the-device.41468/#post-249513")
End Sub

This is the new class code
B4X:
'Class module
Sub Class_Globals
Dim pmain As Panel
Dim objectCount As Int
Dim pa(100) As Panel
Dim bu(100) As Button
Dim la(100) As Label
Dim et(100) As EditText
Dim wv(100) As WebView
Dim tag(100) As String
Dim name(100) As String
Dim event(100) As String
Dim oType(100) As String
Dim editCode As EditText
Dim code As String

Dim apan As aPanel  'activity panel
End Sub

Sub load(edi As Panel,app As Panel )
code=File.ReadString(File.DirAssets,"test.b4a")

editCode.Initialize("editcode")
edi.AddView(editCode,0,0,100%x,80%y)
editCode.Text=code
    pmain.Initialize("acty")
    pmain.Color=Colors.Blue
app.AddView(pmain,0,0,100%x,80%y)


End Sub

Public Sub makeDim(objectName As String,objectType As String)
    name(objectCount)=objectName
    oType(objectCount)=objectType
    objectCount=objectCount+1
End Sub

Public Sub Initialize2(objectName As String,eventname As String)
    Dim ix As Int
    Dim v As View
    Dim es As String
    Dim oTyp As String
    ix=findindex(objectName)
   
    oTyp=oType(ix)
    If oTyp="Panel" Then
        pa(ix).Initialize("pevent")
        pa(ix).tag=ix
    End If
    If oTyp="Button" Then
        bu(ix).Initialize("bevent")
        bu(ix).tag=ix
    End If
    If oTyp="EditText" Then
        et(ix).Initialize("eevent")
        et(ix).tag=ix
    End If
    If oTyp="Label" Then
        la(ix).Initialize("levent")
        la(ix).tag=ix
    End If
    If oTyp="WebView" Then
        wv(ix).Initialize("wevent")
        wv(ix).tag=ix
    End If
   
    name(ix)=objectName
End Sub

Public Sub Initialize()

   
End Sub
Sub acty_click
pmain.BringToFront
End Sub
Sub findindex(objectName As String) As Int
    For m = 0 To objectCount-1
      If name(m).trim=objectName.trim Then Return m
    Next
End Sub
Sub pevent_click
    Dim send As Panel
    Dim index As Int
    Dim s1 As String
    send=Sender
    index=send.tag
    s1=name(index)&"_click"
    runSub(s1.Trim)
End Sub
Sub bevent_click
    Dim send As Button
    Dim index As Int
    Dim s1 As String
    send=Sender
    index=send.tag
    s1=name(index)&"_click"
    runSub(s1.Trim)
End Sub






Sub bStart

RemoveViews
CallSub2(Main,"switcher",2)
Dim command As String
Dim e As Boolean
initGlobals
runSub( "Activity_Create(FirstTime As Boolean)")

End Sub

Sub runSub(command As String)
Dim e As Boolean
command=runAt(command)
Do Until e
runCode(command)
command=runAt(command)
If command.IndexOf("End Sub")>-1 Then e=True
Loop

End Sub


Sub getValues(objectProp As String)As String()
Dim apos, epos,count As Int
Dim s1,s2 As String
Dim v(10) As String
apos=objectProp.IndexOf("(")

If apos>-1 Then
  epos=objectProp.IndexOf(")")
  s1=objectProp.SubString2(apos+1,epos)
  apos=0
    Dim findEnd As Boolean
    Do Until findEnd
        epos=s1.IndexOf2(",",apos+1)
       
        If epos<0 Then
          findEnd=True
          epos=s1.Length
        End If
        v(count)=s1.SubString2(apos,epos)
        count=count+1
        apos=epos+1
    Loop
End If

Return v

End Sub

Sub getFunction(objectProp As String)As String

If objectProp.IndexOf("(") >-1 Then Return objectProp.SubString2(0,objectProp.IndexOf("("))
If objectProp.IndexOf("=") >-1 Then Return objectProp.SubString2(0,objectProp.IndexOf("="))

End Sub
Sub runCode(command)
Dim apos, epos, index As Int
Dim objectType,objectName, objectProp ,eventName,functionsName As String
Dim params(10) As String


objectName=command.SubString2(1,command.IndexOf("."))
objectProp=command.SubString(command.IndexOf(".")+1)
functionsName=getFunction(objectProp)
params=getValues(objectProp)
index=findindex(objectName)
objectType=oType(index)

If functionsName="Initialize" Then
    eventName=params(0)
    initview(objectName,eventName)
End If

If functionsName="AddView" Then
params=getValues(objectProp)
faddview(params)
End If

If functionsName.IndexOf("Color=")>-1 Then
Dim v As View
params=getValues(objectProp)
v=fgetView(index)
v.Color=Colors.RGB(params(0),params(1),params(2))
End If

If objectProp.IndexOf("Text=")>-1 Then
setText(index,objectProp.SubString(objectProp.IndexOf("Text=")+6))
End If
If objectProp.IndexOf("LoadUrl(")>-1 Then
Dim tx As String
tx=objectProp.SubString2(objectProp.IndexOf("LoadUrl(")+9,objectProp.LastIndexOf(")")-1)

loadUrl(index,tx)
End If

End Sub
Sub loadUrl(ix As Int,tx As String)
  wv(ix).loadUrl(tx)
End Sub
Sub setText(ix As Int,tx As String)

    Dim es As String
    Dim oTyp As String
    oTyp=oType(ix).Trim
    If oTyp="Button" Then
        bu(ix).Text=tx
    End If
    If oTyp="EditText" Then
        et(ix).Text=tx
    End If
    If oTyp="Label" Then
        la(ix).Text=tx
    End If

End Sub

Sub fgetView(ix As Int) As View

    Dim v As View
    Dim es As String
   
    Dim oTyp As String
    oTyp=oType(ix).Trim
    If oTyp="Panel" Then
        v=pa(ix)
        es="p"
    End If
    If oTyp="Button" Then
        v=bu(ix)
        es="b"
    End If
    If oTyp="EditText" Then
        v=et(ix)
        es="e"
    End If
    If oTyp="Label" Then
        v=la(ix)
        es="l"
    End If
    If oTyp="WebView" Then
        v=la(ix)
        es="w"
    End If
Return v
End Sub


Sub runAt(subname As String)As String
Dim apos, epos As Int
Dim findstr As String

    apos=code.IndexOf2(subname,apos)
    epos=code.IndexOf2(Chr(13),apos+subname.Length+3)
    findstr=code.SubString2(apos+subname.Length+1,epos)

Return findstr
   
End Sub

Sub initGlobals
'in this first Version it define all Dim .. as of the hole code
Dim apos, epos As Int
Dim findEnd As Boolean
Dim objectType,s1,objectName As String

Do Until findEnd
    apos=code.IndexOf2("Dim",apos)
    epos=code.IndexOf2("Dim",apos+1)
    If epos=-1 Then
      findEnd=True
      epos=code.IndexOf2("End Sub",apos+1)
    End If
    s1=code.SubString2(apos+3,epos)
    objectName=s1.SubString2(0,s1.IndexOf("As"))
    objectType=s1.SubString2(s1.IndexOf("As")+2,s1.Length).Trim
    makeDim(objectName,objectType)
       
    apos=epos
Loop

End Sub


Sub faddview(pm() As String)
Dim v As View
Dim i(4) As Int
Dim ix As Int
Dim oTyp As String
ix=findindex(pm(0))
oTyp=oType(ix)
i(0)=pm(1)
i(1)=pm(2)
i(2)=pm(3)
i(3)=pm(4)
If oTyp="Panel" Then v=pa(ix)
If oTyp="Button" Then v=bu(ix)
If oTyp="EditText" Then v=et(ix)
If oTyp="Label" Then v=la(ix)
If oTyp="WebView" Then v=wv(ix)

pmain.addview(v,i(0),i(1),i(2),i(3))
End Sub

Sub initview(objectName As String,eventName As String)
Dim index As Int
index=findindex(objectName)
Initialize2(objectName,eventName)
event(index)=eventName
End Sub

Sub editcode_TextChanged (Old As String, New As String)
    code=editCode.Text
End Sub
Sub editcode_EnterPressed
   
End Sub
Sub editcode_FocusChanged (HasFocus As Boolean)
   
End Sub


Sub RemoveViews
Dim i As Int
For i=pmain.NumberOfViews-1 To 0 Step -1
  pmain.RemoveViewAt(i) 
Next
End Sub
 

Attachments

  • B4Ainterpreter0_4.zip
    355.2 KB · Views: 455
Top