Script to open a pdf file

I still don’t understand — there is no “ChordPro Warning” dialog in Gig Performer. Are you trying to run a separate ChordPro application?

I was just trying to show you what the actual ChordPro error is. When I run it from GP, it just gives me the “No such file or directory” error in my PDF program. I’ve tried it in 3 different PDF programs, so that’s not it.

When I use the Song Lyrics/Chord editor and click view, it does show the PDF pages in a vertical scroll. So it does work in the editor in the view tab after I paste the code.

When I look at the song properties, it shows the correct name of the song with the .pro extension. And the file is in the Gig Performer Song Lyrics-Chords folder.

Gig Performer’s implementation of the ChordPro standard has some Gig Performer specific extensions in it (such as songpartname) that would not be recognized by a standard ChordPro application

So the error produced by a non-Gig Performer implementation of ChordPro is a complete red herring and I just wasted an hour trying to reproduce this.

So — when you inserted the text below into the Edit tab of Gig Performer’s ChordPro viewer and then switched to the View tab, what actually happened?

{songpartname: 1}
{image: "D:/Defaults/Documents/PDFs/There's Nothing That God Can't Do/There's Nothing That God Can't Do-000001.png" }

{songpartname: 2}
{image: "D:/Defaults/Documents/PDFs/There's Nothing That God Can't Do/There's Nothing That God Can't Do-000002.png" }

It does show the PDF with the individual pages in a vertical scroll. So, it works there. I need it to work full screen, side by side… and with all of the features I use in my PDF program, like annotations, highlighting, etc. So, I need it to open in my PDF program of choice (XODO). I was going to move GP to a secondary screen so that I can see the panels. The primary screen on my laptop would be lyrics/chords.

What is it supposed to look like when viewing lyrics/chords in GP?

Oh – so why were you saying you were getting an error? I’m completely confused

Ah, that’s a whole different ballgame – now I understand why you want a script — you had me believing that our system was actually broken!

What was in your old script?

Oh! Sorry for about that! Is the view tab all you get? That’s pretty small for such an old guy like me! :smile: I was confused too.

My script from 2018 (and worked) is waaaaaay up at the top of this thread, but here it is again:

//Script to open a file or website location when a song/rackspace is opened. Uses Windows PowerShell. 
//This will open the program associated with the file-type, but will not close the program when deactivating the song/rackspace.

var
   file : ExternalApplication // A GPScript object used to execute an external application. This object MUST be declared at global scope
   
   PowerShell : string // This will hold the full name of the application used
                                // to open a file or web link
   
initialization
   // Location of PowerShell
   PowerShell = "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"

end

// A GP Script function to handle the gory details
function OpenFile(var name : string)
   file.EA_ClearAllArgs()
   file.EA_AddArgument(PowerShell)  // First arg is always the name of the executable to run

   file.EA_AddArgument(name)  // This should be location of a file or web address
   file.EA_Start()  // Run the executable

end

On Activate
   // Opens file or link in PowerShell. Use 'C:/path/to/file.ext' or 'http://website.com/'
   // The file or link will be opened by the program associated with it.
   //You can use multiple OpenFile commands for multiple files or links.
   OpenFile("start 'C:/Users/music/Documents/PDFs/Your Love Awakens Me.pdf'")
   OpenFile("start 'https://www.multitracks.com/'")

End

//Following is left over code not necessary because PowerShell runs in the background and closes itself.
//On Deactivate

   //file.EA_Stop()
//end

Oh

You’re not setting the program name

https://gigperformer.com/docs/GPScript40/content/reference/list-of-functions.html#EA_SetProgramName

Also, you may have to separate the ‘start’ and the filename as two different arguments

Here’s an example - no guarantees, I’m not in a position to test it

var
   file : ExternalApplication 
   
   PowerShell : string = "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"

function OpenFile(var name : string)
   file.EA_ClearAllArgs()

   file.EA_SetProgramName(PowerShell)
   file.EA_AddArgument("start")
   file.EA_AddArgument(name)  // This should be location of a file or web address

   file.EA_Start()  // Run the executable

end

On Activate
   OpenFile("C:/Users/music/Documents/PDFs/Your Love Awakens Me.pdf")
   OpenFile("https://www.multitracks.com/")

End

I’ll give it a shot and brush up on GP script. Is there a variable for the song name? That way I could make it:

OpenFile("C:/Users/music/Documents/PDFs/**song_name_variable**.pdf")

Then I’d just have to put the same scriptlet into each song without any changes. I can look it up, but if you know off-hand, I’d appreciate it.

Again, sorry for the confusion. I didn’t understand what the lyrics/chords was supposed to look like in a setlist.

No - but there’s a function called GetCurrentSongName()

I had to look it up too – there are hundreds of functions. Please refer to the system function list

1 Like