Getting started with Basic4GL Mobile

28-Apr-2016
Tom Mulgrew

Getting started with Basic4GL Mobile

This page describes how to create a program in Basic4GL Mobile and get it running on your Android phone or tablet.

Requirements

You will need:

  1. A PC, running Windows 7, 8, or 10, with an OpenGL 3.0 compatible graphics card and drivers.
  2. An Android phone or tablet running Android 4.0 (Kitkat) or later.
  3. A USB cable to connect your phone/tablet to your PC.

Step 1 - Install Basic4GL Mobile on your PC

Download the installer from the Basic4GL Mobile website. (Click the big blue button that says "Download for Windows 7,8,10").

Run the file and follow the prompts to install Basic4GL Mobile.

Then run Basic4GL Mobile. You should see the Basic4GL Mobile IDE.

From here you can key in a BASIC program, run it and debug it. You can also view the help files, which explain the Basic4GL BASIC language syntax, and the different commands for computation, sprite graphics etc.

It's a good idea to check everything works, by loading and running a sample program:

  1. Click the "Open" toolbar button or press Control+O on your keyboard.
    This brings up the file dialog, pointing to the Basic4GL Mobile sample programs folder.
  2. Double click the "snakedemo" file to load it into the editor.
  3. Click the "Go" toolbar button or press F5 to run it.

The snake game should popup in a second window:

You can play snake by left clicking and dragging with your mouse to simulate touching the screen and swiping (actually touching the screen on your PC won't do anything though, even if you have a touch enabled screen).

When you're done, close the window with the mouse or press Esc.

Step 2 - Install the Basic4GL runtime on your phone/tablet

Click here to go to the Google Play store page: Get the
Android App

Or search for "Basic4GL" in the Google Play store.

Install the App, and run it.

The first time it runs not much happens, because there's no BASIC program to run.

The important part is the "Please place 'program.vm' in folder:" message, and the folder to place it in. This is often /storage/emulated/0/basic4gl, but not always, so be sure to check where it is on your phone/tablet.

Step 3 - Create program.vm

"program.vm" is the compiled program ready to be run on the Basic4GL virtual machine.

The Android Basic4GL App needs this, as well as any files that your program uses (like images etc - snakedemo doesn't use any though).

It's easy to create:

  1. In Basic4GL Mobile (on your PC), click "File" and then "Compile for Mobile..."
  2. Select the folder to save it in (the default folder is fine).

Step 4 - Transfer it to your phone/tablet

Here you need to transfer program.vm (and any other files your program uses) into the "basic4gl" folder on your phone/tablet.

The recommended way is using a USB cable as described below. But other ways are possible if you don't have a cable such as creating a shared network folder. Often you just need a bit of creativity and usually a 3rd party App.

  1. Open Windows file explorer on your PC (right click the start menu and choose "File Explorer"), and find the program.vm file you created above.
  2. Connect your phone or tablet to your PC using the USB cable.
  3. If your PC pops up a window about synchronising photos or music, just close it.
  4. You may need to put your phone/tablet into transfer files mode. My phone by default goes into "Charge this device" mode. I have to pull down the notification area, select it and change it to "Transfer Files" mode.
  5. Open another file explorer window on your PC.
  6. Look underneath "This PC" for the phone/tablet. Depending on the brand it may be named differently, for example my generic tablet comes up as "Android Tablet", whereas my phone appears as "Nexus 5X".
  7. Open your phone/tablet in file explorer.
  8. Open "Internal shared storage" if that comes up.
  9. You should reach the main Android folder (which contains the standard folders like "Download", "Music", "Pictures").
  10. Find and open the "basic4gl" folder.
  11. Drag and drop program.vm from your PC into the basic4gl folder.
  12. (Repeat for any other files your program needs)

Step 5 - Run Basic4GL on your phone/tablet

Switch to the main menu on your phone/tablet and run the "Basic4GL" App again.

The game should start running on your phone/tablet.

Auto generating program.vm

To save time, you can configure Basic4GL Mobile to automatically generate program.vm automatically whenever you compile and run your program.

To do this, click "Settings->BASIC runtime settings".

Tick "Create program.vm on compile" and click "OK".

Now whenever you run your program, it will create or replace program.vm in the same folder as your program is saved.

Remarks

This is the main workflow in Basic4GL Mobile. You develop your program on your PC, then whenever you want to test it on mobile, drag and drop it over and run it there.