New topic: Include files in build
<http://forums.realsoftware.com/viewtopic.php?t=47503> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message sgdeveloper Post subject: Include files in buildPosted: Thu Apr 04, 2013 1:55 pm Joined: Fri Mar 22, 2013 11:33 am Posts: 4 Can anyone tell me how to include files necessary for an app in the final build? For example, when the app opens it needs to read a .txt or .csv file to begin the app. Do these files need to be added to the project or just included with the app after the build? During development, I have just referenced them using a Folderitem and that works well but how do I get them (for example in a Windows build) to be referenced properly so that the app can read them? Top charonn0 Post subject: Re: Include files in buildPosted: Thu Apr 04, 2013 2:02 pm Joined: Mon Apr 02, 2007 2:08 am Posts: 1179 Location: San Francisco, CA, USA Files can be included in the built application by dropping them onto the Project tab. They will be included in the build as strings and can be directly referenced by name in your code. For example, assume you dropped a file called readme.txt onto the Project tab. REALstudio will create a globally accessible string property called "readme" which you can use anywhere, e.g.: 'shows the text in a textarea control SomeTextArea.Text = readme or 'Writes the text to a file Dim tos As TextOutputStream Dim file As FolderItem = SpecialFolder.Desktop.Child("instructions.txt") tos = TextOutputStream.Create(file) tos.Write(readme) tos.Close _________________ Boredom Software Top sgdeveloper Post subject: Re: Include files in buildPosted: Thu Apr 04, 2013 2:10 pm Joined: Fri Mar 22, 2013 11:33 am Posts: 4 charonn0, thanks very much for this info. When referencing these global strings, does this also mean that I do not have to worry about the path to these files in the final build. For development, I have just put them in the same directory as Realstudio and referenced them as Folderitems and from your info I assume that this was not correct. Top charonn0 Post subject: Re: Include files in buildPosted: Thu Apr 04, 2013 3:33 pm Joined: Mon Apr 02, 2007 2:08 am Posts: 1179 Location: San Francisco, CA, USA Right, if they've been added to the project then you don't need to worry about FolderItems, etc. The files will exist as read-only global strings; on Windows and Linux they're baked right into the executable, on Mac they're included in the app bundle (but still read-only). You don't need to move the file into the REALstudio directory since the full path of the dropped file is stored in the project. If the file can't be found you'll get an error when you open the project and the option to correct the file path. _________________ Boredom Software Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
