Page 1 of 1

How to save pdf automatically on every 15 minutes

Posted: Fri Jun 26, 2015 11:38 am
by samjith
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.

Re: How to save pdf automatically on every 15 minutes

Posted: Fri Jun 26, 2015 6:52 pm
by jmburnod
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

Re: How to save pdf automatically on every 15 minutes

Posted: Mon Jun 29, 2015 5:51 am
by samjith
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.

Re: How to save pdf automatically on every 15 minutes

Posted: Mon Jun 29, 2015 10:03 am
by jmburnod
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

Re: How to save pdf automatically on every 15 minutes

Posted: Mon Jun 29, 2015 12:52 pm
by samjith
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

Re: How to save pdf automatically on every 15 minutes

Posted: Mon Jun 29, 2015 6:28 pm
by jacque
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?

Re: How to save pdf automatically on every 15 minutes

Posted: Mon Jun 29, 2015 7:55 pm
by SparkOut
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.