Folder path variables

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
PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Folder path variables

Post by PeterG » Sun May 21, 2017 6:54 pm

Hi All
I am busy with something in in the Windows Operating system that should merge number of pdf files and create a resulting PDF.
The first bit works fine but I am opening a new card after this.
In the "on open card" event I want to set a Browser widget url to a variable value:

Code: Select all

 set the url of widget "wgtBrowser" to gFilename
After tracing the following, found that the value has a space:
tCombined = "/users/Documents/pdf /combined.pdf"

Any suggestion would be appreciated.
Thanks
Peter G

PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Folder path variables

Post by PeterG » Sun May 21, 2017 8:26 pm

Hi All
My apologies.
Had 2 ampersands instead of one in the code.

Code: Select all

put defaultfolder & "combined.pdf" into tCombined
set the url of widget "wgtBrowser" to tCombined
Thanks
Peter G

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Folder path variables

Post by richmond62 » Sun May 21, 2017 8:56 pm

At the risk of seeming very stupid indeed I cannot understand what you are trying to get across
as you mention this:
set the url of widget "wgtBrowser" to gFilename
and
tCombined = "/users/Documents/pdf /combined.pdf"
which are, presumably sections of some script we cannot see, so we
can see no obvious connexion between them at all.

Please can you post ALL the script so . . . . .

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Folder path variables

Post by FourthWorld » Mon May 22, 2017 1:21 am

A URL requires a service specifier. Try adding "file://" before the path.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Folder path variables

Post by MaxV » Tue May 23, 2017 8:40 am

I tried also with urlencode, but it seems a bug to me.

This doesn't work: file:///home/max/Scrivania/test+with+spaces.xml
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Folder path variables

Post by FourthWorld » Tue May 23, 2017 3:14 pm

Is it an HTML file or an XML file?

When the file is opened in a separate browser application, does it display? If so, what is the URL shown there? Does it differ from the path used in the LC app?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Folder path variables

Post by MaxV » Wed May 24, 2017 3:21 pm

This doesn't work: file:///home/max/Scrivania/test+with+spaces.html

this work: file:///home/max/Scrivania/test%20with%20spaces.html

So in the end this is the solution:

########CODE to copy and paste#######
on mouseUp
answer file "Select file:"
if the result is not "cancel" then
put it into temp
replace space with "%20" in temp
set the URL of widget 1 to ( "file://" & temp )
end if
end mouseUp
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-6#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

PeterG
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Folder path variables

Post by PeterG » Thu Jun 01, 2017 4:54 pm

Hi MaxV
Many thanks for your input
Much appreciated

Peter G

Post Reply