How Do I Import Files Without Dropbox?

Post Reply
User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

How Do I Import Files Without Dropbox?

Post by rbytes » Sun May 12, 2019 5:27 am

1. You need to choose the files that you want to import into Smart Basic. You can save them to iCloud, Dropbox or Box. Anything text-based, such as programs, can simply be copied or pasted. Any images can be imported using ALBUM IMPORT. So you only need to deal with other types of files that you might want to use in your programs. Examples: .wav, .mp3, .mid, .m4a, .m4p, .mov

2. You need access to a website to which you have a login. There are some free options, such as at https://www.freehosting.com. Then you will FTP the files to that location. I recommend FTP Manager, an inexpensive iOS app. It can move files saved on your local iOS drive, or on the three cloud locations mentioned above, directly to your website.

Once you have your files there, downloading to Smart Basic is easy. I have done the 2 steps above, and you are welcome to download files from my site to test how it works.

There are four files ready for you to try. I will post just one link now, and the others over the next few days.

1. A video at "http://ricardobytes.com/ftp1/Test/BenBram.mp4"

Download the file to Smart Basic:

Code: Select all

' this is a video of a harmony group in high def
a2$="Ben Bram.mp4"
dn$="http://ricardobytes.com/ftp1/Test/BenBram.mp4"   ' case sensitive!
HTTP dn$ GETDIM m     'use the full url here
FILE a2$ WRITEDIM m   'save the binary file
sz=FILE_SIZE (a2$)
If sz>0 then
   Print "Connected to file..."
   print "Downloaded file size:";
   PRINT "###,###,###":sz;"bytes"
   if sz=20508069 then
     print "Successfully downloaded ";a2$
   else
     print "Download incomplete"
   endif
else
   Print "file not found"
endif
end
Now play the video - Notice the Quit button at the screen bottom center.

Code: Select all

'Ben Bram video - Smile
'video of a harmony group in high def
'code adapted by rbytes, March 2017
'based on coding by Dav, July 2015
'
'WORKS ON IPAD/IPHONE/IPOD TOUCH
home$="BenBram.mp4"

'detect device
IF LOWSTR$(DEVICE_TYPE$())="ipad" THEN
  dev=1
ELSE
  dev=0
END IF

GRAPHICS
OPTION SCREENLOCK OFF
OPTION SPRITE POS CENTRAL
OPTION BASE 1
SET BUTTONS CUSTOM
laun$=LAUNCHER$ ()
g$="<p><br><br><br><br><br><br><center><img src="&"""Loadanims/IMG_5813.GIF"""&" </center></p>"

PAGE "main" SET

'init screen
GRAPHICS CLEAR
SET TOOLBAR OFF

SET BROWSERS SCALED 'allow zooming in/out

'get current screen width
curwidth= SCREEN_WIDTH()
curheight=SCREEN_HEIGHT()

'load the homepage and wait animation
URL$=home$
GOSUB loadpage

DRAW COLOR 0,0,0
FILL COLOR .9,.9,.9

GOSUB makebuttons

'main loop...
DO
  IF BUTTON_PRESSED("quit") THEN 
    IF laun$="desktop" THEN
      IF FILE_EXISTS("/launch") THEN
        RUN "/-Launch.sb"
      ELSE
        EXIT
      ENDIF
    ENDIF
    END
  ENDIF

  'if screen rotated...
  IF SCREEN_WIDTH() <> curwidth THEN
    curwidth = SCREEN_WIDTH()
    URL$=BROWSER_TEXT$("n", "window.location.href")
    GOSUB loadpage
  END IF

UNTIL 0

PAGE bm$ HIDE
PAGE "main" HIDE
TEXT
END


'==========================================
'.  G O S U B S
'==========================================

'-------
loadpage:
'-------

IF dev=1 THEN
BROWSER "n" AT 0,0 SIZE SCREEN_WIDTH(),SCREEN_HEIGHT()+4
BROWSER "n" TEXT g$
PAUSE 1
BROWSER "n" URL URL$ 
ELSE
BROWSER "n" AT 0,0 SIZE SCREEN_WIDTH(),SCREEN_HEIGHT()+3
BROWSER "n" TEXT g$
PAUSE 1
BROWSER "n" URL URL$ 
END IF
RETURN


'----------
makebuttons:
'----------

FILL ALPHA 0
DRAW ALPHA .5
DRAW COLOR .8,.8,.8
IF dev = 1 THEN
  SET BUTTONS FONT SIZE 20
  BUTTON "quit" TEXT "Quit" AT curwidth/2-30,curheight-30 SIZE 60,32
ELSE
  SET BUTTONS FONT SIZE 14
  BUTTON "quit" TEXT "Quit" AT curwidth/2-20,curheight-20
END IF
FILL ALPHA 1
DRAW ALPHA 1
RETURN
Attachments
997F2CDA-7840-4E61-81A0-E0340960020F.png
997F2CDA-7840-4E61-81A0-E0340960020F.png (3.05 MiB) Viewed 137 times
Last edited by rbytes on Thu May 16, 2019 5:08 pm, edited 7 times in total.
####### Living the colorful life #######

Henko
Posts: 878
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: How Do I Import Files Without Dropbox?

Post by Henko » Sun May 12, 2019 12:06 pm

The videofile was downloaded, but only 1499 bytes size ??
It didn't play, just got a white screen with the quit button at the bottom.
But important fact is that a download from a website into the sB sandbox succeeded

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How Do I Import Files Without Dropbox?

Post by rbytes » Sun May 12, 2019 1:25 pm

Hmm. Maybe timed out partway through. Please try a few more times and let me know if you can ge the whole file. The size should be 2.05081E+07
####### Living the colorful life #######

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How Do I Import Files Without Dropbox?

Post by rbytes » Sun May 12, 2019 5:52 pm

Oops. Found an error in my download code. I have reposted it. It should work for you now.

There is still an issue with testing for the correct file size, which is 2.05081E+07, just over 20 megabytes

What I thought would work was:

if sz=2.05081E+07 then ' test for equality
print "Successfully downloaded ";a2$
else
print "Download incomplete"
endif

But that always gives an incorrect answer!


So I changed it to:

if sz>2.05080E+07 then
print "Successfully downloaded ";a2$ 'test for greater than the next smaller size
else
print "Download incomplete"
endif

This change is not as accurate, but at least gives the correct response for a successful download.

Anyone know why this happens?
####### Living the colorful life #######

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

A second file to download

Post by rbytes » Sun May 12, 2019 9:17 pm

Continuing the demonstration of how you can import various types of files into Smart Basic without using its Dropbox connection ....

Here is the second file to try. A MIDI arrangement.

The download code:

Code: Select all

'MIDI file of an Alan Parsons song
a2$="Alan Parsons.mid"
dn$="http://ricardobytes.com/ftp1/Test/Alan_Parsons_-_Eye_in_the_Sky.mid"
HTTP dn$ GETDIM m   'use the full url here
FILE a2$ WRITEDIM m 'save the binary data
sz=FILE_SIZE (a2$)
If sz>0 then
   Print "Connected to file..."
   print "Downloaded file size: ";sz;" bytes"
   if sz=77872 then
     print "Successfully downloaded ";a2$
   else
     print "Download incomplete"
   endif
else
   Print "file not found"
endif
end
To play the song, run the next code. There is a delay of several seconds before the music starts. That was inserted by whoever created this file. The PAUSE command is necessary in order to hear all of the music. Otherwise the program ends before the music starts! You could instead use a loop that checks regularly whether the notes are still playing.

Code: Select all

N$="Alan Parsons.mid"
FILE N$ SETPOS 0
NOTES LOAD N$
NOTES PLAY
PAUSE NOTES_LENGTH ()
Last edited by rbytes on Wed May 15, 2019 1:07 pm, edited 3 times in total.
####### Living the colorful life #######

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

A third file to download

Post by rbytes » Tue May 14, 2019 11:01 pm

Continuing the demonstration of how you can import various types of files into Smart Basic without using its Dropbox connection ....

The third file I have available for you to download is an explosion sound effect. It is a .wav audio file - uncompressed.
Here is the download code:

Code: Select all

a2$="explosion.wav"
dn$="http://ricardobytes.com/ftp1/Test/explosion.wav"
HTTP dn$ GETDIM m   'use the full url here.
FILE a2$ WRITEDIM m 'save just the filename.
sz=FILE_SIZE (a2$)
If sz>0 then
   Print "Connected to file..."
   print "Downloaded file size: ";sz;" bytes"
   if sz=37284 then
     print "Successfully downloaded ";a2$
   else
     print "Download incomplete"
   endif
else
   Print "file not found"
endif
end

To play the sound effect, run this code:

Code: Select all

M$="music"
F$="explosion.wav"
MUSIC M$ LOAD F$
MUSIC M$ PLAY
PAUSE MUSIC_LENGTH (M$)
end
Last edited by rbytes on Wed May 15, 2019 1:37 pm, edited 1 time in total.
####### Living the colorful life #######

Henko
Posts: 878
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: A second file to download

Post by Henko » Wed May 15, 2019 10:57 am

rbytes wrote:
Sun May 12, 2019 9:17 pm

Code: Select all

N$="Alan Parsons.mid"
FILE N$ SETPOS 0
NOTES LOAD N$
NOTES PLAY
PAUSE NOTES_LENGTH (N$)
Hi, an error occurred: notes_length() must not have an argument.
Further, the test was succesfull

Henko
Posts: 878
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: A third file to download

Post by Henko » Wed May 15, 2019 11:03 am

rbytes wrote:
Tue May 14, 2019 11:01 pm
Continuing the demonstration of how you can import various types of files into Smart Basic without using its Dropbox connection ....

The third file I have available for you to download is an explosion sound effect. It is a .wav audio file - uncompressed.
Here is the download code:

Code: Select all

a2$="explosion.wav"
dn$="http://ricardobytes.com/ftp1/explosion.wav"
HTTP dn$ GETDIM m   'use the full url here.
FILE a2$ WRITEDIM m 'save just the filename.
sz=FILE_SIZE (a2$)
If sz>0 then
   Print "Connected to file..."
   print "Downloaded file size: ";sz;" bytes"
   if sz=37284 then
     print "Successfully downloaded ";a2$
   else
     print "Download incomplete"
   endif
else
   Print "file not found"
endif
end

To play the sound effect, run this code:

Code: Select all

M$="music"
F$="explosion.wav"
MUSIC M$ LOAD F$
MUSIC M$ PLAY
PAUSE MUSIC_LENGTH (M$)
end
I keep getting the message "download incomplete", with a "filesize" of 1699 bytes.

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How Do I Import Files Without Dropbox?

Post by rbytes » Wed May 15, 2019 1:21 pm

Yes, I see now that NOTES_LENGTH() does not take an argument, yet MUSIC_LENGTH() does. The code for file 2 is fixed now.

I keep getting the message "download incomplete", with a "filesize" of 1699 bytes.
I have also found and fixed the issue with file 3. I had copied all of the files to a folder called Test, but hadn't corrected the path for file 3. Sorry about that. Please use the new code.
Last edited by rbytes on Wed May 15, 2019 1:41 pm, edited 2 times in total.
####### Living the colorful life #######

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How Do I Import Files Without Dropbox?

Post by rbytes » Wed May 15, 2019 1:32 pm

Here is the 4th and last file to download. It is an mP3 sound effect of a fidget spinner. The download code:

Code: Select all

a2$="fidget3.mp3"
dn$="http://ricardobytes.com/ftp1/Test/fidget3.mp3"
HTTP dn$ GETDIM m   'use the full url here.
FILE a2$ WRITEDIM m 'save just the filename.
sz=FILE_SIZE (a2$)
If sz>0 then
   Print "Connected to file..."
   print "Downloaded file size: ";sz;" bytes"
   if sz= 56424 then
     print "Successfully downloaded ";a2$
   else
     print "Download incomplete"
   endif
else
   Print "file not found"
endif

The play code:

Code: Select all

M$="music"
F$="fidget3.mp3"
MUSIC M$ LOAD F$
MUSIC M$ PLAY
PAUSE MUSIC_LENGTH (M$)
####### Living the colorful life #######

Post Reply