It is currently Fri Mar 24, 2017 10:43 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next
Author Message
 Post subject: Re: Hot summer of code
Unread postPosted: Tue Feb 28, 2017 12:26 am 
Offline
User avatar

Joined: Sat Oct 04, 2014 5:45 am
Posts: 611
Hi Gregor,

I enabled RFO2APK for OlibasicXIV and it compiles the APK fine.
Also tested your testcode for Hisense 5.1 and tested OK with max = 50000
I increased it by 1000 and stopped testing at 50000 . Maybe it can go more.

Code:
max = 50000
List.Create s, contens
DIM contens$[max]
FOR i = 1 TO max
   List.add contens, "Line " +STR$(i)
NEXT i

SELECT retItem, contens, "TestList", "PopUp", lP
list.get contens,retItem, selectedItem$
PRINT retItem, selectedItem$, "PressType: "; lP


Emile

_________________
Download and tutorial for RFODESIGNER
https://sites.google.com/site/rfodesigner/


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Tue Feb 28, 2017 1:27 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1288
Hi Gregor

Excellent work

The onKeyDown: now work fine in graphic mode. I used OnKeyPress: to flush the keyboard. I wonder if a new

command 'FlushKeyBoard' could be added that would be quicker then looping until the key board is empty.

Like the new Globals.all, Locals.off, Locals.on commands. After experimenting I found that you can read and

change variables from outside functions even when the function and not been called with an interrupt.
Any variables created in the function can't be see outside the function.

The new Gr.rect <obj_nvar>, left, top, right, bottom{{, rx}, ry} very nice

Good job with then manual

Regards Roy

Code:
Rem OilBasicXIV Test

di_height = 1150
di_width = 672

gr.open 255, 117, 117, 255
gr.color 255, 255, 255, 255, 0
gr.orientation 1
pause 500
WakeLock 3

keydown.on

gr.screen screenWidth, screenHeight
scale_x = screenWidth / di_width
scale_y = screenHeight / di_height
gr.scale scale_x, scale_y

gr.set.stroke 2
gr.rect rec1, 100, 100, 400, 600, 50, 50
gr.color 255, 255, 100, 50, 1
x = di_width / 2 : y = di_height / 2
gr.circle ball, x, y, 30

gr.render

do : pause 1 : until 0

onKeyDown:
    gosub MoveBall
keyDown.resume

OnKeyPress:
    gosub FlushKeys
Key.resume

MoveBall:
    INKEY$ mKey$, mKeyEvent$
    if mKey$ = "left" then x -= 10
    if mKey$ = "right" then x += 10

    if mKey$ = "up" then y -= 10
    if mKey$ = "down" then y += 10
   
    gr.modify ball, "x", x, "y", y
    gr.render
return

FlushKeys:
    do
        INKEY$ mKey$, mKeyEvent$
    until mKey$ ="@"
return

Attachment:
test1.PNG
test1.PNG [ 4.67 KiB | Viewed 393 times ]

Code:
Rem Global Function
Globals.all

x = 500

fn.def Xis()
Locals.off
?"Print x in function ";x
!Change value of x
x = 750
!Set y to 1000
y = 1000
?"Print y made in function ";y
fn.end


call Xis()
?
?"Print x outside of function with it's new value ";x
?"Print y outside of function (can't be seen) ";y
end


Attachment:
test2.PNG
test2.PNG [ 43.88 KiB | Viewed 393 times ]


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Fri Mar 03, 2017 1:42 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 279
Hi All,

here an example how to
* Look for PackageName
* Install a SimpleHttpServer app
* Start the server
* Reorder you program to front again
* Look for paths
* Open a html file

Code:
REM Start of BASIC! StartHttpServer.bas

FN.DEF StartServer(SCAN_MODE$,globals)
ServerAppId$ = "jp.ubi.common.http.server"
APP.INSTALLED check, ServerAppId$
IF check = 0
  APP.LOAD "market://details?id="+ ServerAppId$
  DIALOG.MESSAGE "Installing succeeded?", "SimpleHttpServer \ Under SEETING switch \nLaunch on Activity \nto on! \nPlease confirm", buttonResult, "Yes", "No"
  IF buttonResult = 2
   BUNDLE.PUT globals,"FirstRun",0
  ENDIF
ENDIF

LIST.CREATE S, commandListPointer
LIST.ADD commandListPointer~
"new Intent();" ~
"getLaunchIntentForPackage(" + CHR$(34) + ServerAppId$ + CHR$(34) +");" ~
"addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);" ~
"EOCL"
BUNDLE.PL appVarPointer,"_CommandList",commandListPointer
APP.SAR appVarPointer
FN.RTN appVarPointer

FN.END
FN.DEF ReorderToFront()
PROGRAM.INFO b
BUNDLE.GET b, "PackageName", pN$
LIST.CREATE S, commandListPointer
LIST.ADD commandListPointer~
"new Intent(Intent.ACTION_MAIN);" ~
"setPackage("+ CHR$(34) + pN$ + CHR$(34) +");" ~
"EOCL"
BUNDLE.PL appVarPointer,"_CommandList",commandListPointer
APP.SAR appVarPointer
FN.RTN appVarPointer
FN.END

DEBUG.OFF

BUNDLE.CREATE globals
StartServer("", globals)
SOCKET.MYIP ipAddress$ %Network Address
BUNDLE.PUT globals,"IpAddress:Port", ("http://" + ipAddress$ + ":" + "12345")

PAUSE 2000
ReorderToFront()
FILE.ROOT dP$ %Default Data Path / TARGET
FILE.ROOT eP$, "_External" %External Path / Virtual PUBLIC ROOT
path$ = REPLACE$(dP$, eP$, "")
myFile$ = "htmldemo1.html"
BUNDLE.GET globals,"IpAddress:Port", serverPath$
fullPath$ = serverPath$ + path$ + "/" + myFile$
PRINT fullPath$

DIALOG.MESSAGE "", "Go on", buttonResult, "Go"
HTML.OPEN
HTML.LOAD.URL fullPath$
DIALOG.MESSAGE "", "Go on", buttonResult, "Go"

END


Happy coding
Gregor


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Sun Mar 05, 2017 3:47 am 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1105
Location: UK
 
aFox wrote:
Hi Mog, hi roy,

I've done some testing and can't get ONKEYDOWN: to work in graphic mode, although ONKEYPRESS: dose.


Yes it is true.
I should be able to solve the problem, but it is an old open construction site.
I have to dive deeper.

Gregor


That should be now fixed in XIV.


See https://github.com/RFO-BASIC/Basic/file ... sicXIV.zip



Yep Gregor, It works! I can use my headset as a "paddle" now.

When you hold the buttons down on the headset there is a slight delay. This of course is normal auto-repeat functionality; but what do you think about having a delay you can set from 0ms up to, say 500ms?

That way the headset could be more useable as a "paddle" in game play.

Mog


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Sun Mar 05, 2017 6:40 am 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 279
Mog wrote:
 
aFox wrote:
Hi Mog, hi roy,

I've done some testing and can't get ONKEYDOWN: to work in graphic mode, although ONKEYPRESS: dose.


Yes it is true.
I should be able to solve the problem, but it is an old open construction site.
I have to dive deeper.

Gregor


That should be now fixed in XIV.


See https://github.com/RFO-BASIC/Basic/file ... sicXIV.zip



Yep Gregor, It works! I can use my headset as a "paddle" now.

When you hold the buttons down on the headset there is a slight delay. This of course is normal auto-repeat functionality; but what do you think about having a delay you can set from 0ms up to, say 500ms?

That way the headset could be more useable as a "paddle" in game play.

Mog


Hi Mog,

please try this
Code:
KEYDOWN.ON
VOLKEYS.ON
x = 20
y = 60
GR.OPEN 255, 0, 0, 0, 1, 1

GR.COLOR 255, 255, 255, 255, 1

GR.CIRCLE ball, x, y, 10
stillDown = 0
TIMER.SET  500 %Device independent key trigger speed
DO
GR.MODIFY ball, "x", x, "y", y
GR.RENDER
UNTIL 0

ONTIMER:
IF stillDown = 1
INKEY$ mKey$
IF mkey$ ="key 24" THEN x = x + 10
IF mkey$ ="key 25" THEN x = x - 10
ENDIF
TIMER.RESUME


ONKEYDOWN:
IF stillDown = 0
INKEY$ mKey$
IF mkey$ ="key 24" THEN x = x + 10
IF mkey$ ="key 25" THEN x = x - 10
stillDown = 1
ELSE
INKEY$ mKey$
ENDIF

ONKEYPRESS:

INKEY$ mKey$, mKeyEvent$
IF IS_IN("ACTION_UP", mKeyEvent$)
stillDown = 0
GOSUB FlushKeys
ENDIF
KEY.RESUME

FlushKeys:
DO
INKEY$ mKey$, mKeyEvent$
UNTIL mKey$ ="@"
RETURN
END


Gregor


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Tue Mar 07, 2017 1:07 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1288
Hi aFox

Somthing seems to have happened with 'file.exists'

I have done a test app to show
Code:
Rem Test Save and Load
   
    sound = 1 : buzz = 0
    score = 300
    path$ = "TimerStopWatch/data/"
   
    gosub SaveData
   
    sound = 0 : buzz = 1
    score = 900
   
    gosub LoadData
   
    ?"Score = ";score
    ?"Buzz = ";buzz
    ?"Sound = ";sound
   
end

!------------------------------------------------
! Save Sound, Buzz and Score
!------------------------------------------------
SaveData:
    file.exists pathPresent,path$ + "StopWatchData.txt"
    if ! pathPresent then file.mkdir path$

    text.open w,hs,Path$ + "StopWatchData.txt"
    text.writeln hs,int$(score)
    text.writeln hs,int$(sound)
    text.writeln hs,int$(buzz)
    text.close hs
return

!------------------------------------------------
! Load Sound, Buzz and Score
!------------------------------------------------
LoadData:
    file.exists pathPresent,path$ + "StopWatchData.txt"
    if pathPresent then
        text.open r,hs,path$ + "StopWatchData.txt"
        text.readln hs,score$
        text.readln hs,sound$
        text.readln hs,buzz$
        text.close hs
       
        score = val(score$)
        sound = val(sound$)
        buzz = val(buzz$)
    endif
return


Attachment:
SaveLoadError.PNG
SaveLoadError.PNG [ 62.04 KiB | Viewed 178 times ]

Regards Roy


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Tue Mar 07, 2017 12:23 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 279
roy wrote:
Hi aFox

Somthing seems to have happened with 'file.exists'

I have done a test app to show


APPENDIX TO THE MANUAL
(De Re BASIC! Version 1.90, 2016-03-31)
ENHANCEMENTS and CORRECTIONS
...
2. Look at FILE.EXISTS the second parameter is now a value not a String expression!
...
File.exists <lvar>, <path_svar> Reports if the <path_svar> directory or file exists. If the directory or file does not exist, the <lvar> will contain zero. If the file or directory does exist, the <lvar> will be returned as non-zero. The default path is "<pref base drive>/rfo-basic/data/". It is also possible to use an URI with "file://" as start. Sometimes you get a file path like “/external/images/media/556”. With "file://" + “/external/images/media/556”, File.exists is able to handle it. In this case <path_svar> returns a new absolute file path.
Before this improvement you could write:
File.exists ok, dataPath$ + file$
now you have to write: fn$ = dataPath$ + file$
File.exists ok, fn$


It is a self healing function so it has to be a variable, because in some cases it returns a different file path.

That is the reason I deliver a fitted GW.bas, too.

Some external file browsers calling with APP.SAR return file paths like “/external/images/media/556”.
These are virtual temporary file paths created by Android automatically.

Gregor


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Wed Mar 08, 2017 12:59 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1288
Hi aFox

Thanks for the help, I was looking in the wrong manual :oops:

I've amended my code. Do you think I'm on the right PATH now :)

Regards Roy

Code:
Rem Test Save and Load
   
    sound = 1 : buzz = 0
    score = 300
   
    dataPath$ = "Test/data/"
    file$ = "StopWatchData.txt"
    fn$ = dataPath$ + "/" + file$
   
    gosub SaveData
   
    sound = 0 : buzz = 1
    score = 900
   
    gosub LoadData
   
    ?"Score = ";score
    ?"Buzz = ";buzz
    ?"Sound = ";sound
   
end

!------------------------------------------------
! Save Sound, Buzz and Score
!------------------------------------------------
SaveData:
    file.exists ok, fn$
    if ! ok then file.mkdir dataPath$
    text.open w,hs,fn$
    text.writeln hs,int$(score)
    text.writeln hs,int$(sound)
    text.writeln hs,int$(buzz)
    text.close hs
return

!------------------------------------------------
! Load Sound, Buzz and Score
!------------------------------------------------
LoadData:
    file.exists ok, fn$
    if ok then
        text.open r,hs,fn$
        text.readln hs,score$
        text.readln hs,sound$
        text.readln hs,buzz$
        text.close hs
       
        score = val(score$)
        sound = val(sound$)
        buzz = val(buzz$)
    endif
return


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Wed Mar 08, 2017 8:09 am 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 279
;)


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Wed Mar 08, 2017 9:55 am 
Offline

Joined: Mon Nov 14, 2016 6:49 am
Posts: 39
Dear specialists. I have constructive suggestion. Why Rfo-Basic can not contain console based commands which are capable to create all available Android object types for GUI controls creation such as buttons, combo boxes, radio buttons, check boxes and others. Which problem prevent you from making that, so for now, only HTML5 and Webwiev can enable developers to use those kind of GUI controls. I Am wondering why is it so complex to incorporate this. So GUI of console based apps would also use other object types than list items or OK and Cancel buttons. For now button radio button and check boxes would be incorporated as beginning. What do you think about it?


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9  Next


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred