Problem in loading pdf

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
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Problem in loading pdf

Post by shalu » Wed Jul 01, 2015 7:03 am

Hi,

I am beginner in live code, I am using Linux os and I want to open a pdf from home. for that I am using the code

Code: Select all

   put shell("echo $HOME/") into home1
   put the fld "Field" into ss
   put home1&ss into ass
   answer ass
   launch document ass
The above code is not working because while combing the home path and name of pdf into a variable it's shows that home path and pdf name are appearing in separate lines, how i merge these two line, or is it any alternative method for this problem. :oops:
--
Thanks
Shalu S

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

Re: Problem in loading pdf

Post by SparkOut » Wed Jul 01, 2015 8:03 am

The shell command returning the home path by echo is bringing a trailing return.
You can add a check after retrieval

Code: Select all

if the last char of home1 is cr then
  delete the last char of home1
end if 
Don't refer to "the" field "Field" - "the" is required for properties but not containers.
I can't check right now but look up specialFolderPath. It might be that there is a "home" option for Linux, if the "documents" folder is not the same.

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

Re: Problem in loading pdf

Post by MaxV » Thu Jul 09, 2015 3:07 pm

SparkOut is right, you can use specialfolderPath this way:

Code: Select all

launch document ( specialFolderPath("home") & "/mydocument.pdf" )
It works on Linux Mint.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem in loading pdf

Post by Klaus » Thu Jul 09, 2015 3:51 pm

You can even use $HOME if you prefer this more *NIX like syntax :D
...
launch document ($HOME & "/mydocument.pdf")
...

Post Reply