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,344
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Andrew, would it be possible for Dim Type indexer variables to be local to the array to which they are dimensioned, like local vars are local to their respective subs? This would open the possibility for b4a constants like color, file and dialogresponse for example, to be arrays instead of b4a subs and accessed using the exact same syntax as b4a without encroaching on other like named vars. So for example

B4X:
dim type(black, white, orange, yellow) color
array(color, 0, -1, ..., ...)
# var white is different than indexer white
white = "white"
# indexer white still works with color
settextcolor("myview", color.white)

I was thinking about creating an include file with all the b4a system constants and realized in doing so was going to use up a bunch of common variable names.

Thanks :)
 

agraham

Expert
Licensed User
Longtime User
I'm afraid not. The architecture of the language dictates that indexer variables must be standard variables. The reason for this is that when a variable is encountered a method is called to get that variable. If that method finds the variable is terminated by a "." then it recursively calls itself to get the value of whatever follows the dot which therefore has to be a standard variable or a constant. Interestingly as a side effect of this "." indexers can actually be chained - if your brain can cope with it!
 

JesseW

Active Member
Licensed User
Longtime User
Chaining Indexers? sounds intriguing. Would you elaborate? :)

I have a situation where I build a grid from panels of labels on a scrollview and need to tear the whole thing down and redraw it again. Currently, I prompt the user to rotate the device to cause an activity_create, and that works, but can you think of a more elegant solution?
 

JesseW

Active Member
Licensed User
Longtime User
Yes, but they're generated dynamicly based on the view of the grid chosen by the user. I was considering the consequences of removing a panel, then trying to remove one of its child labels and it dawned on me there is still a reference in the viewmap. I will consider this option more thoroughly.

I have written a RemoveAllViews sub that removes the last indexed element until view map is empty. Ate there any pitfalls to watch out for?

thanks again :)
 

JesseW

Active Member
Licensed User
Longtime User
PS. I like the indexer chaining. That will save me code and reduce complexity in the future :) kudos!
 

JesseW

Active Member
Licensed User
Longtime User
it seems to have worked perfectly :) Thx for your indulgence and assistance
 

walterf25

Expert
Licensed User
Longtime User
Error while trying to run

Hi guys, i was trying to run this code but i got this error, does anybody have any idea what this means, or how to get around this error?

Compiling code. Error
Error compiling program.
Error description: Property: StackDepth is readonly.
Occurred on line: 67
Blib.StackDepth = 15
Word: =

this error is in the Script Module by the way, any tips will be greatly appreciated.

thanks,
Walter
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, if you can spare a moment please...

I came to realize that my Chain and Run statements using a third activity weren't working correctly with large scripts.

So I removed the third activity and rewrote parts of script.bas to do everything itself. In a nutshell, the Chain statement loads the new script into a string called ChainProgram and sets the Args() array, then calls Blib.Halt, which (I am assuming) shuts down the current script and calls Blib_Ended, which, if it finds anything in ChainProgram, starts a new timer called tmrChain for 1/10th of a second, just enough time for Blib_Ended to exit, instead of executing Activity.Finish. In tmrChain_Tick, ChainProgram is copied to Program and then set to "", the first run flag is set to true, and Blib.Run is executed.

This all seems to work very well using the same large script of 1000+ lines that the previous attempt did not work on. I'm running this by you before I go any further, in case I've done something wrong, or you have some suggestions for me.

Thank you very much
Jesse
 

Attachments

  • B4Script_test.zip
    76.6 KB · Views: 366

JesseW

Active Member
Licensed User
Longtime User
...While I had this on my desk I thought I might as well add the ability requested in post #28 to add your own new functions to the BasicLibIDE internal Sys call table so that you can call them in the same way as the ones compiled into the library. In retrospect I should probably have done it this way from the start rather than having the library know what is implemented in Script.bas.

Andrew, I realize its asking a lot, but would you be willing to remove the dependencies to script.bas from the library, and code your original android statements via addsyscalls? This would give me great flexability in my b4script project, and relieve it from the burden of future updates because my script.bas is modified quite a bit.

thanks again for all your help
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I'll consider this in a few days time when the present spell of glorious weather ends and the rain returns so we can no longer get into the garden again. Everything is growing like crazy at the moment so we need to keep on top of the weeds otherwise things run away from us. In our garden (a bit less than 2 acres/0.75 hectares but mostly grass) if we let it get out of control it's a mammoth task to get it back again. "One years seed is seven years of weeds"
 

JesseW

Active Member
Licensed User
Longtime User
cool! thanks for the consideration :) and bravo on the garden!

and while I am thinking about it, have you checked out AIDE on the market? this is hot!!

jesse
 

JesseW

Active Member
Licensed User
Longtime User
hi Andrew. I trust the gardening is going, or went, well. my wife and I have spent a few weekends as well prettying up the place :)

while you are considering, or working on, pulling the strings of script.has out of the library, I wanted to share an idea I have. since you've graciously allowed the use of the _ char as the leading char in a var name, would it be much additional effort to hav those _variables be like process globals, and store their values in a b4a map, accessed by the varname? this would augment set/getsaveddata. I realize in basiclibide, there would be no use for them, but in my b4scripr project, they'd come in very, very handy. the b4s project I'm working on now is becoming quite complex, and it'd be so nice to be able to create certain vars once for all scripts to share without having to bundle and unbundle them along with any other passed/saved values in the saveddata commands.

on that note, I've been planning to add map accessibility for some time now. one approach, although not as clean and elegant as the method I described above, would be to create 3 new statements: setappvar(varname, value) to init/set a process global, isappvar(varname) to tell if one has been init'd, and appvar(varname) to retrieve a value. appvar values would be stored in a b4a map. alas, the preferred method would be the lib itself handling the _variables, but I could make this work if the preferred way isn't in the near future.

you're the man, Andrew. this wouldn't be possible without your kindness. thanks so much for it all :sign0188:
 

agraham

Expert
Licensed User
Longtime User
it'd be so nice to be able to create certain vars once for all scripts to share without having to bundle and unbundle them along with any other passed/saved values in the saveddata commands.
You could use ShareArray to do this and access the individual elements as named variables using the dot syntax.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
HOT DAMN!!!!! ANDREW!!! I'm so excited!!!

I was able to get true system wide global (process global) vars and arrays working, that are declared once and then remember their values from script to script and through pausing and resuming. I have two new functions, GlobalVar(name) and GlobalArray(name) that setup two maps that contain the variable/array names as keys and their contents as values. And it works :sign0060: 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?

This project is really starting to shape up! I really need to get a donation your way, if it pleases you.

What would the chances be of creating two new events, Blib_SubStarting and Blib_SubEnding? Then I could use the same techniques to code truly static (as in vb6 static) local var's that retain their value from call to call...

Man, I'm on fire! I'm so glad to be a part of this :sign0188:
 
Top