Using an internal file for PDF for manual

Francis Nugent Dixon effendi at wanadoo.fr
Sat Aug 9 07:21:56 EDT 2014


Hi from Beautiful Brittany,

FAO Charles  Szasz,

I hate Adobe Reader, and don’t really go for Preview (except for its useful options).
I use SKIM (unfortunately this app is Mac Only), great appleScript interface, and as user friendly as you get.

I open files from a LiveCode script like this :   (Care with line wraps)

   put "set GVFilePath to POSIX file " & quote & GVDataPath & field "MyTitle" & quote into line 1 of GVMasterScript
   put "tell application " & quote & "Skim" & quote into line 2 of GVMasterScript
   put "set myDocument to open GVFilePath" into line 3 of GVMasterScript
   put "tell myDocument" into line 4 of GVMasterScript
   if field "MyPagesC" is empty then                       -- Do we have any page numbers ?
      put 1 into GVPage                                          — If not, set to default - Page 1.
   else
      put char 1 to 3 of field "MyPagesC" into GVPage     — such as “1.5” which is desired text size.
   end if
   if field "MyPageC" = 2 then put round(GVPage/2 + 1) into GVPage   — I wonder why I did this ????
   if field MyScaleC is empty then put "2.0" into field MyScaleC      — Default text size for me.
   put field MyScaleC into LVScaleFactor
   put "set view settings to {scale factor:" & LVScaleFactor & ", auto scales:false}" into line 5 of GVMasterScript
   put "go to page " & GVPage into line 6 of GVMasterScript
   put "end tell" into line 7 of GVMasterScript
   put "activate" into line 8 of GVMasterScript
   put "end tell" into line 9 of GVMasterScript
   --
   --     AppleScript is now complete. So execute it !
   --
   do GVMasterScript as AppleScript

Note : field “MyTitle” is the title of my pdf file (in my liveCode Stack), the file I want to open.
           GVMasterScript is the script I build in line and feed to appleScript.
           GVDataPath is a global variable containing the partial path to my LiveCode folder containing my file (end with “/“)
           GVFilePath is a global variable containing my complete file path (including the file suffix).
           field “MyPageC” is the page of the pdf (in my liveCode stack) I want to go directly to.
           field “MyScaleC” is the scale of the pdf file (in my liveCode stack) as I want it displayed
           (I use scales of 0.4, 0.5, 0.7, 1.0, 1.5, or  2.0, depending on the text size I want on the screen)

The appleScript will launch SKIM with the required parameters (there are more possible parameters that I don’t use).
The pdf file will be displayed in the foreground, in front of your LiveCode Stack.

You can find more info in Skim/appleScript (if you are patient)  when you google “appleScript for SKIM”.

I hope you find this useful.

Francis



More information about the use-livecode mailing list