It is currently Tue Apr 25, 2017 7:28 am



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  [ 25 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Im new ! New help for many questions !!
Unread postPosted: Sun Jan 08, 2017 7:42 am 
Offline

Joined: Fri Jan 06, 2017 12:44 am
Posts: 11
Sry for my english ^^ !

1) How can i save and load a .txt file (for save a game party).

2) i dont understand how can i use the touchscreen ? what is synthax for touch the screen and have coordonnate X, Y ?

for example when you touch the screen :
if X > 100 and x < 200 then goto Nextway ===> how can i have this possibility ?
print "ok"
Nextway:
print "ooo"

3) close the app normaly (when i creat apk, and i want close the apk i have the print line "END"). I just want have the synthax for close my apk normaly as normal apk ^^. is it possible ?


Thx all !


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Sun Jan 08, 2017 8:16 am 
Offline

Joined: Mon Feb 08, 2016 9:07 am
Posts: 106
Hi!
1) For reading and writing text files see manual pages 106 to 108.
GRABFILE text$, "MyJournal.txt" is an easy way to read a complete text file.
An easy way to save a textfle is just print your text lines to console with subsequent CONSOLE.SAVE "File.txt".
See page 95

2) Use Gr.touch touched, x, y to get the coordinates where the screen was touched. See page 161
You need to gr.open ... before you can use Gr.touch

3) Use EXIT instead of END to completely exit the APK.

Regards
nobs


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Sun Jan 08, 2017 9:36 am 
Offline

Joined: Fri Jan 06, 2017 12:44 am
Posts: 11
THX !!


1) im try to understand ^^

2) Its work !!
but what is the correct synthax for many conditions ? for example
if x<200 then goto... ==> WORK ! (but only 1 condition)
if x>200 and x<500 then goto ... <== error and crash
if x>200 : x<500 then goto ... <== understand if x<500 ... ^^

3) EXIT work perfectly :D !


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Sun Jan 08, 2017 10:38 am 
Offline
User avatar

Joined: Thu Jan 08, 2015 11:28 am
Posts: 1088
Location: .NET
there are no keyword-operators in BASIC!
you have & for the and operator, | for or operator
http://www.rfo-basic.com/manual/#_Toc447196521

_________________
https://github.com/evolbug
http://toobasic.jimdo.com


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Mon Jan 09, 2017 6:49 am 
Offline

Joined: Fri Jan 06, 2017 12:44 am
Posts: 11
X , Y work for me to :) !
Thx for help guys ;) !

A other and important question ^^ :

When i use a variable like a=12 , the console said me 12.0 and not 12 ...
Is it possible to remove .0 After 12 ? :D

Thx again


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Mon Jan 09, 2017 7:28 am 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1128
Location: From Blighty
Code:
a = 12
PRINT INT$(a)


Mog


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Mon Jan 09, 2017 8:00 am 
Offline

Joined: Fri Jan 06, 2017 12:44 am
Posts: 11
Work fine !!

I tried int(a) and i had a crash ^^. Thx again ! :)


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Mon Jan 09, 2017 4:20 pm 
Offline

Joined: Fri Jan 06, 2017 12:44 am
Posts: 11
Its me again !! ^^

I realy dont understand how save info on Text file work. I tried it:

SAVE:
line$ = "9382929"

TEXT.OPEN r, 1, "SAVE.txt"
do
TEXT.READLN 1, line$
Print line$
TEXT.CLOSE 1
goto menu

But I have a error and no save.txt file creat... :(
Can someone explain to how loader This file After (for load a game for exemple).

Thx a lot guys :-*


Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Tue Jan 10, 2017 1:38 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1317
Hi Atomose

Run the demo and then look in 'RFO Basic/data' and you will see a folder called 'MyGame" in that folder there will be a folder caller 'data' in that folder will be the text file called 'GameData.txt'

Regards Roy

Code:
Rem Save and Load Demo

FALSE = 0 : TRUE = 1
sound = TRUE : buzz = FALSE : music = TRUE
highScore = 1250
path$ = "MyGame/data/"

gosub SaveData

gosub LoadData

?"highScore = ";highScore
?"music = ";music
?"sound = ";sound
?"buzz = ";buzz

end

!------------------------------------------------
! Save the High Score, Music, sound, and Buzz
!------------------------------------------------
SaveData:
    file.exists pathPresent,path$ + "GameData.txt"
    if ! pathPresent then file.mkdir path$

    text.open w,hs,Path$ + "GameData.txt"
    text.writeln hs,int$(highScore)
    text.writeln hs,int$(music)
    text.writeln hs,int$(sound)
    text.writeln hs,int$(buzz)
    text.close hs
return

!------------------------------------------------
! Load the High Score, Music, sound, and Buzz
!------------------------------------------------
LoadData:
    file.exists pathPresent,path$  +"GameData.txt"
    if pathPresent then
        text.open r,hs,path$ + "GameData.txt"
        text.readln hs,highScore$
        text.readln hs,music$
        text.readln hs,sound$
        text.readln hs,buzz$
        text.close hs
        highScore = val(highScore$)
        music = val(music$)
        sound = val(sound$)
        buzz = val(buzz$)
    endif
return



Report this post
Top
 Profile  
 
 Post subject: Re: Im new ! New help for many questions !!
Unread postPosted: Tue Jan 10, 2017 10:15 am 
Offline

Joined: Mon Feb 08, 2016 9:07 am
Posts: 106
To write strings or numbers to a text file, you need the commands TEXT.OPEN W ... (W means write) and TEXT.WRITELN ...

Example:

Code:
a$="This is the text"
filename$="output.txt"
text.open w, fn1, filename$
text.writeln fn1 ,a$
text.close fn1


That's all.
nobs


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 3 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