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: 31,054
  • BasicIDE2.97.zip
    118 KB · Views: 2,484
  • BasicLibIDE_1.98.zip
    44.1 KB · Views: 1,345
Last edited:

TommyE28

Member
Licensed User
Longtime User
Thank you for this nice tool agraham. Have it on my Archos 70IT tested and it works fine.
Is there a way to determine the current line number on which my cursor is there to set a breakpoint?
 

agraham

Expert
Licensed User
Longtime User
Version 2.5 now posted can add and remove line numbers from the displayed script. There is a brief mention of this in the readme.txt file.

I've also taken the liberty of changing the IDE to use Geocomputings layout file and code so that the IDE scales better on tablets and other larger screen devices.
 

bahoughton

New Member
Licensed User
Longtime User
Hello Agraham,

First, I thank you for the on device IDE. It's been a lot of fun to tinker with.

Next, I (expect to) expose my ignorance with a question or two:

- Is it possible to include the .src file(s) that we create with BasicIDE into a compiled APK what we create with Basic4Android?

- If so, is there a good example of how to do this?

Thanks in advance!
 

agraham

Expert
Licensed User
Longtime User
There are at least two ways to achieve this. Both should be easy to implement using the existing main activity of BasicIDE as a starting point.

One way would be to make a new project, include the .src as a resource (Files tab) and change the main activity of BasicIDE to load this from File.DirInternal and run it immediately.

Another way would be to again make a new project and change the main activity to make it look for a specifically named source file in the BasicIDE folder and again load and run it immediately.
 

bahoughton

New Member
Licensed User
Longtime User
Thank you. I'm going to do some experimenting to see if I can get it working. Your tips are appreciated!
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, I'm really liking the Basic IDE. This is simply amazing... I've read through script.bas and am learning how it interfaces with the library. I have a little issue tho...

I looked at the definition for some of the activity property setting subs, like SetActivityBackground, and decided to add a companion sub SetActivityTitle. But when I ran the script, it ended with an error. I got it to work with the Sys command as you stated before. Here is the code I use


B4X:
''Sets the activity title text
Sub SetActivityTitle(title As String)
   Activity.title = title
End Sub

''Sets the activity title color
Sub SetActivityTitleColor(color As String)
   Dim icolor As Int
   icolor = color
   Activity.TitleColor = icolor
End Sub

Am I correct in saying that the library itself already knows the definitions of certain subs? If so, is there a facility to inform the library of new command subs?

On a side note, I was able to successfully install Label_Click and Panel_Click events. I need them for a project I'm working on. I used the Blib.CanCall function so the script would not cause an error if the event catcher was not incorporated in the script. Here is the Script.bas code of the Label_Click event


B4X:
'Call the script "Sub label_click(sender)" when any Label Click event is raised. 
Sub Label_Click
   If Blib.CanCall("label_click") Then
      Dim v As View
      v = Sender   
      Dim params(1) As String
      params(0) = v.Tag
      Blib.Call("label_click", params)
   End If
End Sub
 

agraham

Expert
Licensed User
Longtime User
Am I correct in saying that the library itself already knows the definitions of certain subs?
Yes, BasicLibIDE.jar knows what's in Script.bas so both need to be modified to add new functions.

If so, is there a facility to inform the library of new command subs?
I'm afraid not, other than using the Sys command for ones unknown to the library. It is actually no more efficient (or inefficient :)) to use Sys rather than a built-in call - both use the same mechanism.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Thanks for your quick response. Can I feel free to modify script.bas, or is there a reason not to?
 

JesseW

Active Member
Licensed User
Longtime User
I am pleased to present my addition to this wonder tool, BasicIDE. I have added the ability to fling, so the editor text keeps scrolling after you release your touch from the screen. I've added it as an on/off type action so you don't have to use it if you don't like it. It is accessible from the menu.

A note to remember: Not so much in Gingerbread, and unknown in ICS, but in some the Froyo releases of Android, v2.2, if you scrolled the cursor off the screen and then touched the screen when it had stopped scrolling to place the cursor at a new place, the screen would jump back to where the cursor used to be, instead of staying where you flinged it to. If you like the fling characteristics, but this jump back to where it was behavior annoys you, there is a simple solution. When you have the screen where you want it, simply slide your finger to the side slightly and lift it off the screen at the point where you want the cursor, and the editor will not jump back. Problem solved.

Andrew, I hope you like and will keep this addition in future releases of BasicIDE. That would just make my day like you wouldn't believe :D I have many more new ideas for BasicIDE because I plan to use it much, and I will share them here if your open to new ideas for your project. In that light, my next addition would be the removal of all views on the activity except for the editor edittext itself, and the addition of a Settings and Debug menu options where the appropriate current on-screen and menu items will be moved to. Accessing the new settings and debug dialogs will be no more inconvenient than they are now. I just personally like the editor text window to be as large as possible, and would like your view / blessing on it. After that, I have other ideas...

Edit: I found a bug and made a couple of other enhancements. Please see the next post for details and the new project file...
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Here are the fixes and changes I made to the version described above

Fixed: I discovered that fling was lost on orientation change. Fixed. (the fling mechanism code has several changes to accommodate this fix)

Fixed: The Wrap setting was also lost during orientation change. Fixed.

Fixed: I also discovered that when the orientation changed, the source code changed flag lost its value. Fixed.

Added: The source code changed mechanism now includes a snapshot of what the source was when it was loaded or last saved, and will only report changes if the current source code differs from that snapshot.

Added: A new menu item [Abandon] has been added to allow the current source code changes to be abandoned and revert back to the last saved snapshot described above.

Ps... I forgot in the above post, that my next intended change (which should come today) is the ability to manually align the bottom of the source code edittext view to the top of the soft keyboard for those of us that don't like the two to overlap. This will also be an on/off type action in case you like it the way it is.

Also note that any changes and additions I make to Andrews project have been commented in the B4A source code
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
The Wrap checkbox has been moved to the menu. In its place is an arrow that is used to toggle the bottom of the text input area up or down.

I've also added the ability to calibrate the bottom of the text input area to the top of the keyboard so they don't overlap. Touch and hold the new arrow to start the calibration. When the calibration starts, touch inside the now smaller text input area, which has calibration instructions, to bring up the keyboard. If the line above the keyboard where spelling suggestions and punctuation doesn't come up, type a few letters to bring it up. Then, to move the bottom of the text area down, touch a down arrow. The 10 arrow moves it down 10 pixels, and the 1 arrow moves it down 1 pixel. Try to leave a single black line inbetween. If you go down too far, use the up arrows to bring it back up. When you are satisfied with where it is, touch the [Ok] button and you will be given the alignment value. Write it down. Next time, when you enter calibration mode, touch the [###] button and enter this number. It's quicker than recalibrating with the arrows.

A future update will save this value, along with all the other settings, to a settings file that will be loaded when BasicIDE is started so calibrating will no longer be necessary at all.

My apologies for such a clunky interface for doing this. I've chased how to bring the bottom of the text area up automatically when the keyboard is raised, like most other Android apps do, for a long time and have basically given up. I wonder if the reason it doesn't work is because B4A uses an Absolute layout. I just don't know...

So whats next? Reorganizing the menu. I've decided to leave the on screen views where they are. There is enough text input space. But the menu has too many items, so I will condense and organize them, and add a settings option that will save all your preferences. This update will come in a week or two.

I am open to any feedback anyone has. I only strive to make it easier to use for us, the programmers. Hope you enjoy the enhancements.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Andrew, I have a request, please. Would you add both ' and # as ignored statements for remarks and preprocessor directives to the BasicLibIde library? Thank you kind sir :)
 

agraham

Expert
Licensed User
Longtime User
I'm afraid not. That request would require more work that you probably realise as the library has a two-pass tokenizer as well as the core token despatcher that would need to be modified and I am presently way out of the required level of familiarity with how it all works to start poking around inside it.

Also single quote is already in use by the tokenizer as strings can be either single or double quote delimited. This was intended to make it easier to programmatically manipulate interpreter source code in Basic4ppc/Basic4android programs.
 

JesseW

Active Member
Licensed User
Longtime User
understood. I believe there is still an issue with activity_resume calling other subs. here is a test script to demonstrate



B4X:
rem test
rem

x = 5

sub activity_resume
  mysub
end sub

sub mysub
end sub

if there is no activity_resume sub, or if it doesn't call another sub, it runs fine.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Try this, it may fix the problem. I was trying to allow for the situation where during a Call into the library it calls out to Script.bas which then Calls in to the library again. In retrospect this is probably unfixable as Call is actually driving the interpreter which probably can't cope with being called recursively so if the fix works I think I'll detect any recursive attempt and error it in the next release version.

Also "#" should now be treated as "Rem" to allow for your preprocessor directives.

I haven't done a lot of testing on this so I would suggest that you test that, as well as Activity_Resume and Activity_Pause, the other events can call Subs which in turn call other Subs.
 

Attachments

  • BasicLibIDE1.51.zip
    45.5 KB · Views: 445

JesseW

Active Member
Licensed User
Longtime User
Try this, it may fix the problem.

Thanks, preliminary testing shows it works correctly now. I will do some more in-depth testing later when I have a chance.

Also "#" should now be treated as "Rem" to allow for your preprocessor directives.

This seems to work also. Thanks for the addition.

Everyone using BasicIDE should download the BasicLibIDE1.51.zip file above and place the two files in their additional libraries folder.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
It's never that simple! :( Version 1.51 is also broken due to a recursive problem. If a call of the library Call method by an event makes a SysCall that performs an action that causes a View event to be raised that is called immediately by Android and not through the message queue (like changing a Checked property) this causes the Call method to be entered recursively and it did not cope with it gracefully. My mind is about to explode!

I think it's fixed in 1.52 here. Please test and report back then I'll repost it properly. Any other small changes wanted while I've got this on my desk?
 

Attachments

  • BasicLibIDE1.52.zip
    45.6 KB · Views: 405
Top