Share My Creation Device Basic language IDE

Unfortunately without a Device IDE it is no longer possible to whip up quick and dirty programs on an Android device like we could with Basic4ppc on Windows Mobile.

I realised that my BasicLib script interpreter library only lacked one thing that stopped it being used as the basis for an interpreter for a device IDE and that was that it didn't support any means of responding to external events so all it could do was run linear code then exit. Fine for scripts but not for a user driven application that spends most of its time suspended waiting for events to happen. So I added it!

As well as being able to respond to events a program needs to be able to interact with the platform to add controls and access the GUI, file system and other OS services. Unlike previous versions of BasicIDE, which used the normal BasicLib library and relied upon the "Sys" function to call methods, version 2.2, and future, versions use a new BasicLibIDE library that "knows" about the methods in Script.bas so the platform functions are now embedded in the script language. It is important that the version of Script.bas matches that of the BasicLibIDE library as both need to be modified in parallel to add new functions to the language.

The previous Sys and CallHostSub functionality is of course still available.

The demo program here supports the most important views, and their events, for small programs and has graphics and file handling support. Look at Readme.txt for instructions and the comments in the Script module to see what is implemented there.

EDIT :- See post #7 for a suggestion to add Invalidate to the Script module

EDIT :- Version 2.0 posted. See post #8 for details.

EDIT :- Version 2.1 posted. See post #9 for details.

EDIT :- Version 2.2 posted. See post #15 for details.

EDIT :- Version 2.2a posted with the BasicLibIDE library included. See post #17 for details.

EDIT :- Version 2.3 posted. See post #18 for details.

EDIT :- Version 2.4 posted. See post #20 for details.

EDIT :- Version 2.5 posted. See post #23 for details.

EDIT :- JesseW has posted his improved version of the IDE itself, see post #32 for details. You will still need the BasicLibIDE jar and xml from the archive in this post.

EDIT :- Version 2.6 posted. See post #47 for details.

EDIT :- Version 2.7 posted. See post #51 for details.

EDIT :- Version 2.8 posted. See post #52 for details.

EDIT :- Version 2.9 posted. See post #79 for details.

EDIT :- Version 2.91 posted. See post #87 for details.

EDIT :- Version 2.92 posted. See post #92 for details.

EDIT :- Version 2.93 posted. See post #95 for details.

EDIT :- Version 2.94 posted. See post #100 for details.

EDIT :- Version 2.95 posted. See post #118 for details.

EDIT :- Version 2.96 posted. See post #138 for details.

EDIT :- Version 2.97 posted. See post #140 for details.

EDIT :- Version 1.98 of BasicLibIDE is posted below. Use this instead of the version in BasicIDE2.97.zip. It fixes a problem with Call and CallSub.
 

Attachments

  • BasicLibIDE.jpg
    BasicLibIDE.jpg
    12 KB · Views: 30,890
  • BasicIDE2.97.zip
    118 KB · Views: 2,351
  • BasicLibIDE_1.98.zip
    44.1 KB · Views: 1,230
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Andrew, I almost forgot! I drive a truck all week, and today, on my way south of Montgomery, Alabama to the Walmart distribution center in Brundidge, Alabama, I happened to glance at my Garmin GPS, and this is what was showing!!!

:D
 

Attachments

  • agraham.png
    agraham.png
    44.8 KB · Views: 492

agraham

Expert
Licensed User
Longtime User
I'm not sure about the names, as the term 'global' actually refers to any variable accessed in the main code section. SysVar(name) and SysArray(name)??? Any ideas?
I'd say they are acting as global static variables and name the calls something appropriate.

What would the chances be of creating two new events, Blib_SubStarting and Blib_SubEnding?
It's possible but I'm very dubious as the performance hit of making a call twice per Sub would be extremely large. Accessing an array shared by ShareArray has literally no overhead in both host and script. The only benefit of having a local static mechanism would be visibilty. I would suggest you stick to using ShareArray with suitably named variables that emphasise their locality.

I looked up that Walmart centre on Google Earth and boy, that's a big place! :eek:

P.S. No donation needed.
 

JesseW

Active Member
Licensed User
Longtime User
It's possible but I'm very dubious as the performance hit of making a call twice per Sub would be extremely large...

Understood. I wondered about that...

...I would suggest you stick to using ShareArray with suitably named variables that emphasise their locality.

The weird part is while I was coding it to use ShareArray, I wondered if I could get true global individual variants, instead of just arrays, so I tried saving them, using SetGlobal (because you can't save individual variants using ShareArray, and there is no ShareGlobal), on activity_pause and blib_ended, and restoring them, using GetGlobal, on blib_starting, and it worked. So when I coded the arrays, I had forgotten about using ShareArray and coded them likewise, using GetArray and SetArray. There isn't a single ShareArray in the whole thing :D And... I have true individual global variants. I'm really pleased...

The two new functions I added are simply to create new key/value pairs in the maps the vars and arrays are saved in. The get and set routines do all the work, iterating through all the pairs.

I looked up that Walmart centre on Google Earth and boy, that's a big place! :eek:

P.S. No donation needed.

Yes, they're monsters! I drive for a food manufacturer, so I am at places like that almost every day. You get used to it...

Thanks again for all your help
Jesse
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
@JesseW. Do you have any plans to post a version of your IDE?

yes, but the past month at work has taken all my spare time, so dev is really slow going right now. I've added a few new features, and I've a few bugs to work out, so I will post an update in a few weeks.

can you share your reason for asking? :)

I've been considering posting it as an apk instead of a b4a project. any thoughts on that?

its been posted for quite some time here http://www.b4x.com/forum/basic4andr.../15468-b4script-device-basic-programming.html
 
Last edited:

agraham

Expert
Licensed User
Longtime User

JesseW

Active Member
Licensed User
Longtime User
Andrew, since b4a's default data type is string, and b4script uses string types to pass parameters back and forth to subs, is there any reason, (like a performance hit for example), I shouldn't remove the 'As String' type casters from the sub definitions? I'd really like to change them for increased readability in the help file since b4script doesn't use type casters. thanx :)

ie change:
B4X:
sub FileReadString(dir As String, fileName As String) As String

to:
B4X:
sub FileReadString(dir, fileName)
 
Last edited:

margret

Well-Known Member
Licensed User
Longtime User
Just downloaded the BasicIDE to try on my ASUS 101 with Android 4.0.3. I copied the BasicIDE.jar, xml to the XtraLibs. I created the BasicIDE folder in the SDCard root, created a sub folder Help and copied the src files to the BasicIDE and the html to the Help folder. I then compiled and installed it. When I open it, it says BasicIDE v0 in the titlebar. If I press menu and select more, then Help. It says /mnt/sdcard/BasicIDE/Help if not a folder. I have viewed the help file in the file manager by browsing and tapping the help file. It is there and the folder shows just as it should. If I try to Dim a var it says error: expected CR. Any info or help about this? I am using B4A 2.02.
 

JesseW

Active Member
Licensed User
Longtime User
off the top of my head, I don't know why the help isn't working. that'd be a question for Andrew to answer.

as far as dimming variables, only arrays can be dimmed. all other vars are variants. those used or referenced before the first sub are global. all others are local. neither are dimmed. only dim arrays.

I am developing a different ide based on Andrew's basiclib. it has many additional features I'd be more than happy to send it to you if you'll pm me your email.

see ya
jesse
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
ps... and only one array per dim statement.

did you know you can use object notation when coding arrays? consider the following

B4X:
dim a(6)
a(0) = 0
for ix = 1 to 5
  a(ix) = ix
next

you can use this instead...

B4X:
dim a.6
a.0 = 0
for ix = 1 to 5
  a.ix = ix
next

its even possible to use nested object notation, like

B4X:
dim a.6
dim index.6
for ix = 0 to 5
  a.ix = ix
  index.ix = 5 - ix
next

ix = 4
b = a.index.ix

this notation has come in very handy a few times for me.

chow...
jesse
 

JesseW

Active Member
Licensed User
Longtime User
@ JesseW, do you have just a small piece of test code I can try on my install and see if it runs? Mine still shows version v0 in the titlebar and most things I type in gives errors. I am hoping it's just that I don't know how to use it..

sorry, but the code I develop uses my version, called b4script, and wouldn't run correctlyon basiclibide. let me suggest downloading and compiling the latest published version of my ide from the link below. I am the worlds worse about getting updates out, so that version is way behind. I keep thinking of improvements before I finish debugging, so any current version isn't ever fully complete. perhaps I should work for Microsoft >sigh<

http://www.b4x.com/forum/basic4andr.../15468-b4script-device-basic-programming.html

Andrews project does come with some example code tho. look in the readme file of his project to find it.

good luck
jesse
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, it seems the Exit statement doesn't clean the stack correctly.

B4X:
for i = 1 to 100
  for j = 1 to 100
    if i < 100 then
      exit
    endif
  next
next
#

this code throws a stack depth exceeded error. would you look into this?

thank you
jesse
 

agraham

Expert
Licensed User
Longtime User
Hmm :( Something seems to have wrong over the years. the same problem is also in my "master" C# .NET version for Basic4ppc. Goto and Exit both break the block structuring of the code so there is some hairy logic in the second pass of the tokeniser that should scan the code and pre-calculate the stack corrections and jump locations needed to allow them to cleanly leave For and If blocks even when nested. Exit is simpler as it only has to look forward while Goto has to look both forward and back.

Both Goto and Exit now longer work as originally designed, so I have broken something at some time in the past. I'm not really worried about Goto and might remove it from the language (what do you think?) but Exit ought to work properly but is complicated because it may jump out of one or more nested If blocks as well as the For block. I will look at it but I remembering struggling with the logic so it is not an immediately obvious fix. In the mean time the following works to achieve the same end. You should be able to structure the code in the loop to do whatever you need and still get the effect of Exit.
B4X:
for i = 1 to 10
  endval = 100
  for j = 1 to endval
    if i < 100 then
       j = endval
    endif
 next
next
 

JesseW

Active Member
Licensed User
Longtime User
I have been able to code around the flaw, so its no big deal. cost me some frustration early on. I'm not privy to your lib code, but it seems to me, the way I understand inner workings of certain dialects of basic, that perhaps exit needs to pop two entries off whatever kind of nesting stack is used, one for the If nest and the other for the For or Do nest, and only one is being popped, thus leaving a dirty stack that overflows. a single line If statement (ie. If j < 100 Then Exit) would seem to correct this. just thinking out loud...

as far as removing the Goto, I dunno. it wouldn't break any code of mine, but may cause some grief to others. may I suggest leaving it, and listing it as depreciated in the help file?

thanks for looking into this
jesse
 

agraham

Expert
Licensed User
Longtime User
Version 2.96 now posted fixes both Exit and Goto.

Both fixes were easier than I anticipated. Goto broke when a cast was unsigned that should have been signed. :eek:

Exit now doesn't try to be clever. ;) In a brute force solution For saves the stack pointers on entry and Exit restores them if it executes, so neatly overcoming trying to count If block nesting depths.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
) ... In a brute force solution For saves the stack pointers on entry and Exit restores them if it executes, so neatly overcoming trying to count If block nesting depths.

i assume the Do statement also does this? that's it for looping constructs, isn't it? Return exits subs, so I can't think of any other...

thanks again
 

agraham

Expert
Licensed User
Longtime User
i assume the Do statement also does this?
It does now! :) Version 2.97 now posted corrects the oversight. :eek:

There are three stacks. One for SUB calls,one for IFs and one shared by FORs and DOs.

End Sub and Return just set the If and Do stacks empty so need no logic as they also pop the SUB stack and so there is no block structuring to remember even if Return exits from one or more nested DOs or IFs.

Exit however needs to respect the existing block structuring as it can return to an outer FOR, DO or IF block which it wasn't properly doing but hopefully now is.
 
Top