How to save pdf automatically on every 15 minutes

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
samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

How to save pdf automatically on every 15 minutes

Post by samjith » Fri Jun 26, 2015 11:38 am

We are using Linux. We open a pdf using shell command in livecode, we need back up the pdf for every 15 minutes. Is this possible by livecode.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to save pdf automatically on every 15 minutes

Post by jmburnod » Fri Jun 26, 2015 6:52 pm

Hi,

I think you have to use a "send in time" message.
Have a look at "send" and "pendingMessages" in LC dictonary.

Something like that:

Code: Select all

on startSavePdfPending
   SavePdfPending
end startSavePdfPending

on SavePdfPending
   -- Your save command
   send "SavePdfPending" to me in 900 seconds
end SavePdfPending

--to stop 
on stopSavePdfPending 
   doStopPending SavePdfPending
end stopSavePdfPending

on doStopPending pMessage
   repeat for each line aLine in the pendingmessages
      if pMessage is in item 1 of aLine then
         cancel item 1 of aLine
      end if
   end repeat
end doStopPending
Best regards
Jean-Marc
https://alternatic.ch

samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

Re: How to save pdf automatically on every 15 minutes

Post by samjith » Mon Jun 29, 2015 5:51 am

Hi,

I understood something, not more. If you don't mind can you explain the code with some example.

If i want to copy a saved pdf (example.pdf) at time 10:00 am to path "~/home/samjith/"
Then how this possible.


Thanks,
Samjith.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to save pdf automatically on every 15 minutes

Post by jmburnod » Mon Jun 29, 2015 10:03 am

Hi Samjith,

Here is a stack for example. I tested it on OSX but it should work on linux.
It use a pendingmessage called "SavePdfPending" that save the aera of grc "CadrePrint" to a pdf file.
This message is sent every 30 seconds (easier for test)
Fortunately you stop it with a clic on "StopSave". 8)

I see the first page of pdf file is empty but I don't know yet how avoid this but I am sure someone have the answer

Best regards
Jean-Marc
Attachments
expOneCdTopdfInTime.livecode.zip
(26.45 KiB) Downloaded 197 times
https://alternatic.ch

samjith
Posts: 85
Joined: Tue Mar 31, 2015 10:09 am

Re: How to save pdf automatically on every 15 minutes

Post by samjith » Mon Jun 29, 2015 12:52 pm

Hi Marc,

I dont want to creat a pdf. What my need is that

I open a pdf using shell command
if need to copy pdf to my home directory for every 30 minutes.

If iam working with that pdf for 4 hout, then it will copy to my home directory for 8 times


Thanks
Samjith

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

Re: How to save pdf automatically on every 15 minutes

Post by jacque » Mon Jun 29, 2015 6:28 pm

I'm confused. LiveCode can't edit PDF files, so I think you are opening it in another app. Is that correct? f so, you can just use regular file commands to copy the existing file to another location. LiveCode needs to be running in the background to do that.

Code: Select all

put url "binfile:" & <path to pdf>" into url "binfile:" & <path to copy>"
If you are not editing the pdf in another app, what do you do with it in LiveCode?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: How to save pdf automatically on every 15 minutes

Post by SparkOut » Mon Jun 29, 2015 7:55 pm

What are the command line (shell) commands you are using to control the pdf?

In LiveCode, you would use something like Jean-Marc's timing script to execute the SavePDFPending handler every interval.
The handler would execute the shell command required to save the pdf in the required location, eg

Code: Select all

on SavePDFPending 
   get shell("/user/bin/thePDFexecutable ~/home/samjith/")
end SavePDFPending
whatever shell command you need depends on what your 3rd party controller application is.

Post Reply