Page 1 of 1

File/Folder Structure

Posted: Thu Feb 15, 2018 5:16 pm
by marlin55
I'm new to Smart Basic on iOs and I'm struggling to understand how to access files and folders on the iPad. I grew up with Windows which still uses the DOS filepath method to store and retrieve files. I can't get my head around the equivalent on the iPad. Specifically, I want to display a jpeg image in a Smart Basic program I'm writing. The image was emailed to me and I can "extract" it from the email on the iPad, but 1) I need to reaname it because the email system gave it a stupid 32 digit filename, 2) I want to save it to a folder (preferably a new one for images to be used in SB), and 3) later import that image into an SD program and display it.

I tried Googling an answer but all I get is either "You don't need to worry about folders 'cos Apple takes care of all that", or "Here's how to create folders for your apps." (which is not what I'm trying to do).

I can press on the image in the email and the iPad offers me options, one of which is 'Save to Folder', but the only folders it offers are Keynote, Numbers and Pages with now option to make a new folder or rename the file. Even if I choose to use one of those existing folders, I don't understand how I would then find the jpeg from within my SB program. I can see there's a 'Draw Image N$ AT ...' command, but presumably N$ either contains a directory path and filename, or I have to set the directory first. But a) I don't know how to do set the directory path (all the manual says is "... it can be changed with command DIR SET", on p38 with no other reference as to how this command works, and b) how do I work out the path to where the jpg is stored?

I'd be grateful for any guidance.

Re: File/Folder Structure

Posted: Thu Feb 15, 2018 5:40 pm
by rbytes
Do you have Dropbox installed? That is the recommended method to move a file into Smart Basic. Once you download and install the Dropbox App, you run this one-line program in Smart Basic.

Code: Select all

OPTION DROPBOX ON
You can name the program whatever you want. You will only need it once. :D

When you run it, you will be asked to allow the link to Dropbox.
Once you do, you will see an extra button (a cloud) in Smart Basic at the right of the bottom toolbar. It will toggle you between your files in Smart Basic and files you save to the Smart Basic folder in Dropbox.

So now to get your image into Smart Basic, assuming it is in the Camera Roll:

1. Open Photos app
2. Select your photo
3. Press the up-arrow button
4. Tap the Copy to Dropbox icon from the popup graphic menu
5. Select the Smart Basic folder as the Dropbox destination
6. You can rename your image before you confirm the copy. I always change the extender from .jpeg to .jpg (you have to confirm that too)

7. Now launch Smart Basic
8. Toggle the Dropbox icon so you see "Dropbox" at top of screen
9. Find your image (at the bottom of the list of files)
10. Press the Copy icon
11. Toggle from Dropbox back to Smart Basic (you'll see "Smart Basic" at top of screen)
12. Press the Paste icon.
(You may first want to navigate into a folder before pasting)

Seems like a lot of steps, but after using Smart Basic for a while you will hardly have to think about them. ;)

Re: File/Folder Structure

Posted: Thu Feb 15, 2018 6:54 pm
by marlin55
Thanks rbytes (again). I use Dropbox through my browser, but didn't realise I also had to download an app. This I have done. The step I didn't understand was when I selected the file to upload from the Camera Roll, in addition to choosing the Dropbox folder I was also asked for an email address to which to post. Naturally I chose my own, but I couldn't complete the upload step without supplying an email address which seems odd.

Managed steps 1 to 7 without difficulty, but I came unstuck at about step 12, (but maybe it was an earlier through misunderstanding the term "toggling"). I went into the DB app selected my image, selected 'copy', then went back to the SB app but couldn't see a Paste icon.

If you didn't mean me to go into the Dropbox app, I assume there must be a way to link with DB from within the SB app, but I can't see where that is. Sorry to be a nuisance, but could you kindly clarify.

Re: File/Folder Structure

Posted: Thu Feb 15, 2018 7:01 pm
by marlin55
... restarted DB and Cloud icon appears bottom right. Touch this and top strip changes to say "DropBox", but no file names appear. I have lots on DB, including the new folder Smart Basic which contains my image, but it's not visible in the SB DropBox window.

Re: File/Folder Structure

Posted: Thu Feb 15, 2018 7:36 pm
by rbytes
That is very odd that you are asked to provide an email when you Save to Dropbox from Photos. That shouldn't be happening.

Do you see a Smart Basic folder when you look at Dropbox from inside Smart Basic? If so, go into it. Try copying a file from Smart Basic to this Dropbox folder and see if it appears there.

Re: File/Folder Structure

Posted: Thu Feb 15, 2018 7:43 pm
by rbytes
Thinking further. I missed one fact. The Smart Basic folder is created in the folder Apps on Dropbox at the time you create the link in Smart Basic. Try moving your image there. Then you should be able to see it and copy it into Smart Basic.

From within Smart Basic you can not see anything outside of the Apps/Smart Basic folder so I was wrong to ask if you could see the folder. You can't, nor can you see any of your other files and folders on Dropbox.

So you are very close now to your objective. 8-)

Re: File/Folder Structure

Posted: Fri Feb 16, 2018 11:08 am
by marlin55
Thanks rbytes. I had mistakenly created my own SB Folder in DB. I now see, thanks to your further advice, that there is already an SB folder within the Apps folder within DB. I can now see my file from within SB - hooray! So the final stage is how to access that file from SB code. I tried DRAW IMAGE "image.jpg" AT 0,0 but got the error message "File does not exist: "image.jpg", even though it is now listed on the DB screen within SB. Do I need to do something extra tell the code to look in the DB part of SB?

*** now solved *** moved image to same folder as program

Re: File/Folder Structure

Posted: Fri Feb 16, 2018 3:47 pm
by rbytes
No, SB code can not read or run files directly from DB. What you need to do is copy a file in DB, switch to SB and paste it in a location that you can refer to when you want to load it. You also have the option of moving it to SB, which deletes the DB version of the file.

Notice that I say it, not they. Each file copy (or cut) and paste must be done individually - you can only operate on one file at a time.

There are also times when you may want to move a file in the other direction, from SB to DB. The process works the same - just exchange the letters DB and SB in the instructions above.