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,909
  • BasicIDE2.97.zip
    118 KB · Views: 2,367
  • BasicLibIDE_1.98.zip
    44.1 KB · Views: 1,241
Last edited:

agraham

Expert
Licensed User
Longtime User
I can't try it properly as you haven't included either of the actual scripts. However if it works when stepping I would guess it's a timing problem of some sort when trying to start the Script activity before the Main activity is fully resumed. Try starting a Timer in Main.Activity_Resume, disable the Timer in its Tick event and start the Script activity there. Start with a couple of seconds delay and if it works play with smaller delay values.
 

JesseW

Active Member
Licensed User
Longtime User
I tried your timer suggestion, and 1000ms was sufficient on an emulator running 2.2, but 100ms was not. I had already thought of that, and thought the idea was a bad fix rather than a good solid implementation.

But I was able to fix it rather eloquently, though. Instead of activity script falling back to main to do the processing, then finding a way to restart script, I created a third activity, Chain, which has a empty activity_create, and activity_resume has only one statement, activity.finish, then all the processing is done on the way out in activity_pause. This way, activity script comes back up into play naturally, instead of having to find a way to force it or wait for it, and processing resumes naturally. Since activity_resume is called instead of _create when script comes back to focus, I had to call _create from _resume, but it works like a champ. Every time. I'm glad its behind me.

I also added a Run command to compliment Chain, that loads and runs another script without sending an array as Args(), and SavedData() is dimmed back to 0.

Unfortunately, against what you had hinted to in an earlier post, these mods have necessitated modifications as well as additions, so now I have the daunting task of going through my script.bas and comparing it line-by-line with 2.9 script.bas, ensuring the new 2.9 is fully equipped with my changes. I was hoping for a way around this, as to why I mentioned it up front, but the extra work is DEFINITELY worth the outcome.

Andrew, you're the man! Thank you one more time :D

ps. As soon as I'm done converting script.bas to 2.9, I will start a new thread for B4Script and post the project there.
 

agraham

Expert
Licensed User
Longtime User
You can use your existing 2.8 script.bas with no worries under 2.9. The only difference is the addition of

B4X:
Dim args(3) As String
args(0) = "Fred"
args(1) = "Bill"
args(2) = "Charlie"
Blib.Run(args)
in Activity_Create to test the args array length fix.
 

JesseW

Active Member
Licensed User
Longtime User
Tested. You forgot to tell me to change the ver# >D'Oh!< :D

Sorry everyone, I don't have the time now to update the help comments in all the new additions and properly post the project file in a new thread. I will soon.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Andrew, I just discovered, after pulling most of my hair out, that the StrRemove function has been actually coded as StRemove. If / when you resolve this, would you leave StRemove intact? Thanks..

Jesse
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, I've found two bugs:

1. if there isn't a blank line at the very end of a script, adding line no's deletes the last line.

2. the ElseIf statement always throws an exception after a previous ElseIf has tested true. In the code below, line 5 will always throw an error.

B4X:
 if false then
  a = 1
elseif true then
  a = 4
elseif false then
  a = 5
elseif true then
  a = 6
endif

ps. nevermind in leaving StRemove intact when you correct it to its proper StrRemove name.

Thanks again for this wonderful tool.
 

agraham

Expert
Licensed User
Longtime User
Version 2.91 now posted fixes the typo in the name of the StrRemove function and the also the ElseIf problem.

You could have fixed the line number "feature" as it is in Basic4android code in Sub AddLineNumbers - but I have done it anyway, though I didn't note it in the versioning comments and can't be bothered to go through packaging and uploading this version again just to correct that.
 

JesseW

Active Member
Licensed User
Longtime User
thanks for the fixes :D I know I could have fixed the line # thing, but it still would have needed correcting in your version anyway. thanks again..

were any changes made to script.bas?
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, would you consider a mod that would allow the underscore char _ to begin a variable name? ie. Dim _id(0)

thank you again, so much
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, finding some issues in the math functions.

1. the Round throws an illegal argument exception no matter how it is used

2. Int(4.8) returns 4.8 instead of 4

3. all of them seem to choke on a fraction without a leading zero, ie. .5 - is this an android thing?

thank you sir
 

agraham

Expert
Licensed User
Longtime User
Version 2.92 now posted. Round and Int, which suffered in the transition from C# to Java are now fixed and underscore is now accepted as the start of a variable name.

Numeric literals must start with one of the numeric characters 0 to 9 because "." is a keyword used in the syntax for accessing the elements of a structure variable and if present at the beginning of a number will be parsed as the keyword and not as a decimal point.
 

JesseW

Active Member
Licensed User
Longtime User
Thank you very much. I understand the "." keyword. I REALLY like the concept of using the array indices behind the dot! I use it all the time. I continually find myself wanting to use numeric literals instead of variables tho... like array.1 or array.23 - hint... hint... In the meantime I just have a few variables, zero, one, two, etc... and use array.zero

Thanks again :)
 

JesseW

Active Member
Licensed User
Longtime User
Thanks for the update :)

But... In the zip file in post 1, BasicLib.jar and .xml are inside instead of BasidLibIDE.jar and .xml. I installed them anyway, and started b4a, and BasicLibIDE ver is still 1.92 :(

If it makes you feel any better, I uploaded the last ver of B4Script without any help files >blush<

Thanks
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, found an anomaly with the For statement: it will always iterate at least once, even when its condition is pre-satisfied and shouldn't iterate at all. Typical Basic behavior dictates a For Next loop can skip iterating altogether if the exit condition exists at the onset. Here is an example

B4X:
item = 0
for n = item - 1 to 0 step -1
  msgbox(n, "")
next
#

although no one would ever need to write a hard coded loop that would never execute, I do have a routine that responds to a touch from a list of items, then looks for a non-zero value in the items above it, but if the first item is touched, as in the example above, it still eiterates when it shouldn't, causing an error because there is no -1 item in the list.

I can work around this, if this behavior is intentional. Just bringing it to your attention.
 

agraham

Expert
Licensed User
Longtime User
By design - yes, but only because I didn't take this possibility into acount. I've checked what Basic4ppc does, which is the reference for the behaviour of this library and it does not iterate in this situation so I'll implement that same behaviour. It's an easy fix which I've done and checked in my C# master version. I'll do the Java library mod later tomorrow.
 
Top