Author Topic: BASIC for Android  (Read 17292 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
BASIC for Android
« on: July 14, 2013, 04:03:55 PM »
This thread is dedicated to porting BASIC languages and translators to Android ARM Linux with on device development. (C/C++ compiling on the device with .APK application exporting) At the moment we have ScriptBasic, BaCon and MBC (AIR's gcc BCX) working on Android. The goal is to create a generic API for accessing the Android Java VM resources from native C/C++ code the BASIC languages were written in. This is not a new concept and the tools and libraries readily available for projects like this one. I will append to this post with examples and current code releases as I don't have the same time limit restrictions as where this thread originated.

Project Development File Repository

I have created a members only board to store current development efforts. My reasoning for making these files available only to members (developers & advocates) is that I don't want half-baked work in progress files floating around the net and assumed to be released code. When members release their code to beta, guest attachments will be available.

« Last Edit: July 16, 2013, 12:09:51 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - C4droid
« Reply #1 on: July 14, 2013, 04:57:53 PM »



Quote
C4droid is a user-friendly (but powerful) C/C++ IDE + C/C++ compiler for Android with GNU Makefile, SDL and Qt support. C4droid supports devices with ARM processors only (not devices with Intel x86 or MIPS processor).
You can create your own applications on Android device and run them even without Internet access: compiler is offline. Result can be exported to an executable (for terminal apps) or APK (for apps with GUI).
This app uses TCC and uClibc (or GCC + Bionic with a plugin), so it has full support of ANSI C and ISO C99 (and full C++ support with GCC).
C4droid supports syntax highlighting, code completion and source code formatting, so it is a very handy tool for education and programming on the go.

C4droid will ask you to install C++ support at first startup and will configure itself in semi-automatic mode.
If you want to do that manually, you need:
0) Enough internal memory OR root rights. C4droid does not require root rights for devices with more than 50MB of free internal memory.
1) Install GCC plugin (C4droid will ask you to install it).
2) Select G++ compiler in C4droid preferences.
3*) Use iostream, not iostream.h
4*) Add "using namespace std;" to your program (before int main)

C4droid contains a Terminal Emulator with BusyBox, so you can use Makefiles without any changes, shell commands syntax is the same as on Linux PC.
To compile Makefile projects, open any file in the same folder with Makefile and long-click "Compile" to configure current directory (C4droid will create .c4droid configuration file when you will press Ok). After configuring folder, you can press compile button and C4droid will build your project.
Do not forget to enter executable name and select compilation mode (and press ok also, else changes will be discarded)
You can also build and install open-source libraries the same way. Currently tested libraries are gmp(internal memory only),mpfr,mpc,libxml2,neon,sqlite,SDL_gfx(--disable-mmx required).

C4droid supports SDL, NativeActivity and Qt for GUI now, install SDL plugin for C4droid to use it (only GCC/G++ compiler is supported, so you need GCC plugin also).
(SDL is detected with #include "SDL.h", NativeActivity is detected with #include "android_native_app_glue.h", Qt is detected with #include "QtGui").
Qt support limitations:
1) If you are compiling a single-file Qt app, you must add #include "yoursourcefilenamewithcpp.moc" to the end of file. If you are using .pro file for compilation, you do not need to do that.

Quick manual:
If you have found a bug or app is not working, email me.

Long click actions:
Save button: save as.
Open button: recent files.
Run button: run with arguments.
Compile button: configure current directory.
Tab: close tab.

Result of compilation (binary or APK) can be exported using menu->export.
If you have "Illegal instruction" error using internal c compiler (TCC), install GCC plugin, GCC supports softfloat by default.

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - MBC3
« Reply #2 on: July 14, 2013, 05:04:57 PM »
You can find the current development version of MBC3 (AIR's gcc BCX) running on Android Linux in the members only code repository.

Code: [Select]
MBC Version 3.0-Beta1v2.3 (2012/06/26)
MBC3: Based on Linux BCX by Mike Henning (c) 2009
(c) 2009-2011 Armando Rivera with additional code (c) 2009 John Jacques

[Lines In: 5] [Lines Out: 116] [Statements: 1] [Time: 0.02 sec's]
BCX translated mbchello.bas to mbchello.c
Shelling Out To: g++  -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings mbchello.c -ldl  -O2 -fno-short-enums -o mbchello
Shelling Out To: strip -s -R .comment -R .note -R .note.ABI-tag mbchello
shell@android:/data/local/c4bin $ ls -l mbchello
-rwxrwxrwx shell    shell        8564 2013-07-13 18:28 mbchello
shell@android:/data/local/c4bin $ ./mbchello
Hello World
shell@android:/data/local/c4bin $

Note #include <iostream.h> references have been removed to prevent static linking of it's dependencies.
« Last Edit: July 16, 2013, 12:00:28 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - BaCon
« Reply #3 on: July 14, 2013, 05:10:23 PM »


You can find the current development version of BaCon 2.2.0 beta release running on Android Linux in the members only code repository.

Code: [Select]
shell@android:/data/local/c4bin $ ./bacon220 -c gcc -o -O2 -o -fno-short-enums bacon220.bac                                                                
Converting 'bacon220.bac'... done.
Compiling 'bacon220.bac'... done.
Program 'bacon220' ready.
shell@android:/data/local/c4bin $ ls -l bacon220*
-rwxrwxrwx shell    shell      448661 2013-07-13 23:37 bacon220
-rw-rw-rw- shell    shell      274788 2013-07-08 19:07 bacon220.bac
shell@android:/data/local/c4bin $ strip -s -R .comment -R .note -R .note.ABI-tag bacon220
shell@android:/data/local/c4bin $ ls -l bacon220                                                                                                          
-rwxrwxrwx shell    shell      403796 2013-07-13 23:38 bacon220
shell@android:/data/local/c4bin $

bindump.bac
Code: [Select]
shell@android:/data/local/c4bin $ ./bacon220 -c gcc -o -fno-short-enums bindump.bac                                                                        
Converting 'bindump.bac'... done.
Compiling 'bindump.bac'... done.
Program 'bindump' ready.
shell@android:/data/local/c4bin $ ls -l bindump*
-rwxrwxrwx shell    shell       93564 2013-07-12 23:17 bindump
-rw-rw-rw- shell    shell        3464 2013-07-07 20:54 bindump.bac



Note The RECURSIVE file delete option has been removed from this version of BaCon due to no support for the ftw library under Android Linux.
« Last Edit: July 16, 2013, 12:02:54 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - ScriptBasic
« Reply #4 on: July 14, 2013, 05:24:12 PM »
I thought I would share where I left off (a year ago) with ScriptBasic on Android. This is an example of interfacing with the Android Java VM API via the SL4A interface. What made this interesting to me is that I could script the device locally on the device or remotely via a WIFI connection. SL4A is a socket/JSON interface to the UI and other services Android offers to it's users. I added an ANSI screen attribute library to ScriptBasic. It runs fine on both Ubuntu and Android Linux.

You can find the current development version of ScripBasic 2.2 running on Android Linux in the members only code repository.





Code: [Select]
' SL4A and console screen mnemonics demo

IMPORT DVM
INCLUDE "ansi.inc"

CLS

PRINT GRAPHICS_ON
PRINT "l",STRING(38,"q"),"k"
FOR i = 2 TO 15
  PRINT AT(1,i),"x",AT(40,i),"x"
NEXT i
PRINTNL
PRINT "m",STRING(38,"q"),"j"
PRINT AT(1,3),"t",STRING(38,"q"),"u"
PRINT AT(30,3),"w"
FOR i = 4 TO 15
  PRINT AT(30,i),"x"
NEXT i
PRINT AT(30,i),"v"
PRINT GRAPHICS_OFF

PRINT AT(2,2),BOLD,COLOR(7,4,STRING(10," ") & "SAMSUNG Tab 2 10.1" & STRING(10," "))
PRINT AT(2,4),BOLD,COLOR(7,6," Phone Type" & STRING(17," "))
PRINT AT(2,5),BOLD,COLOR(7,6," Screen Brightness" & STRING(10," "))
PRINT AT(2,6),BOLD,COLOR(7,6," Airplane Mode" & STRING(14," "))
PRINT AT(2,7),BOLD,COLOR(7,6," Ringer Slient Mode" & STRING(9," "))
PRINT AT(2,8),BOLD,COLOR(7,6," Screen On" & STRING(18," "))
PRINT AT(2,9),BOLD,COLOR(7,6," Max Media Volume" & STRING(11," "))
PRINT AT(2,10),BOLD,COLOR(7,6," Max Ringer Volume" & STRING(10," "))
PRINT AT(2,11),BOLD,COLOR(7,6," Media Volume" & STRING(15," "))
PRINT AT(2,12),BOLD,COLOR(7,6," Ringer Volume" & STRING(14," "))
PRINT AT(2,13),BOLD,COLOR(7,6," Vibrate Mode" & STRING(15," "))
PRINT AT(2,14),BOLD,COLOR(7,6," Vibrate Mode Ringer" & STRING(8," "))
PRINT AT(2,15),BOLD,COLOR(7,6," Vibrate Mode Notify" & STRING(8," "))

PRINT AT(33,4),DVM::getPhoneType()
PRINT AT(33,5),DVM::getScreenBrightness()
IF DVM::checkAirplaneMode() = "false" THEN
  PRINT AT(33,6),COLOR(1,0,"false")
ELSE
  PRINT AT(33,6),COLOR(2,0,"true")
END IF
IF DVM::checkRingerSilentMode() = "false" THEN
  PRINT AT(33,7),COLOR(1,0,"false")
ELSE
  PRINT AT(33,7),COLOR(2,0,"true")
END IF
IF DVM::checkScreenOn() = "false" THEN
  PRINT AT(33,8),COLOR(1,0,"false")
ELSE
  PRINT AT(33,8),COLOR(2,0,"true")
END IF
PRINT AT(33,9),DVM::getMaxMediaVolume()
PRINT AT(33,10),DVM::getMaxRingerVolume()
PRINT AT(33,11),DVM::getMediaVolume()
PRINT AT(33,12),DVM::getRingerVolume()
IF DVM::getVibrateMode() = "false" THEN
  PRINT AT(33,13),COLOR(1,0,"false")
ELSE
  PRINT AT(33,13),COLOR(2,0,"true")
END IF
IF DVM::getVibrateMode(TRUE) = "false" THEN
  PRINT AT(33,14),COLOR(1,0,"false")
ELSE
  PRINT AT(33,14),COLOR(2,0,"true")
END IF
IF DVM::getVibrateMode(FALSE) = "false" THEN
  PRINT AT(33,15),COLOR(1,0,"false")
ELSE
  PRINT AT(33,15),COLOR(2,0,"true")
END IF

PRINT AT(1,18)
LINE INPUT z

  • CLS - Clear screen and home the cursor. (x1:y1)
  • COLOR(fg,bg,text) - Set the foreground, background and text to be displayed in color.
  • AT(x,y) - Position the cursor to the (x:y) position on the screen.
  • NORMAL - Return attributes to the default state.
  • BOLD - Bold the text follow the attribute.
  • UNDERLINE_ON - Start underline text mode.
  • UNDERLINE_OFF - End  underline text mode.
  • REVERSE_ON - Start reverse video mode.
  • REVERSE_OFF - End reverse video mode.
  • INS - Insert a blank character at the current cursor position moving the text to the right.
  • DEL - Delete a character at the current cursor position and shift text to the left.
  • INS_LINE - Insert a blank line on the row the cursor is at and shift lines of text down.
  • DEL_LINE - Delete a line on the row the cursor is at and shift lines of text up.
  • GRAPHICS_ON - Switch to the graphics/line draw character set.
  • GRAPHICS_OFF - Return back to the standard charater set.
Note: All of the above screen attributes are in the form of a string. (except CLS)

ansi.inc
Code: [Select]
' Console Display Enhancement Library

SUB CLS
  PRINT "\033[2J\033[1;1H"
END SUB

FUNCTION COLOR(fg,bg,text)
  COLOR = "\033[" & (fg + 30) & ";" & (bg + 40) & "m" & text & "\033[0m"
END FUNCTION

FUNCTION AT(x,y)
  AT = "\033[" & y & ";" & x & "H"
END FUNCTION

GLOBAL CONST NORMAL = "\033[22m"
GLOBAL CONST BOLD = "\033[1m"
GLOBAL CONST UNDERLINE_ON = "\033[4m"
GLOBAL CONST UNDERLINE_OFF = "\033[24m"
GLOBAL CONST REVERSE_ON = "\033[7m"
GLOBAL CONST REVERSE_OFF = "\033[27m"
GLOBAL CONST INS = "\033[1@"
GLOBAL CONST DEL = "\033[1P"
GLOBAL CONST INS_LINE = "\033[1L"
GLOBAL CONST DEL_LINE = "\033[1M"
GLOBAL CONST GRAPHICS_ON = "\033(0"
GLOBAL CONST GRAPHICS_OFF = "\033(B"
« Last Edit: July 16, 2013, 12:04:24 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - SB SQLite
« Reply #5 on: July 15, 2013, 11:41:39 PM »
ScriptBasic has an extension module for SQLite3 that doesn't require any dependencies from Android Linux. I wanted to have the SQLite3 command line utility and discovered there wasn't a binary version available. (just ARM source) I compiled the SQL library and it seems to work fine on Android Linux. (see below) I will add it to the members only code repository board along with the current version of the SB DVM extension module for SL4A resources. The follow example is using a copy of the Android contacts database from my tablet.

Code: [Select]
import sqlite.bas

db = sqlite::open("contacts2.db")

stmt = sqlite::query(db,"select * from raw_contacts")

while (sqlite::row(stmt) = sqlite::SQLITE3_ROW)
  if sqlite::fetchhash(stmt,column) then
    for x = 0 to ubound(column) step 2
      PRINT column[x]," - ",column[x+1],"\n"
    next x
  end if
wend

sqlite::close(db)

shell@android:/sdcard/scriptbasic $ scriba t6_sqlite.sb
_id - 1
account_name - 1
account_type - 1
data_set - 1
sourceid - 1
raw_contact_is_read_only - 0
version - 2
dirty - 1
deleted - 0
contact_id - 1
aggregation_mode - 0
aggregation_needed - 0
custom_ringtone - 0
send_to_voicemail - 0
times_contacted - 0
last_time_contacted - 0
starred - 0
display_name - John Spikowski
display_name_alt - Spikowski, John
display_name_source - 40
phonetic_name - 40
phonetic_name_style - 3
sort_key - John Spikowski
sort_key_alt - Spikowski, John
name_verified - 0
sync1 - 0
sync2 - 0
sync3 - 0
sync4 - 0
shell@android:/sdcard/scriptbasic $

raw_contacts schema
Code: [Select]
sqlite> .tables
_sync_state               phone_lookup              view_data_usage_stat    
_sync_state_metadata      photo_files               view_entities          
accounts                  properties                view_groups            
activities                raw_contacts              view_raw_contacts      
agg_exceptions            search_index              view_raw_entities      
android_metadata          search_index_content      view_stream_items      
calls                     search_index_docsize      view_v1_contact_methods
contacts                  search_index_segdir       view_v1_extensions      
data                      search_index_segments     view_v1_group_membership
data_usage_stat           search_index_stat         view_v1_groups          
default_directory         settings                  view_v1_organizations  
directories               status_updates            view_v1_people          
groups                    stream_item_photos        view_v1_phones          
mimetypes                 stream_items              view_v1_photos          
name_lookup               v1_settings               visible_contacts        
nickname_lookup           view_contacts             voicemail_status        
packages                  view_data              
sqlite> .schema raw_contacts
CREATE TABLE raw_contacts (_id INTEGER PRIMARY KEY AUTOINCREMENT,account_name STRING DEFAULT NULL, account_type STRING DEFAULT NULL, data_set STRING DEFAULT NULL, sourceid TEXT,raw_contact_is_read_only INTEGER NOT NULL DEFAULT 0,version INTEGER NOT NULL DEFAULT 1,dirty INTEGER NOT NULL DEFAULT 0,deleted INTEGER NOT NULL DEFAULT 0,contact_id INTEGER REFERENCES contacts(_id),aggregation_mode INTEGER NOT NULL DEFAULT 0,aggregation_needed INTEGER NOT NULL DEFAULT 1,custom_ringtone TEXT,send_to_voicemail INTEGER NOT NULL DEFAULT 0,times_contacted INTEGER NOT NULL DEFAULT 0,last_time_contacted INTEGER,starred INTEGER NOT NULL DEFAULT 0,display_name TEXT,display_name_alt TEXT,display_name_source INTEGER NOT NULL DEFAULT 0,phonetic_name TEXT,phonetic_name_style TEXT,sort_key TEXT COLLATE PHONEBOOK,sort_key_alt TEXT COLLATE PHONEBOOK,name_verified INTEGER NOT NULL DEFAULT 0,sync1 TEXT, sync2 TEXT, sync3 TEXT, sync4 TEXT );
CREATE INDEX raw_contact_sort_key1_index ON raw_contacts (sort_key);
CREATE INDEX raw_contact_sort_key2_index ON raw_contacts (sort_key_alt);
CREATE INDEX raw_contacts_contact_id_index ON raw_contacts (contact_id);
CREATE INDEX raw_contacts_source_id_data_set_index ON raw_contacts (sourceid, account_type, account_name, data_set);
CREATE INDEX raw_contacts_source_id_index ON raw_contacts (sourceid, account_type, account_name);
CREATE TRIGGER raw_contacts_deleted    BEFORE DELETE ON raw_contacts BEGIN    DELETE FROM data     WHERE raw_contact_id=OLD._id;   DELETE FROM agg_exceptions     WHERE raw_contact_id1=OLD._id        OR raw_contact_id2=OLD._id;   DELETE FROM visible_contacts     WHERE _id=OLD.contact_id       AND (SELECT COUNT(*) FROM raw_contacts            WHERE contact_id=OLD.contact_id           )=1;   DELETE FROM default_directory     WHERE _id=OLD.contact_id       AND (SELECT COUNT(*) FROM raw_contacts            WHERE contact_id=OLD.contact_id           )=1;   DELETE FROM contacts     WHERE _id=OLD.contact_id       AND (SELECT COUNT(*) FROM raw_contacts            WHERE contact_id=OLD.contact_id           )=1; END;
CREATE TRIGGER raw_contacts_marked_deleted    AFTER UPDATE ON raw_contacts BEGIN    UPDATE raw_contacts     SET version=OLD.version+1      WHERE _id=OLD._id       AND NEW.deleted!= OLD.deleted; END;
sqlite>
« Last Edit: July 16, 2013, 12:44:35 AM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - SB cURL
« Reply #6 on: July 16, 2013, 10:33:13 AM »
I'm working on porting the ScriptBasic cURL extension module for Android but until then I have the command line version working.

Code: [Select]
shell@android:/data/local/bin $ ./curl --help
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
     --anyauth       Pick "any" authentication method (H)
 -a, --append        Append to target file when uploading (F/SFTP)
     --basic         Use HTTP Basic Authentication (H)
     --cacert FILE   CA certificate to verify peer against (SSL)
     --capath DIR    CA directory to verify peer against (SSL)
 -E, --cert CERT[:PASSWD] Client certificate file and password (SSL)
     --cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)
     --ciphers LIST  SSL ciphers to use (SSL)
     --compressed    Request compressed response (using deflate or gzip)
 -K, --config FILE   Specify which config file to read
     --connect-timeout SECONDS  Maximum time allowed for connection
 -C, --continue-at OFFSET  Resumed transfer offset
 -b, --cookie STRING/FILE  String or file to read cookies from (H)
 -c, --cookie-jar FILE  Write cookies to this file after operation (H)
     --create-dirs   Create necessary local directory hierarchy
     --crlf          Convert LF to CRLF in upload
     --crlfile FILE  Get a CRL list in PEM format from the given file
 -d, --data DATA     HTTP POST data (H)
     --data-ascii DATA  HTTP POST ASCII data (H)
     --data-binary DATA  HTTP POST binary data (H)
     --data-urlencode DATA  HTTP POST data url encoded (H)
     --delegation STRING GSS-API delegation permission
     --digest        Use HTTP Digest Authentication (H)
     --disable-eprt  Inhibit using EPRT or LPRT (F)
     --disable-epsv  Inhibit using EPSV (F)
 -D, --dump-header FILE  Write the headers to this file
     --egd-file FILE  EGD socket path for random data (SSL)
     --engine ENGINGE  Crypto engine (SSL). "--engine list" for list
 -f, --fail          Fail silently (no output at all) on HTTP errors (H)
 -F, --form CONTENT  Specify HTTP multipart POST data (H)
     --form-string STRING  Specify HTTP multipart POST data (H)
     --ftp-account DATA  Account data string (F)
     --ftp-alternative-to-user COMMAND  String to replace "USER [name]" (F)
     --ftp-create-dirs  Create the remote dirs if not present (F)
     --ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)
     --ftp-pasv      Use PASV/EPSV instead of PORT (F)
 -P, --ftp-port ADR  Use PORT with given address instead of PASV (F)
     --ftp-skip-pasv-ip Skip the IP address for PASV (F)
     --ftp-pret      Send PRET before PASV (for drftpd) (F)
     --ftp-ssl-ccc   Send CCC after authenticating (F)
     --ftp-ssl-ccc-mode ACTIVE/PASSIVE  Set CCC mode (F)
     --ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)
 -G, --get           Send the -d data with a HTTP GET (H)
 -g, --globoff       Disable URL sequences and ranges using {} and []
 -H, --header LINE   Custom header to pass to server (H)
 -I, --head          Show document info only
 -h, --help          This help text
     --hostpubmd5 MD5  Hex encoded MD5 string of the host public key. (SSH)
 -0, --http1.0       Use HTTP 1.0 (H)
     --ignore-content-length  Ignore the HTTP Content-Length header
 -i, --include       Include protocol headers in the output (H/F)
 -k, --insecure      Allow connections to SSL sites without certs (H)
     --interface INTERFACE  Specify network interface/address to use
 -4, --ipv4          Resolve name to IPv4 address
 -6, --ipv6          Resolve name to IPv6 address
 -j, --junk-session-cookies Ignore session cookies read from file (H)
     --keepalive-time SECONDS  Interval between keepalive probes
     --key KEY       Private key file name (SSL/SSH)
     --key-type TYPE Private key file type (DER/PEM/ENG) (SSL)
     --krb LEVEL     Enable Kerberos with specified security level (F)
     --limit-rate RATE  Limit transfer speed to this rate
 -l, --list-only     List only names of an FTP directory (F)
     --local-port RANGE  Force use of these local port numbers
 -L, --location      Follow redirects (H)
     --location-trusted like --location and send auth to other hosts (H)
 -M, --manual        Display the full manual
     --mail-from FROM  Mail from this address
     --mail-rcpt TO  Mail to this receiver(s)
     --mail-auth AUTH  Originator address of the original email
     --max-filesize BYTES  Maximum file size to download (H/F)
     --max-redirs NUM  Maximum number of redirects allowed (H)
 -m, --max-time SECONDS  Maximum time allowed for the transfer
     --negotiate     Use HTTP Negotiate Authentication (H)
 -n, --netrc         Must read .netrc for user name and password
     --netrc-optional Use either .netrc or URL; overrides -n
     --netrc-file FILE  Set up the netrc filename to use
 -N, --no-buffer     Disable buffering of the output stream
     --no-keepalive  Disable keepalive use on the connection
     --no-sessionid  Disable SSL session-ID reusing (SSL)
     --noproxy       List of hosts which do not use proxy
     --ntlm          Use HTTP NTLM authentication (H)
 -o, --output FILE   Write output to <file> instead of stdout
     --pass PASS     Pass phrase for the private key (SSL/SSH)
     --post301       Do not switch to GET after following a 301 redirect (H)
     --post302       Do not switch to GET after following a 302 redirect (H)
     --post303       Do not switch to GET after following a 303 redirect (H)
 -#, --progress-bar  Display transfer progress as a progress bar
     --proto PROTOCOLS  Enable/disable specified protocols
     --proto-redir PROTOCOLS  Enable/disable specified protocols on redirect
 -x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port
     --proxy-anyauth Pick "any" proxy authentication method (H)
     --proxy-basic   Use Basic authentication on the proxy (H)
     --proxy-digest  Use Digest authentication on the proxy (H)
     --proxy-negotiate Use Negotiate authentication on the proxy (H)
     --proxy-ntlm    Use NTLM authentication on the proxy (H)
 -U, --proxy-user USER[:PASSWORD]  Proxy user and password
     --proxy1.0 HOST[:PORT]  Use HTTP/1.0 proxy on given port
 -p, --proxytunnel   Operate through a HTTP proxy tunnel (using CONNECT)
     --pubkey KEY    Public key file name (SSH)
 -Q, --quote CMD     Send command(s) to server before transfer (F/SFTP)
     --random-file FILE  File for reading random data from (SSL)
 -r, --range RANGE   Retrieve only the bytes within a range
     --raw           Do HTTP "raw", without any transfer decoding (H)
 -e, --referer       Referer URL (H)
 -J, --remote-header-name Use the header-provided filename (H)
 -O, --remote-name   Write output to a file named as the remote file
     --remote-name-all Use the remote file name for all URLs
 -R, --remote-time   Set the remote file's time on the local output
 -X, --request COMMAND  Specify request command to use
     --resolve HOST:PORT:ADDRESS  Force resolve of HOST:PORT to ADDRESS
     --retry NUM   Retry request NUM times if transient problems occur
     --retry-delay SECONDS When retrying, wait this many seconds between each
     --retry-max-time SECONDS  Retry only within this period
 -S, --show-error    Show error. With -s, make curl show errors when they occur
 -s, --silent        Silent mode. Don't output anything
     --socks4 HOST[:PORT]  SOCKS4 proxy on given host + port
     --socks4a HOST[:PORT]  SOCKS4a proxy on given host + port
     --socks5 HOST[:PORT]  SOCKS5 proxy on given host + port
     --socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy
 -Y, --speed-limit RATE  Stop transfers below speed-limit for 'speed-time' secs
 -y, --speed-time SECONDS  Time for trig speed-limit abort. Defaults to 30
     --ssl           Try SSL/TLS (FTP, IMAP, POP3, SMTP)
     --ssl-reqd      Require SSL/TLS (FTP, IMAP, POP3, SMTP)
 -2, --sslv2         Use SSLv2 (SSL)
 -3, --sslv3         Use SSLv3 (SSL)
     --ssl-allow-beast Allow security flaw to improve interop (SSL)
     --stderr FILE   Where to redirect stderr. - means stdout
     --tcp-nodelay   Use the TCP_NODELAY option
 -t, --telnet-option OPT=VAL  Set telnet option
     --tftp-blksize VALUE  Set TFTP BLKSIZE option (must be >512)
 -z, --time-cond TIME  Transfer based on a time condition
 -1, --tlsv1         Use TLSv1 (SSL)
     --trace FILE    Write a debug trace to the given file
     --trace-ascii FILE  Like --trace but without the hex output
     --trace-time    Add time stamps to trace/verbose output
     --tr-encoding   Request compressed transfer encoding (H)
 -T, --upload-file FILE  Transfer FILE to destination
     --url URL       URL to work with
 -B, --use-ascii     Use ASCII/text transfer
 -u, --user USER[:PASSWORD]  Server user and password
     --tlsuser USER  TLS username
     --tlspassword STRING TLS password
     --tlsauthtype STRING  TLS authentication type (default SRP)
 -A, --user-agent STRING  User-Agent to send to server (H)
 -v, --verbose       Make the operation more talkative
 -V, --version       Show version number and quit
 -w, --write-out FORMAT  What to output after completion
     --xattr        Store metadata in extended file attributes
 -q                 If used as the first parameter disables .curlrc
shell@android:/data/local/bin $

My goal with ScriptBasic on Android Linux is to provide a set of tools and utilities one would expect to find on other flavors of Linux.

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - BeeBdroid
« Reply #7 on: July 16, 2013, 09:11:11 PM »





« Last Edit: July 21, 2013, 12:06:23 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android
« Reply #8 on: July 16, 2013, 09:38:54 PM »
I took a quick peek at the source for BeeBdroid and it's based on b-em (Tom Walker) with a JNI connection to the Java VM API. B-em under Linux supports full screen and all the video modes, sound, keyboard reasignments and other BBC BASIC features. Beebdroid and the C4droid SDL example should be a good foundation for all the BASIC languages looking for an Android UI connection.

BTW Joshy (D.J.Peters) has made progress with getting FreeBASIC ported to ARM. Maybe he will stumble on this thread and find value in an Android port of FB.

« Last Edit: July 17, 2013, 12:36:54 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android
« Reply #9 on: July 22, 2013, 11:27:37 AM »
I just watched the 20 minute QB64 video on how to build Android applications.

I wish I could see the look on BASIC programmers faces while watching this video. (WTF!)

This confirms I'm on the right path with native C/C++ development on Android Linux.
« Last Edit: July 22, 2013, 08:31:45 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - My-Basic
« Reply #10 on: July 23, 2013, 09:37:23 PM »
I was able to compile MY-BASIC (Tiny BASIC class interpreter) on Android. This is the first interactive BASIC that isn't running in a emulator like the BBC version. I attached the my_basic binary and the help pdf.



« Last Edit: July 23, 2013, 09:49:30 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android - Benchmarks
« Reply #11 on: July 23, 2013, 11:19:12 PM »
Now that I have a few BASIC languages running native on Android Linux, a little benchmarking seems in order.

MY-BASIC

Code: [Select]
 a$ = ""
  b$ = ""
  FOR x = 65 TO 90
   a$ = a$ + CHR(x)
  NEXT x
  FOR x = 1 TO 1000
   FOR y = 25 TO 0 STEP -1
     b$ = b$ + MID(a$, y, 1)
   NEXT y
   b$ = b$ + a$
  NEXT x
  PRINT LEN(b$);

shell@android:/data/local/my-basic $ time ./my_basic strbench.bas              
52000
    0m11.97s real     0m11.92s user     0m0.00s system
shell@android:/data/local/my-basic $


BaCon

Code: [Select]
 a$ = ""
  b$ = ""
  FOR x = 65 TO 90
   a$ = a$ & CHR$(x)
  NEXT x
  FOR x = 1 TO 1000
   FOR y = 26 TO 1 STEP -1
     b$ = b$ & MID$(a$, y, 1)
   NEXT y
   b$ = b$ & a$
  NEXT x
  PRINT LEN(b$),"\n"

shell@android:/data/local/BaCon $ ./bacon -c gcc -o -fno-short-enums strbench.bac                                                                          
Converting 'strbench.bac'... done.
Compiling 'strbench.bac'... done.
Program 'strbench' ready.
shell@android:/data/local/BaCon $ time ./strbench
52000

    0m3.83s real     0m3.80s user     0m0.00s system
shell@android:/data/local/BaCon $


ScriptBasic

Code: [Select]
FOR x = 65 TO 90
  a = a & CHR(x)
NEXT x
FOR x = 1 TO 1000
  FOR y = 26 TO 1 STEP -1
    b = b & MID(a, y, 1)
  NEXT y
  b = b & a
NEXT x
PRINT LEN(b),"\n"

shell@android:/sdcard/scriptbasic $ time scriba strbench.sb
52000

   0m4.03s real 0m4.00s user 0m0.02s system
shell@android:/sdcard/scriptbasic $
« Last Edit: August 08, 2013, 12:59:36 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3570
    • ScriptBasic Open Source Project
Re: BASIC for Android
« Reply #12 on: August 08, 2013, 11:29:42 AM »
I'm still refining my toolbox on Android Linux (non-rooted) and revisited an app I purchase sometime ago for Java native development. A member on another forum mentioned that AIDE can also be used to develop C/C++ native application in a non-rooted environment. I installed AIDE on one of my stock Samsung Galaxy Tab 2 10.1 tablets and created  this OpenGL C example using the NDK feature set to allow Android VM access  to it's resources.I think you will find the SF_Demo.apk (attached) worth viewing if native development on Android is of interest.

« Last Edit: August 08, 2013, 12:10:32 PM by JRS »