Page 1 of 1
How To Open Different Kind Of Text Files And Put in a Field?
Posted: Sun Apr 28, 2013 1:21 pm
by Fasasoftware
Dear friend,
i have a big problem...how i can open Different Kind Of Text Files And Put in a Field? Of course when i push a button each per time... Documents like :
.txt , .rtf , .pdf , .doc, etc...... In other words... i need to choose the format when i open a file and import to a field...
Can you help me please???
I thank you in advance....
Best regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 12:18 pm
by BvG
The "answer file with type" dialogue allows the user to choose from different types, which you then can handle differently in code:
Code: Select all
answer file "Choose a text file:" with type "Plain Text|txt|TEXT" or type "Rich text|rtf|RTF "
put it into theFilePath
put the result into theFileType
if theFileType = "Plain Text" then
--do stuff here
else if theFileType = "Rich text" then
--do other stuff here
end if
Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 12:54 pm
by Fasasoftware
I thank you very much Bvg....
But this is not exactly what I need....
I need a script that open a big range of files text...like (at least these type of format) txt,doc,rtf,pdf...etc... and put it into a field....your example is too generic... can you show me another detailed solution???
Thanks a lot again!!!
Best Regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 1:07 pm
by Dixie
Look at the files function in the dictionary... using this function will tell you what 'type' your file is before you try to open it.
Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 2:06 pm
by Fasasoftware
I have found a very useful stack in the User Samples by "Christian Langers" Called "TextUtil.livecode"......
This is so perfect for me .... but i need only one modify....I need to open also the PDF format....in other words retrieve a text file with sense from a PDF format.....
Can Someone help me???? Any script idea or some ideas to change this stack acccepting PDF???
Many thanks to All!!!!!
Best regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 8:37 pm
by Fasasoftware
Unfortunetly,
the stack that i told you ....don't work in windows......
I need to know how to open a file in a wide rage of format for any platform....including Mobile.....
Can you help me please????
best regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Mon Apr 29, 2013 9:34 pm
by dave_probertGA6e24
I think you need to be a little more specific in what you mean by "open a file".
Do you mean you simply want to access the file as ascii text (which would look like rubbish to most people) ?,
or
Do you mean you want to display the "Formatted" file (ie. with font's, lines, boxes, graphics, etc) ?
If you want the first option above then simply do:
Code: Select all
put url("binfile:yourfilenamehere.ext") into tData
put tData into field "your field"
obviously it will look awful in the case of the various binary file formats, but it will show stuff!
To do the latter option - show formatted files, you will need to tell us the file types you are interested in looking at. Remember that a PDF is not the same as a DOC file and so forth. There is no single function that will show any file type that you want - because they are all different in their binary formatting and suchlike.
If you are after something that is going to allow you to preview any type of file then you will be writing a very large tool that you will need to spend a lot of time and effort creating. As you can probably guess there are not too many people who will give away all that code for free - be prepared to pay.
To get answers in any forum, including this one, you really need to be very specific in what you ask and give as much information as possible regarding what you want people to give you. You will get answers quicker, and usually more focussed on what you ask for. Remember that other people might not understand what you want by what you write - there are non-english speakers who don't read/write the same as you, and also the reverse is true.
Hope that helps,
Dave
Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Tue Apr 30, 2013 3:34 pm
by Fasasoftware
DEAR DAVE,
Thank you for your answer...i think to be clear i need a script that open all kind of text including mac windows and mobile android and ios...
i need for example a code like this but for all format:
Code: Select all
on mouseUp
answer file "A text file" with type ("text files|txt|tTXT" & return & "all files|*|*")
if it <> "" then
put it into theFilePath
put URL ("file:" & theFilePath) into field "text"
else
--no file was selected, or cancel was pressed
beep
end if
end mouseUp
but this example open only a txt file....
I need to open . txt,rft,doc,docx,html,pdf...at least...
Ok, it's also ok if it's not formatted text ...but the words must be clear, not with garbage's fonts..
I think this script or stack could help a lot of livecode users...
Any Idea???
Thanks a lot...
best regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Tue Apr 30, 2013 5:15 pm
by Klaus
Buonasera Lestroso,
you can only display TXT and RTF files NATIVELY in Livecode!
For PDF and DOC/DOCX you may need an external or library.
Here is something for DOC files:
http://curryk.com/wordlib.html
No idea about PDF, sorry, but on the Mac you can display a PDF document in a player object, if that helps...
Best
Klaus
Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Tue Apr 30, 2013 8:25 pm
by Fasasoftware
Many thank you Klaus...Vielen Danke...
Now I see...I can only display or open natively txt and rtf..... ok....
So i have decide to use external app (also On Line) that convert Pdf to txt or word.... to include in my app
Ok...Thank you a lot to everybody for the help.....
Best regards,
Lestroso

Re: How To Open Different Kind Of Text Files And Put in a Fi
Posted: Thu May 02, 2013 9:23 pm
by danielrr
This is wonderful! Only the problems with Unicode, as per usual, but a truly useful tool