Author Topic: is there any way to open a pdf doc from slick c code  (Read 177 times)

Graeme

  • Senior Community Member
  • Posts: 2631
  • Hero Points: 330
is there any way to open a pdf doc from slick c code
« on: July 22, 2021, 11:54:27 am »
Is there any way to open a pdf doc from slick c code?

shell("abc.pdf") doesn't work.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1583
  • Hero Points: 140
Re: is there any way to open a pdf doc from slick c code
« Reply #1 on: July 22, 2021, 02:11:53 pm »
I don't see anything that looks up the document type handler outside of some browser specific code.

On Windows you can use shell("start FILENAME"), and on the Linux shell("xdg-open FILENAME").    And it looks like shell("open FILENAME") for OSX.

So something like this:
Code: [Select]
   filename := "~/Books/ModernRobotics.pdf";
   cmd := "";
   if (_isWindows()) {
      cmd = 'start';
   } else if (_isLinux()) {
      cmd = 'xdg-open';
   } else {
      cmd = 'open';
   }
   rc := shell(cmd' '_maybe_quote_filename(filename));



Graeme

  • Senior Community Member
  • Posts: 2631
  • Hero Points: 330
Re: is there any way to open a pdf doc from slick c code
« Reply #2 on: July 23, 2021, 09:36:55 am »
great, thanks.