Commit 4ce9cffe by kollo

modified sqldemo so it works again under Android

parent 0f72fa5d
' gfalist.bas fuer Android, linux und WINDOWS
'
' Converts all GFA-BASIC .gfa files (found in the /sdcard/bas/ folder)
' into X11-Basic .bas files.
' (c) Markus Hoffmann 2016
'
' Anleitung f"ur Android:
' das binary gfalist ist in der X11-Basic app enthalten und
' ist im Ordner bas/ abgelegt fuer drei Prozessor-Architekturen.
' Evtl. muessen Sie das anpassen
'
' Comment: converted .gfa file usually need do be manually edited
' before they can be successfully run by X11-Basic.
'
PRINT "initializing..."
FLUSH
prefix$=""
basedir$="."
IF ANDROID?
sqls$="/usr/bin/gfalist"
IF NOT EXIST(sqls$)
' Try to install it
sqls$="/data/data/net.sourceforge.x11basic/gfalist"
IF NOT EXIST(sqls$)
PRINT "gfalist is not yet installed."
@android_install
ENDIF
ENDIF
tmp$="/sdcard/gfa.err"
prefix$="HOME=/sdcard/ "+CHR$(10)
basedir$="/sdcard/bas"
ELSE IF WIN32?
sqls$="gfalist"
tmp$="gfa.err"
ELSE
sqls$="gfalist"
tmp$="/tmp/gfa.err"
ENDIF
t$=SYSTEM$(prefix$+sqls$+""+" 2>&1")
IF LEN(t$)=0
PRINT "something is wrong. gfalist is not responding."
END
ENDIF
' PRINT "GFALIST Version: "+t$
' Search .gfa and .GFA files
print "search .gfa and .GFA files...."
ON ERROR CONT ! Skip any error like permission denied or so....
a$=FSFIRST$(basedir$,"*")
WHILE len(a$)
SPLIT a$," ",0,typ$,name$
IF typ$="d" ! Is it a directory?
ELSE
IF GLOB(name$,"*.gfa") or GLOB(name$,"*.GFA") ! Check if the filename matches the pattern...
@doone(basedir$+"/"+name$)
ENDIF
ENDIF
ON ERROR CONT ! Skip any error like permission denied or so....
a$=FSNEXT$()
WEND
print "done."
IF ANDROID?
END
else
QUIT
ENDIF
procedure doone(infile$)
LOCAL outfile$
outfile$=infile$+".bas"
print "converting "+infile$
if not exist(outfile$)
t$=SYSTEM$(prefix$+sqls$+" -o "+outfile$+" "+infile$+" 2>&1")
print t$
else
print "ERROR: "+outfile$+" already exist. Will not overwrite."
endif
return
PROCEDURE android_install
LOCAL t$
PRINT "installing Androids gfalist in "+sqls$
IF EXIST("/sdcard/bas/gfalist.armeabi")
PRINT "copying..."
FLUSH
OPEN "I",#1,"/sdcard/bas/gfalist.armeabi"
t$=INPUT$(#1,LOF(#1))
CLOSE #1
BSAVE sqls$,VARPTR(t$),LEN(t$)
' PRINT system$("cp /mnt/sdcard/bas/sqlite3 "+sqls$+" 2>&1")
PRINT "change mode..."
FLUSH
PRINT SYSTEM$("/system/bin/chmod 755 "+sqls$+" 2>&1")
FLUSH
ELSE
PRINT "cannot find gfalist. please download it "
PRINT "and put it in /sdcard/bas/"
END
ENDIF
RETURN
......@@ -4,17 +4,10 @@
' Markus Hoffmann + Joachim Wiedemann-Heinzelmann Jan 2013
'
' Anleitung f"ur Android:
' das binary sqlite3 muss von hier abgeholt werden:
' http://www.zois.co.uk/dl/sqlite3
' (Size: 1448982 bytes, MD5 checksum: c14086bcc1b32503e0ebfe711dda73ee)
' das binary sqlite3 ist in der X11-Basic app enthalten und
' ist im Ordner bas/ abgelegt für drei Prozessor-Architekturen:
'
' The above site is down. You should now build a static binary youself.
'
' The sources and Makefile for this are here:
' https://github.com/stockrt/sqlite3-android
'
' Dann dieses File in den /sdcard/bas Ordner legen, da wo
' sqldemo.bas auch liegt.
' Die Dateien test.db und error.txt finden sich anschliessend in /sdcard/
' Wenn die Datenbank test.db in einem anderen Verzeichnis liegen soll, muss
' prefix$ angepasst werden.
......@@ -128,10 +121,10 @@ ENDFUNCTION
PROCEDURE android_install
LOCAL t$
PRINT "installing Androids sqlite3 in "+sqls$
IF EXIST("/sdcard/bas/sqlite3")
IF EXIST("/sdcard/bas/sqlite3.armeabi")
PRINT "copying..."
FLUSH
OPEN "I",#1,"/sdcard/bas/sqlite3"
OPEN "I",#1,"/sdcard/bas/sqlite3.armeabi"
t$=INPUT$(#1,LOF(#1))
CLOSE #1
BSAVE sqls$,VARPTR(t$),LEN(t$)
......@@ -141,8 +134,7 @@ PROCEDURE android_install
PRINT SYSTEM$("/system/bin/chmod 755 "+sqls$+" 2>&1")
FLUSH
ELSE
PRINT "cannot find sqlite3. please download it from"
PRINT "http://www.zois.co.uk/dl/sqlite3"
PRINT "cannot find sqlite3. please download it "
PRINT "and put it in /sdcard/bas/"
END
ENDIF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment