BBC BASIC
« *CD in Android »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 1:04pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: *CD in Android  (Read 266 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 646
xx *CD in Android
« Thread started on: Jan 14th, 2016, 2:55pm »

Android doesn't have the concept of 'current working directory' that Windows and Linux have. The *CD command 'works' (that is, you can change the directory and it will display what you changed it to) but it doesn't actually control where files are read from or written to!

Put another way, if you don't specify an absolute path for a file Android uses a default directory which is unrelated to the directory that *CD displays (and is not straightforward to discover).

The practical consequence is that you should always specify an absolute path if you want your programs to run properly under Android. It is in any case bad practice to assume that the 'current directory' is initially where your program was loaded from, because even under Windows and Linux it may not be.

So for example if you currently use OPENIN("filename") change it to OPENIN(@dir$+"filename"). This should ensure compatibility across all platforms.

Richard.
User IP Logged

jgharston
New Member
Image


member is offline

Avatar




PM


Posts: 12
xx Re: *CD in Android
« Reply #1 on: Oct 13th, 2017, 11:28pm »

on Jan 14th, 2016, 2:55pm, Richard Russell wrote:
So for example if you currently use OPENIN("filename") change it to OPENIN(@dir$+"filename"). This should ensure compatibility across all platforms.

Except if you're writing a file navigator, as was the first bit of "real code" I was experimenting with today. Eg:

OSCLI "CD "+destination$
*.*.*
INPUT "File: "A$
CHAIN A$

Non-Android (ok, I've only tried Windows, RISCOS and BBC) chain the file you can see, Android tries to find a file hidden behind the mystery door (I think in /mnt).

Doing CHAIN @dir+A$ results in always looking for a file in the directory the executing program was launched from, not the one you're looking at.

...more investigation needed.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 646
xx Re: *CD in Android
« Reply #2 on: Oct 14th, 2017, 08:32am »

on Oct 13th, 2017, 11:28pm, jgharston wrote:
Doing CHAIN @dir+A$ results in always looking for a file in the directory the executing program was launched from

Well, not "was launched from" but "is stored in" (which is what @dir$ means). You took my comment too literally: when suggesting @dir$+filename$ I was of course using that as an example of a fully-qualified (absolute) path. You could use @usr$ or @tmp$ or @lib$ - or a path specified relative to one of those - and it would work just as well. It's just that in Android you cannot pass a relative path (which by definition means 'relative to the Current Directory') since there is no 'Current Directory'.

There is no need for any "investigation", that's how Android works. It's good practice to use absolute paths on all platforms so it shouldn't be an onerous requirement.

Richard.
« Last Edit: Oct 14th, 2017, 12:36pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls