save file into app

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mah_qethyBUShPJV
Posts: 4
Joined: Wed Apr 11, 2012 5:27 pm

save file into app

Post by mah_qethyBUShPJV » Fri Aug 05, 2022 12:05 pm

good day

I'm making car instruction step by step how to

ex how to change oil and oil filter
i already make pdf files with instruction
but i need to press button and it show the instruction
i already know to make path and open pdf but if i send the application to other the pdf will be on my laptop and it will not work with them

what can i do ?

ps. my app
1st stack car company ex( bmw , vw , Toyota ...
then it go to car model
then car year
then 6 button show ex( oil and oil filter change

mah_qethyBUShPJV
Posts: 4
Joined: Wed Apr 11, 2012 5:27 pm

Re: save file into app

Post by mah_qethyBUShPJV » Fri Aug 05, 2022 12:07 pm

it prefer be in app as internet access not always have

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: save file into app

Post by jacque » Fri Aug 05, 2022 5:07 pm

You can store the PDF files in the app as custom properties. Do you know how to do that?

Another way is to put the files in the Copy Files pane of the standalone settings. Then they will be included in the app installation.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mah_qethyBUShPJV
Posts: 4
Joined: Wed Apr 11, 2012 5:27 pm

Re: save file into app

Post by mah_qethyBUShPJV » Sat Aug 06, 2022 8:20 am

thank you so much ill try it

mah_qethyBUShPJV
Posts: 4
Joined: Wed Apr 11, 2012 5:27 pm

Re: save file into app

Post by mah_qethyBUShPJV » Sat Aug 06, 2022 9:45 am

jacque wrote:
Fri Aug 05, 2022 5:07 pm
You can store the PDF files in the app as custom properties. Do you know how to do that?

Another way is to put the files in the Copy Files pane of the standalone settings. Then they will be included in the app installation.
hi i try to find tutorials for what u said but didnt find
can u refer tutorials for "You can store the PDF files in the app as custom properties. Do you know how to do that?"
i already upload pdf in standalone but dont know to to refear button to open it

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: save file into app

Post by SparkOut » Sat Aug 06, 2022 12:07 pm

It is possible to store pretty much any information in a custom property. A pdf is a binary file so you would need to use the "binfile" syntax in a "url" command to get the original file.

To display it afterwards would need you to do the reverse operation and take the data in the custom property and then write it into a file on the user's device that can be read by whatever application is used for the display. (There are complications in cross-device methods, and "generally speaking" there are security reasons why displaying a local file in a browser is prevented. You can search for info on this forum.)

Code: Select all

--you need to know the full path and filename
--for the purpose of this illustration it is assumed to be stored in a variable "tFile"
put url ("binfile://" & tFile) into tDatasheet
set the cDatasheet of this card to tDatasheet
--this allows for one datasheet per card, but you can adjust the naming and storage convention to your design, however you wish
To write it out you need to use a writeable location and also a place that is readable by the display app, with the complications noted above.

Code: Select all

--you need to know the destination file path and name, 
--assumed here to be stored in a variable, such as
put specialFolderPath("documents") & "/xyz.pdf" into tDatafile
put the cDatasheet of this card into url ("binfile://" & tDatafile)
launch document tDatafile --results may vary
If you are the author of the datasheets, it might be much more convenient to save them as rtf documents instead of pdf.

Then you can import them in the same way as indicated above. But instead of having to write out the file for display, with those complications, you can just display the rtfText in a field within the LiveCode app.

Code: Select all

set the rtfText of field "DatasheetView" to the cDatasheet of this card

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: save file into app

Post by jacque » Sun Aug 07, 2022 8:13 pm

mah_qethyBUShPJV wrote:
Sat Aug 06, 2022 9:45 am
i already upload pdf in standalone but dont know to to refear button to open it
If you already incude the PDF files in standalone settings they will be stored in specialFolderPath("resources") in the app. The file name will be specialFolderPath("resources") & "/myFile.pdf". If you want to get the file content instead of just the path, use this:

Code: Select all

put url ("binfile:" & specialFolderPath("resources") & "/myFile.pdf") into tPDF
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply