06-23-2018 13:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-23-2018 13:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have a text file with a list in the format of:
name 0 0
I am trying to read it into a searchable format. So far, I can't even get the file to be found. I tried
let info = readFileSync("MyData.txt", "ascii");
let info = readFileSync("../common/MyData.txt", "ascii");
The studio tells me it cannot find the file. Any thoughts on where it might be? Also, I am hoping to read/search the info. If this won't work...let me know now.
Thanks.
Thanks.

06-23-2018 13:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-23-2018 13:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It probably depends how you created the file. If it was transferred from the companion, you could try looking in /private/data/
Gondwana Software

06-23-2018 16:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-23-2018 16:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I created a file under my common folder (where my utils.js is) and copied the text info into it. I will try the private/data tomorrow.
Thank you for the suggestion.

06-24-2018 12:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-24-2018 12:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
FlyFrosty, I don't think it works like that. I don't think that text files that you create in Fitbit Studio get uploaded to your device. Did you find this mechanism in the docs? If not, you can't rely on it.
Maybe you should write the file from your app when it is first run or something.

06-24-2018 17:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-24-2018 17:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am hoping to read the text file with my app. I have found a text list with 400+ lines of data in it (it is the city/time zone list). I would love to allow the user to search through them and choose their desired time zone based on that city. If I have to type them in, they may get 10 or 15 to choose from.

06-25-2018 08:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-25-2018 08:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I read a binary file in my resources folder like this:-
var stats = fs.statSync("/mnt/assets/resources/level_data.bin");
allLevels = new Uint8Array(stats.size);
let file = fs.openSync("/mnt/assets/resources/level_data.bin", "r");
fs.readSync(file, allLevels, 0, stats.size, 0);
fs.closeSync(file);
You should be able to read your text file in the same way.

06-25-2018 10:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-25-2018 10:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The paths when reading file are relative from where the .js file is stored.
So when reading a file the path would be like "./resources/files/somefile.txt"
The above example:
"./" - Go up one folder from the JS file.
"/resources" - Folder to put resources in ( create with the project)
"/files" - Sub folder to keep our stuff organized.
"/somefile.txt" - Name of file.
Something else to be aware of when reading files that are packaged with the app, they are read only on the device.

