CHDK/uBASIC/Scripts

User-written Scripts
(I'm new to this Wikia thing, so bear with if I'm doing something wrong here. :-) )

Please add your debugged and tested scripts to this section. Reserve discussion and help for writing your script to the DISCUSSION section (tab above). Final scripts will appear on this page.
 * Scripts added here should include:
 * Camera model that you wrote it on.
 * Other camera models that it is known to work on.
 * Any special instructions that may be required for running the script.
 * Your script!


 * Since some scripts require special instructions that might be too lengthy to write into the script itself with "print" statements, I think it would be a good idea to start a common practice of including a short but informative text-file with each script, that could be saved by the same filename. Using a .TXT extension so the file may be referred to as a help-file using CHDK's "File Reader".

I'll post one here that I tweaked/wrote to provide as an example, and for you to use as a possible template if needed.

To post your own script to this main Scripts page:
 * 1) Click on the EDIT TAB at the top of the page (not the ones beside each entry).
 * 2) Scroll to the bottom of the list of scripts.
 * 3) Make sure there's a horizontal-line formatting command between your script and the last script. (using the string on a line by itself)
 * 4) Put the title of your script inside of the ==Headline Text== formatting commands. This will cause it to show up in the "Contents" box at the top of the page, so people can more easily get right to your individual script.
 * 5) Preface each line of your script with a character to retain orignal formatting.

Focus Bracketing
Documentation/Help (save as a small "focus-brkt.txt" file to your /SCRIPTS/ folder)
 * Written for/on: Powershot S3 IS
 * Also works on: (unknown at this time)

Put camera into Manual Focus mode. Make sure your focal distance is not too close to infinity or the nearest focus range of the camera. Meaning: allow some focus-space for the bracketing steps chosen so it won't bottom-out hitting a focus limit. Set your "Script shoot delay" to 0, 1, or 2 (depending how fast your camera can use this script). Set the number of bracketing steps you desire, keeping in mind that there will be twice this number of shots taken. 5 bracketing steps = 5-near + chosen-focus + 5-far, 11 shots in total. Step sizes of 2, 3, 4, and 5 work well. Shooting with the script: Put camera in  mode. HOLD DOWN YOUR MF (manual focus) BUTTON! Press shutter release.

Script Code (save as "focus-brkt.bas" to your /SCRIPTS/ folder) @title Focus Bracketing (Hold MF!) @param a Number of +/- steps @default a 2 @param b Step size @default b 2 if a<1 then let a=2 if b<1 then let b=3 print "Preparing..." for n=1 to a*b click "down" next n print "Shoot 1 of", a*2+1 shoot for s=1 to a*2 for n=1 to b        click "up" next n    print "Shoot", s+1, "of", a*2+1 shoot next s print "Finalizing..." for n=1 to a*b click "down" next n end

Unlimited Interval Shooting

 * Written for/on: Powershot S3 IS
 * Also works on: (unknown at this time)

This script was written for times where you need to use your camera for surveillance or for extended astrophotography sessions, etc. This script will run until you interrupt it by any means available. Use with caution! See the documentation below. Documentation/Help (save as a small "intvl-nolimit.txt" file to your /SCRIPTS/ folder)

This interval shooting script will repeat non-stop until you interrupt it by pressing the shutter-button (or exit the  mode with other button presses). If your camera is hooked up to an AC power-supply DO NOT leave this script running for many hours, days, or weeks as it could damage your camera! Otherwise it will run as long as your batteries last or as much space as you have left available on your SD card.

IMPORTANT: It has been found that lengthy intervalometer sessions with shutter speeds below 1 second (1 to 15 seconds) will cause your camera to show an error code or just shut down after 2 to 12 exposures. This has been traced down to a power-requirement limit and the brand of AA batteries in use. Keep your exposures further apart, use shorter shutter-speeds, turn off your LCD display (use the EVF view), and turn off auto-focus to try to lower the amount of power-drain that will cause this.

Script Code (save as "intvl-nolimit.bas" to your /SCRIPTS/ folder)

IMPORTANT: When copying this script to a new file, BE SURE that there's a [space] character after the ":shot " statement (6th line from the bottom). This is a limitation/work-around for the tiny uBASIC for these cameras. rem Non-Stop Interval Shooting @title Interval Shooting Non-stop @param a Interval (Minutes) @default a 0 @param b Interval (Seconds) @default b 5 @param c Interval (10th Seconds) @default c 0 t=a*60000+b*1000+c*100 if t<100 then let t=5000 n=1 print "Interval shooting." print "Until you interrupt it." print "Use with caution." sleep 1000 goto "shot" :shot print "Shot number", n   shoot n=n+1 sleep t   goto "shot"

Next New Script Title
[ ↑↑ Place Next Script Here ↑↑  ]