FANDOM


Previous chapter: My first script
Next chapter: Talking with the user

Okay, you now know the very basics of a PlayOnLinux script, but we should add some functionality now!

The window Edit

Almost every POL-installer has a window telling the user what to do, or what the installer does. Thanks to the POL-functions it's really easy to initiate a window. You only need one single row of code:

POL_SetupWindow_Init

Well, it sure isn't the shortest command you've seen, but for some reason all POL-functions that interacts with windows starts with "POL_SetupWindow". Okay, create a new script. Add the things that must be in the script, and at the end add that command. Run the script from POL and see the result. Congratulations!

Screenshot85

Most scripts will look like this.

Well, you've now created a window, but at the end of the script you will also want to close the window, this is done with the command (surprise!) POL_SetupWindow_Close. And we would also want the script to terminate when it is done, lets add the bash-command exit at the end of the script.

The script you have now is the very basics of all other scripts you will ever do. Yes, all scripts you will ever do. As you can see in the picture to the right I've added a row saying "# Script goes here". All on the row after a "#" is not used by bash. This means you can add useful comments in your script, telling you what each part does! (I warn you, writing script without making comments is not very good. You'll understand the script for now, but let's see in two months!)

Using the window Edit

Screenshot86

Your message will probably look something like this.

Sure, an empty window is cool, but not rather informative. What about adding a text to the window? Add this function POL_SetupWindow_message right after the part where you initiate the window. But wait a second, what message? That's right, you'll also have to tell the function what to print on the screen. This is the functions reference:

POL_SetupWindow_message "My message" "Title"

So add you own message and title, save the script and run it. Looks quite cool, right? It's okay to be impressed, but lets not be too satisfied yet. Continue to the next chapter first!

Previous chapter: My first script
Next chapter: Talking with the user
Community content is available under CC-BY-SA unless otherwise noted.