Digita World

Home Digita
Scripting
Digita
Desktop
Digita
Applications
Other
Files
Links

Digita Script Tutorials - Scripting Your First Image Capture

Before writing the body of your script we need to make sure the Mode statement in your script header is set to 0 (Capture mode). DigitaScript commands can only capture an images when the camera is set to the capture mode.Your script header should look something like this:

name "First Image Capture Script"
mode 0
menu "Example Scripts"
label "Capture"

Only two commands are actually required in the body of the script, SetCaptureMode( ) and StartCapture( ). The SetCaptureMode command tells the camera what kind of image you want to capture (still, burst, or timelapse). The StartCapture command tells the camera to capture the image. For the purposes of this tutorial, we're going to set the capture mode to still.

name "First Image Capture Script"
mode 0
menu "Example Scripts"
label "Capture"

SetCaptureMode (still)
StartCapture()

exitscript

If your camera is ready when the StartCapture command is processed, this script will capture an image. But it doesn't give any control to the user of the script, and it can't verify that the camera actually captured an image.

To give the user some control, we're going to place a WaitForShutter( ) command just before the StartCapture command.

WaitForShutter("Take Picture Now!")

The WaitForShutter( ) command puts the camera's LCD panel into display mode, then pauses the script until the user presses the shutter release button. The string inside the parenthesis appears at the top of the LCD display.

To make sure the StartCapture command is successful, we're going to check the error status returned by the StartCapture command.

Every command in the DigitaScript command set returns an error status of 0 if it is successful. To access the returned error status, the command statement is called as part of a variable assignment.

declare i: status

status = StartCapture()

The error status can be assigned to any variable declared as a signed integer.

OK, so we've added a conditional that returns some text to the user if the capture is successful. What do we want the user to do if the StartCapture command fails?

The best answer is to return to an earlier line in the script and attempt to capture the image again. To make this happen, we're going to use a goto statement and a marker statement. A marker statement is a word used to 'mark' a location in the body of your script. Marker statements must always be followed by a colon (:).

CAPTURE:

A goto statement returns the camera's script processor to the specified marker.

goto CAPTURE

To make sure only a failed capture is repeated, we're going to put these new lines of script inside a conditional statement with a few lines of text to let your user know what's going on.

A conditional statement makes it possible for a script to make a decision. In DigitaScript, a conditional statement consists of the word if followed by a condition or test. If the condition is true, the lines of script following the condition are processed. The conditional statement is closed with an end statement. If the condition is false, the script jumps to line following the end statement.

In this script we will be using the != (not equal to) operator. (Refer to the Script Reference for information on conditional operators.)

if status != 0
   DisplayLine ("Image capture failed.")
   DisplayLine ("Please try again.")
   Wait (2000)
   goto CAPTURE
end

If the script does not go back to the :CAPTURE line, then we should display a message to the user letting them know everything worked ok.

   DisplayLine ("Image capture successful")
   Wait (2000)

Your final script should look something like this:

name "First Image Capture Script"
mode 0
menu "Sample Scripts"
label "Capture"

declare i: status

CAPTURE:

status = 0
SetCaptureMode (still)
WaitForShutter ("Take Picture Now!") status = StartCapture ()

if status != 0
   DisplayLine ("Image capture failed.")
   DisplayLine ("Please try again.")
   Wait (2000)
   goto CAPTURE
end

DisplayLine ("Image capture succeeded")
Wait (2000)

exitscript

Congratulations, you've just written your first script!

Save the file as CAPTURE.CSM in plain text format, then install it into the SYSTEM directory on your Compact Flash card.

To run this script, insert your CF card into your camera. Power your camera up, then set it to capture mode. Press the menu button, then navigate to the Sample Scripts menu. Highlight (select) the script Capture, then press the Edit softkey (Kodak users press the Start softkey) to run the script.

Download the free Script SDK to see how much more you can do with DigitaScript. Inside the SDK you'll find more details on the basics of DigitaScript as well as some free scripts you can use as guides when creating your own scripts.

Back to tutorial page


Last modified January 24, 2003          Copyright 2001, Chuck Gadd

Digita, Digita Desktop, DigitaPhoto.com, and DigitaDev.com are trademarks of FlashPoint Technology, Inc.