Comments (15)
All references to sdcard with Basic.filePath which is assigned a value in onCreate() in Basic.java.
filePath = Environment.getExternalStorageDirectory().getPath() + "/" + AppPath;
from basic.
Paul, if that is ok with you I would like to reopen this issue. Because the following has been solved:
Android suggests to not hardcode "/sdcard/" but use Environment.getExternalStorageDirectory().getPath() instead
But not this second aspect:
Currently IDE can load programs only from /sdcard it would be an enhancement for the user to choose another place, typically an external sdcard (when /sdcard is used for internal memory)
I have been meeting the issue with a Samsung Galaxy S III, and now with a Sony Xperia Go. BASIC! should propose to load programs from external SD-Card and not only internal memory. Here is a Java code snippet to list all the SD-Cards: http://renzhi.ca/2012/02/03/how-to-list-all-sd-cards-on-android/
I will try to look at how to implement a new preference in BASIC! IDE this week-end
from basic.
Do you only want to be able to change the program LOAD path? Or do you want to change the base path for all storage access commands?
Do you want BASIC! to initialize all of its directories to a different card. If so, how to your propose telling BASIC! to do this?
Maybe can provide some commands that would illustrate what it is you wish to accomplish.
from basic.
Yes you are right, I would in fact like to change the base path for all storage access commands. Basically change the Environment.getExternalStorageDirectory().getPath() value to any sd-card chosen by the user.
This would be done by a "base path" or "base drive" or "root drive" preference in the IDE (via menu touch) containing the list of /mnt resources made available by this renzhi.ca snippet
from basic.
The base path is set the first time BASIC! (or a derived APK) is loaded after a new release. Is it your idea that every time BASIC! (or a derived APK) is first loaded, the user is asked where to store thing?
from basic.
We could do that, but it wouldn't be so good: ask something at first BASIC! start would go over most users' heads. I was thinking more to start by assuming that baseDrive=Environment.getExternalStorageDirectory().getPath() (same as currently) but offer a preference in the IDE menu for user to change that: present the list of sd-cards and if user selects one different from Environment.getExternalStorageDirectory().getPath() then create the base folders and copy the initial resource, or and it could be acceptable I think, save the preference and simply exit the IDE (after a small warning popup, maybe) then initialize folders and resource at next start (automatic or launched by user, TBC what is doable).
from basic.
Please explain your term IDE in this context.
I think you are saying that Menu->Preferences should contain an entry for selecting available storage devices. The user selects one.
How do you propose BASIC! communicate to itself that it is to initialize/use this new base directory the next time it starts?
Edited: I think I can see how to do that communication using saved preferences. I still need to figure out how to save present/save a value that was not predefined at compile time. I am pretty sure it can be done.
from basic.
Yes sorry, IDE = Integrated Environment Development = what I call RFO-BASIC! application (as opposed to a BASIC! program compiled to an APK).
You got it right, this would be a new entry in Menu->Preferences.
I have been digging in the Editor.java code but am a little lost of how to implement this (the initialize part I mean), particularly how the preferences are stored
from basic.
Look at Settings.java.
from basic.
On a related note is it normal that in LoadFile.java there is still a hard-coded "/sdcard" ? line 147 sdDir = new File("/sdcard/"); shouldn't we make use of Environment.getExternalStorageDirectory().getPath() ?
from basic.
Apparently I did not get every /sdcard/ in the full IDE. I will so a search and replace of the whole things.
from basic.
This issue needs to be re-opened. I think that the changing of the base drive can be done using preferences.
from basic.
I got an error: In Editor, selected "Load" from menu. "Load File" app header with blank screen, error Toast "System Error. File not directory." issued by LoadFile.Load1().
Debug:
My "git pull" got this. I uninstalled BASIC!, built with this change, and installed from Eclipse (debug run).
Basic.onCreate() calls Settings.getBaseDrive() which returns "0". "0" is the default value if the Settings Activity was never run. Basic.onCreate() compares "0" to "none". "none" is the default value if Settings.setBaseDrive finds no external drive. Compare fails, so Basic.basePath is set to "0" and Basic.filePath is set to "0/rfo-basic".
The rest is obvious: Editor.loadFile() starts LoadFile Activity. LoadFile.Load1() uses Basic.basePath, but there is no path "/0".
I didn't commit a fix because I don't know your intention regarding the initialization of a new preference. My workaround was to patch Settings.getBaseDrive to use "none" as the default string. This may not be appropriate if you're trying to distinguish "never initialized" from "there really isn't an external sd".
Is there a reason to use sdDir.getAbsoluteFile() + "/" + Basic.AppPath
instead of Basic.filePath
(which is Basic.basePath + "/" + Basic.AppPath
)?
from basic.
The first problem is easily fixed by changing line 162 of Setting.java:
from: .getString("base_drive_pref", "0");
to: .getString("base_drive_pref", "none");
When Basic.java is started it will see "none" and use "Environment.getExternalStorageDirectory().getPath();" for the base path.
I will commit this one line change.
No, there is no reason why Load1 is the way it is other than historical. The code you mentioned will work just as well.
from basic.
Released in v01.72
from basic.
Related Issues (20)
- instanceof Fails HOT 2
- Assets with a folder structure are not readable directly
- SENSORS.LIST names not all 20 standard sensor types.
- VOLKEYS.ON / VOLKEYS.OFF
- STT.RESULTS list variable is not reset at program start
- GR.CAMERA. _ _ _SHOOT The file name extension from "image.png" is wrong in a case of jpeg compression
- BYTE.WRITE.BUFFER is very slow
- The Editor stops until REPLACE ALL in Search is used with empty search string
- ROUND Input of NaN (Not a Number) Value returns 0.0 or crashes if the scale is specified. HOT 1
- USING$ Input of a NaN (Not a Number) Value for arguments needing Integer or Long values returns 0 HOT 1
- Some functions return 0.0 or 0 instead of NaN or Infinity HOT 1
- IF with a single NaN value returns **true**, but that is **wrong** HOT 3
- Command Round, double import is to unprecise
- Timer.set <value> -- cannot use a var for <value> HOT 1
- GrabURL reads cache
- On Oreo getting sensor data fails if the returned data array length is lower than three
- [Suggestion] Make the project compatible to Android Studio
- NaN and Infinity issue with gr.arc and gr. modify HOT 1
- Out-of-bound GR.BITMAP.CROP crashes BASIC HOT 1
- User apks without permission crash at startup HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basic.