Author Topic: Read file error  (Read 3283 times)

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile
Read file error
« on: 2014-May-29 »
I use this simple code:

Code: (glbasic) [Select]
SETCURRENTDIR("Media") // go to media files

AUTOPAUSE TRUE
SEEDRND GETTIMERALL()

//SETSCREEN 9999,9998,FALSE
SETSCREEN 440,700,FALSE

int_sd$ = PLATFORMINFO$("APPDATA")
ext_sd$ = PLATFORMINFO$("DOCUMENTS")


WHILE TRUE

PRINT "Int_sd: " + int_sd$, 0, 10
PRINT "Ext_sd: " + ext_sd$, 0, 20

PRINT "Path: " + GETCURRENTDIR$(), 0, 30

  PRINT "**************2", 0, 50

OPENFILE(1,"1.txt", TRUE)
READLINE 1, nome$
PRINT "1 : " + nome$,0 ,70
CLOSEFILE 1


SHOWSCREEN
WEND

In Windows work fine but in Android Crash...
I use DOESFILEEXIST() but it tells me that the file does not exist.

I test a various option:
OPENFILE(1,"Media/1.txt", TRUE)
or
OPENFILE(1,"Media\1.txt", TRUE)

but the file not found!
« Last Edit: 2014-Jun-01 by Moru »

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile
Re: Read file error
« Reply #1 on: 2014-May-29 »
mmmm it's error of Android Extras .....

I do not know why but it does not work the command: SETCURRENTDIR("Media")


Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4159
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Read file error
« Reply #2 on: 2014-May-31 »
mmmm it's error of Android Extras .....

I do not know why but it does not work the command: SETCURRENTDIR("Media")



I don't think this is an AE issue - Android's file system seems to be problematic with GLBasic. From my own personal experience with OUYA and GameStick (both Android deveices) AE has helped in lots of areas where GLBasic falls far short. Try compiling your GLB program for Android without AE and see if you get the same result.

In AE you need to use Android.Check_Asset("") prior to loading media using the standard LOADANIM etc. commands

Remember Android is very specific with regards to case sensitivity too, which include the format (eg .png/.PNG etc.)
I came. I saw. I played.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
Re: Read file error
« Reply #3 on: 2014-Jun-01 »
SETCURRENTDIR("Media") is done automatic with AE. This is required so Android.Check_Assest() could work, so they looking in the same path. This is due SETCURRENTDIR() did not set dir in the Java part, only in c++ Part.

But you need add Android.Check_Assest(file$) before any loading commands. Its to skips the ... screen.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile
Re: Read file error
« Reply #4 on: 2014-Jun-01 »
Thanks for reply!

But ADmob works????
How to set a Banner Positon, Dimension etc????

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
Re: Read file error
« Reply #5 on: 2014-Jun-01 »
only fullscreen ads works, not onscreen banners. Again, see Android Sample.

PS. Can this thread moved to the glbasic en forum, this is not a faq me thinks.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

MrTAToad

  • Guest
Re: Read file error
« Reply #6 on: 2014-Jun-01 »
You should be checking the result from OPENFILE too - as it could be failing there...

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
Re: Read file error
« Reply #7 on: 2014-Jun-01 »
you still need a Android.Check_Asset("") if you using internal txt file. There is also Android.Android_DirCopy (here im forget to remove Android_ from the function name, if you want to copy the whole dir from the apk to the memory.

Etc glbasic can only read from the internal/sd memory, not from APK file, which is in AE not copied automatic. That hence you need those commands.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile
Re: Read file error
« Reply #8 on: 2014-Jun-02 »
Thanks for help and sorry for having written in the wrong section!  :booze:

I'm waiting for the version which you can block then autolight off .

Thank for your BIG work spacefractal  :nw:

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3958
    • View Profile
    • Space Fractal
Re: Read file error
« Reply #9 on: 2014-Jun-02 »
until im release a new AE, which im do in this incoming weekend, you can add this line in the public class SDLActivity extends Activity { class in SDLActivity.java, just before // >>>>>>>> END ANDROID EXTRAS <<<<<<<< line (around line 414):

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

this keep the screen on.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline Kyo

  • Dr. Type
  • ****
  • Posts: 350
    • View Profile
Re: Read file error
« Reply #10 on: 2014-Jun-02 »
Thanks spacefractal you are Boss  :nw: