Importing Files in SmartBasic SDK

User avatar
greycheek
Posts: 34
Joined: Sun Mar 15, 2015 3:14 pm
My devices: MacBook Air, Iphone 6+, Ipad 2

Importing Files in SmartBasic SDK

Post by greycheek »

My application calls external files (a text file and 2 images). How do I include those files when compiling a SmartBasic app in SDK for Xcode?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Importing Files in SmartBasic SDK

Post by Mr. Kibernetik »

Exactly as you include your main program.
Your project in SDK should be an exact replica of your project on your iDevice, including all necessary files.

User avatar
greycheek
Posts: 34
Joined: Sun Mar 15, 2015 3:14 pm
My devices: MacBook Air, Iphone 6+, Ipad 2

Re: Importing Files in SmartBasic SDK

Post by greycheek »

Im using an input statement to read the contents of a text file into a string variable. I get a message At runtime stating that there is no data to read. Im assuming that is because it is not seeing the text file. Ive tried placing the text file in different directories and have also tried changing the file path in the SmartBasic program text file. All no good. What am i doing wrong?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Importing Files in SmartBasic SDK

Post by Mr. Kibernetik »

All you have to do is just copy your files exactly as they are in your smart BASIC to the "Samples" folder of SDK.
If this advice does not help, then please tell me all your files names with their folder names in your sB project.

User avatar
greycheek
Posts: 34
Joined: Sun Mar 15, 2015 3:14 pm
My devices: MacBook Air, Iphone 6+, Ipad 2

Re: Importing Files in SmartBasic SDK

Post by greycheek »

Here are the filenames in the Samples folder:

GreyGrad.jpeg
Info.txt
Prop Wheel.png
WOP.txt (this is the SmartBasic program file)

All of the above files are in the same "Files" directory in the SmartBasic app.

Here is the error message at runtime:

INPUT without data in file "Info.txt"
FILE "Info.txt" INPUT infotext$

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Importing Files in SmartBasic SDK

Post by Mr. Kibernetik »

Then you need to create "Files" directory in the "Samples" directory and put your files there.
And path to your executable file will be: "Files/WOP.txt"

Or you can try it another way.
Put your files in the root directory of smart BASIC and try to run. If you get the same error then your program is coded to run only from "Files" folder. If you get no errors then you need to find out, step by step, what is wrong with your code and why it does not see files, like here viewtopic.php?f=34&t=1304#p7910

User avatar
greycheek
Posts: 34
Joined: Sun Mar 15, 2015 3:14 pm
My devices: MacBook Air, Iphone 6+, Ipad 2

Re: Importing Files in SmartBasic SDK

Post by greycheek »

The "Info.txt" is not seen no matter what folder the file is placed in, including the "Files" folder. It does seem to be accepting the two image files, however. I wonder if this is not a file path issue, but something else?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Importing Files in SmartBasic SDK

Post by Mr. Kibernetik »

Please tell what you will find.

User avatar
greycheek
Posts: 34
Joined: Sun Mar 15, 2015 3:14 pm
My devices: MacBook Air, Iphone 6+, Ipad 2

Re: Importing Files in SmartBasic SDK

Post by greycheek »

I'm stumped. Even when I remove the "FILE "Info.txt" INPUT infotext$" command from the SmartBasic code, the iOS simulator still generates the same error message at runtime!

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Importing Files in SmartBasic SDK

Post by Mr. Kibernetik »

Seems your app in simulator is outdated.

My quick suggestion can be: delete your app from simulator and try again. Or perform Product > Clean from Xcode menu.

Post Reply