Sometimes we need to get the Order ID for use in our macros. This can be for any number of reasons, but what’s important to know is that you need to grab the job id in different ways depending on where a product item is during its life-cycle.
When a product is sitting in the items window in a job, it is in the product item stage. Once released it will sit on the queue until printed, this is the queued stage. The final stage is printing.
Depending on what stage the product is, the order id will need to be retrieved from different database tables or using KPL provided functions. So here is the Code:
String manipulation is one of the most common things to do in a programming language, so it is to no surprise that KPL offers many tools for doing what you want. I will try to show you and explain some of it most useful tools.
The most common task that I can think of is to test if two strings are the same.
In other languages you would use the “==” comparison operation. in KPL you need to use the built in
// this is a case-insensitive comparison
Edit As noted in the comments by Tom Apeland (The KPL Author!). You can use ==:
// This is a case sensitive comparison
if ( ~~ == ~~ )
remember that when using a variable to always use <> like so
if ( ~<somevar>~ == ~The text to compare to~ )
This will return True or False and can be used directly into any conditional structure.
Many things we might want to do to a string Read more
KPL variables resemble PHP variables in the sense that they are loosely typed and don’t have to be declared. For those new to programming, this means that you don’t have to declare that the variable is an integer or a text string.
Variable names must start with an alphabetic character followed by any alpha-numeric combination, underscores are allowed but any other non alpha-numeric character is forbidden. These are some Examples of correct variable names:
If you want to get your feet wet with KPL, cmds files are the easiest way to get started. Cmds stands for commands, there are many uses for these files but the most important in my opinion is the import of photo orders from other applications. To be able to use cmds files we first we need to enable a hot folder in DP2, the steps are as follows:
- On the User Tasks Menu Click on categories under you see the menu option Import
- Click Import and look for Commands
- Click Commands
- A new window opens, select a directory (preferably one that is easy accessible for your application)
- click Start
KPL (Kodak Professional Language) is the underlying language that drives the DP2 Photo Lab production software. It is based on the C programming language family and it allows developers access to a lot of C methods and windows API’s. The language has been greatly expanded from it’s C roots to include features that are tailored to the photo production world.
The best way to understand this is to imagine DP2 as being a Runtime Environment in which KPL is Executed. The entire DP2 User interface and Underpinnings are implemented using KPL. Since KPL is an interpreted language, changes to DP2 do not require recompiling and can be done pretty much live. Even thought documentation is limited, the fact that you can see all the code that is used to do everything in DP2, makes it easy to learn what does what. DP2 has a very powerful Programmer’s Assistant tool and Debugger. There is also integration with Notepad++ for syntax highlighting also integration with the plugging snippets plus adds snippets and auto completion.
DP2 is a database driven application so naturally KPL has amazing tools for reading and writing data to the database. For what I have seen KPL is an Object Oriented Language, there is a long list of classes but most of the scripting that a user will be doing is based on the use of functions.
There is a great number of built-in functions for managing orders, images, packages and other production related work. Also, since Version 14 there is a very powerful Hooks system to alter the interface without having to change core DP2 files, this is a great way to avoid having your code being wiped out when a new version is installed.
There is a lot more to be said about KPL and DP2, you can create UIs using Html, JS and CSS, there is a built in Web server for receiving commands and there is also way to insert KPL scripts from other applications through the use of a hotfolder. There is robust printer integration, great queue management and print job organization. I will be talking more about this things on future articles as I work and discover more on the matter.
It is also important to note that the programming team at Kodak is filled with great, helpful people that will answer most of your questions almost immediately over email. And most of the changes in DP2 are driven by customer feedback.