Share My Creation B4Script - On device basic programming

JesseW

Active Member
Licensed User
Longtime User
Andrew, I just noticed the chain/run statements do not call activity_pause before loading the new script. since I had originally envisioned each script of a project being its own activity, I am now thinking activity_pause should be called.

do you have comments either way?
 

JesseW

Active Member
Licensed User
Longtime User
blib_ended no longer calls activity.finish when chaining. it simply sets a 10ms timer so blib_ended can exit, then the timer restarts blib with the new script. activity_resume is manually called when blib_ended is called at the end of the main code segment. this is a much quicker and elegant solution than switching activities and the only negative is the menu items don't reset, but I am writing a custom menu for that.

I was really hoping you knew of a hook in android that would allow for a manual activity restart that you'd show me how to activate with reflection. (hey, a guy can hope, can't he?)
 

JesseW

Active Member
Licensed User
Longtime User
Version 1.05 is here! This is a major update. Lots of things have been added and updated. Here's the list:

- Added HideKeyboard command
- Open Project menu option now displays a list of files to load instead of automatically loading the projects main script
- Find & Replace is now working. It's a bit clunky, but it works nicely.
- The Help menu option has been replaced by Misc. Help is now an option inside Misc
- Undo has been added. It allows a single level undo for now. A later release may provide multiple levels
- A new directive, #STACKSIZE has been added. The stacksize may be set in settings, but each programs memory requirements are different, so if this new directive is in a script, it will be used instead of the value in settings. To use, enter #STACKSIZE 16 on a line by itself (replace 16 with the value you want)
- A new menu option, Copy To, has been added in the File menu. Once a script is in the editor, use Copy To to copy it to another project. This is useful if you have a project called Includes which has all your include files. They may now easily be copied right from B4Script
- Saving a script now creates automatic backups. It can be turned off in settings, but should be left on unless storage is critically low. Currently, it has a bug and saves two copies of the file instead of just one, and I can't find it. Help???
- Fixed a bug or two in the Gravity_ constants
- Improved logic of the #INCLUDE directive to not include the same script twice
- Improved logic of the #INCLUDE directive to merge sub's. How this works: The main code section (before the first Sub statement) of the included script replaces the #INCLUDE directive of the including script. The each sub in the included script is examined and if it exists already in the including script, the code body of the included script is placed at the top of the matching sub in the including script, just below the Sub statement. This allows for additional functionality to be added to an already existing code sub. If there is no matching sub in the including script, the included sub is added to the end of the including script. In the next post, I will upload and explain a custom menu system written entirely in B4Script, which uses this conecpt.
- Scripts included with the #INCLUDE directive are now marked with ###Begin and ###End tags in the final script. To demonstrate, write one script to include another, then use the File / Merge Scripts option to display the merged, or final, script.
- If a script uses the Chain, Run or Restart statements, AND the script has finished the main code block and the Activity_Resume event sub has finished executing, the Activity_Pause event sub will now be executed before the script chains to the next script. Note that if the Chain, Run or Restart statements are called from the main code section or the Activity_Resume sub, Acitivity_Pause will not be called. *** Andrew, is this the correct way of doing this?
- You are now warned of an overwrite while saving a script

I had coded the AddDefaultEdittext statement, but the edittext fields it created were not correct, so the code is still there, but remarked out, and the statement was removed from the Blib.AddSysCalls method. If anyone has a desperate use for it, let me know.

See the first post for the download link...

Most importantly... Enjoy!!!
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Here is the Custom Menu include file. In the zip is a readme which explains how to use it. The script is documented for your learning pleasure About the only differences are there are three rows of 4 items max, for a possible 12 items, instead of just 6, and there is no raising up animation.

The reason for the custom menu is there is currently no way in Basic4Android to remove items from the system menu. In B4Script, it is now possible to have a project with many scripts which call each other using Chain and Run statements. It is possible that each of these scripts will have different needs that require different menu items. Without restarting the underlying activity, there's no way to replace menu items. So a custom menu system was designed to overcome this limitation. Each script can now have its own independent menu items, easily accessed from the script.

Remember, this menu system is written completely in B4Script. There's not much this little powerhouse development system can't do.

Hope you enjoy...
 

Attachments

  • custommenu.zip
    3.1 KB · Views: 537
Last edited:

ScriptBasic

Member
Licensed User
Longtime User
I'm running on a Samsung Galaxy Tab 2 10.1 tablet and there seems to be a difference in the UI theme between BasicIDE and Basic4Android apps. The buttons in BasicIDE seem flat where B4A buttons have a theme to them. It may just be me as the scale factoring to fit on on my tablet may be distorting the controls.

:sign0104:
 
Last edited:

ScriptBasic

Member
Licensed User
Longtime User
Can I (re)compile BasicIDE with the DBUtils library for SQLite3 support? Is this what CallHostSub is used for?
 

agraham

Expert
Licensed User
Longtime User
"CallHostSub" (which also has the alias "Sys") was the original way to extend the capabilities of a script by accessing Basic4android Subs. The latest version of BasicLibIDE supports adding your own keywords by "AddSysCalls" which uses the same calling mechanism as "CallHostSub" but makes your added functions look as though they are part of the script language. The BasicIDE demo uses this to implement the graphical capabilities. Look at the "Custom Functions" region at line 1995 in the Script module of the demo.
 

ScriptBasic

Member
Licensed User
Longtime User
That is a great feature to help expand on the interpreter / GUI designer.

Is the Script.bas file the only place one needs to reference the new function in the language?

I'm going to try and add DBUtils to the language and see how far I get. :sign0095:
 

agraham

Expert
Licensed User
Longtime User
Is the Script.bas file the only place one needs to reference the new function in the language?
I don't inderstand what you mean by "reference" in this context. However the new functions are called using the Basic4android event mechanism in the same way that the other BasicLib Events like Loaded and Starting are called. This means that the called function must reside in the activity in which the BasicLibIDE object is Initialized. They in turn can of course then call Subs declared in a code module if you want to move clutter out of the activity.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
A new version of B4Script has been posted. The download method has been changed from downloading a Basic4Android project file and compiling it to downloading a complete app file. The .apk app file may be found here

Its been a while since I've uploaded a new version, and there are many enhancements, unfortunately too many to remember Among the important ones: a new help file display format for the Android Extensions Help option. Also, B4Script is now using the new version of the BasicLibIde library that pulls all the roots out of the script.bas file and allows for complete control of the functions outside the core language.

I've experienced some issues with the Static and AppStatic statements when using more than a few arrays, and I've not had time to resolve them.

Jesse
 

JesseW

Active Member
Licensed User
Longtime User
MMaze - Mage generator and explorer

This is a little something I did in my spare time. It started out as a simple maze generator, just to see if I could still remember how to do it from the old 8-bit days. After that was finished, I was able to flush in some code to display the maze in 3D. This script demonstrates graphics rendering for both the B4Script and BasicLibIde apps.

While you are navigating through the maze, remember the north star is visible in the northern sky and the moon in the southern sky.

It's not completely finished, as you'll see when you step on the red exit square (it doesn't end the game), so you'll have a little challenge yourself, but for the most part, the generation, rendering and navigation routines are all complete and working.

To start, choose a skill level by selecting the size of the maze. After it have been generated, touch the [Continue] button, then navigate through the 3D maze to your thumbs delight. Hope you enjoy.

Note: although it was developed for the B4Script app, it should work with little modification with AGraham's BasicLibIde app. I haven't tested it, but I do know you'll have to add at least this function to the mmaze.b4s file, then rename it to mmaze.src:

B4X:
Sub IIf(expr, trueval, falseval)
  If expr Then
    Return trueval
  Else
    Return falseval
  Endif
End Sub

If it proves too difficult to convert to BasicLibIde, please download the B4script app from here.

I do not mind if you borrow some of this code for your own projects. Please feel free...
 

Attachments

  • mmaze.zip
    3.2 KB · Views: 576
  • Screenshot_2012-11-13-11-26-09.png
    58.3 KB · Views: 603
  • Screenshot_2012-11-13-11-26-22.png
    20.9 KB · Views: 622
  • Screenshot_2012-11-13-11-26-32.png
    18.5 KB · Views: 587
  • Screenshot_2012-11-13-12-18-10[1].png
    20.8 KB · Views: 573
Last edited:

nypaulie

Active Member
Licensed User
Longtime User
Creating an apk file.

Thanks JesseW! I've been playing with the demo B4Script you've linked and have made some of my own .b4s files. I want to know if it's possible to make apk files from these (.b4s files) or is this something you are working on.
 

JesseW

Active Member
Licensed User
Longtime User
Thanks JesseW! I've been playing with the demo B4Script you've linked and have made some of my own .b4s files. I want to know if it's possible to make apk files from these (.b4s files) or is this something you are working on.

Edit: Paulie, I'd sent you a private message. You may disregard that message. I've published the project as described below. Have fun!
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
I've posted the project for Basic4android that allows B4Script projects to be compiled as .apk apps here.
 

JesseW

Active Member
Licensed User
Longtime User
Version 1.10 is uploaded in the Test My App forum. See this link for more information
 

JesseW

Active Member
Licensed User
Longtime User
Version 1.11 is now online here. It adds the ability to add shortcuts to your homescreen, that launch project scripts when touched.

I've been wanting to add this for a LONG TIME. Im so glad it's here! :sign0060:
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, I plan to add the remaining views methods and events. there'llbe quite a few. do you forsee any pperformance degradation? thx
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…