Script error (unk key) - Script Writing - CHDK Forum supplierdeeply

Script error (unk key)

  • 10 Replies
  • 5471 Views
Script error (unk key)
« on: 09 / January / 2012, 16:00:59 »
Advertisements
Hi guys,
I just found out that my Phottix Strato II isn't fully compatible with the G12 for remote triggering. The problem is that while half shutter works (camera locks focus when you hold half shutter on wireless trigger), fully pressing the shutter button on the trigger does nothing and the photo isn't taken.

As such, I decided to write a small script which allows me to take a picture while half shutter is being pressed. Here's what I've written so far (using uBasic):

Code: [Select]
@title Strato wireless remote workaround
@param a Lock AF
@default a 1

if a=1 then set_aflock(1)

:myloop
if is_pressed "half_shoot" then
repeat sleep 50 until get_shooting()==true
shoot
endif
if is_pressed "set" then goto "safeexit"
sleep 1000
goto "myloop"

:safeexit
if a=1 then set_aflock(0)
end

When executing this script on my G12, I am getting an error called unk key on line 14. Is there something wrong with the jump?

Appreciate any help! :-)

Malcolm

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Script error (unk key)
« Reply #1 on: 09 / January / 2012, 16:34:54 »
You have a synthax mix of ubasic and lua code.

The script is a uBasic script, but 
Code: [Select]
set_aflock(1)
repeat sleep 50 until get_shooting()==true
set_aflock(0)
are lua or mixed code.

msl
CHDK-DE:  CHDK-DE links

*

Offline zeno

  • *****
  • 891
Re: Script error (unk key)
« Reply #2 on: 09 / January / 2012, 18:09:56 »
To fix it in ubasic you need to rewrite it like this:

Code: [Select]
@title Strato wireless remote workaround
@param a Lock AF
@default a 1

if a=1 then set_aflock(1)

:myloop
if is_pressed "half_shoot" then
do
                   sleep 50
                until get_shooting()==true
shoot
endif
if is_pressed "set" then goto "safeexit"
sleep 1000
goto "myloop"

:safeexit
if a=1 then set_aflock(0)
end
You may want to use my ubasic debugger (http://www.zenoshrdlu.com/kapstuff/zubdb.html) which runs under Windows, OSX and now Ubuntu Linux, to test your scripts.
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

Re: Script error (unk key)
« Reply #3 on: 09 / January / 2012, 18:13:58 »
Thanks a lot for the help!

Zeno, thanks for sharing your app! Will definitely come in handy next time :-)


Re: Script error (unk key)
« Reply #4 on: 10 / January / 2012, 08:44:26 »
Updated the script, but I'm still getting the same error on the goto "myloop" line when running it on the camera :(

*

Offline zeno

  • *****
  • 891
Re: Script error (unk key)
« Reply #5 on: 10 / January / 2012, 10:21:19 »
Try this version ('goto' statements are not good practice anyway!):
Code: [Select]
@title Strato wireless remote workaround
@param a Lock AF
@default a 1

if a=1 then set_aflock(1)
b = 0
while b = 0
if is_pressed "half_shoot" then
do
                   sleep 50
                until get_shooting()==true
shoot
endif
if is_pressed "set" then b = 1
sleep 1000
wend

if a=1 then set_aflock(0)
end
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Script error (unk key)
« Reply #6 on: 10 / January / 2012, 11:15:18 »
until get_shooting()==true is wrong. That's lua syntax.

Use until get_shooting=1 for uBasic. uBasic knows no true or false.

Btw, with uBasic we need no brackets for the arguments.

msl
CHDK-DE:  CHDK-DE links

Re: Script error (unk key)
« Reply #7 on: 11 / January / 2012, 05:40:51 »
Appreciate all your help guys!

Still getting the same error (unk key) with the following updated script though. I'm beginning to think that it's something with the logic of the script  ???

Code: [Select]
@title Strato wireless remote workaround
@param a Lock AF
@default a 1

if a=1 then set_aflock(1)
b = 0
while b = 0
if is_pressed "half_shoot" then
do
            sleep 50
        until get_shooting=1
shoot
endif
if is_pressed "set" then b = 1
sleep 1000
wend

if a=1 then set_aflock(0)
end


Re: Script error (unk key)
« Reply #8 on: 11 / January / 2012, 07:02:52 »
try
Code: [Select]
if is_pressed "shoot_half" theninstead
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Script error (unk key)
« Reply #9 on: 11 / January / 2012, 07:03:31 »
Sometime we not see the wood for the trees.  :lol

"half_shoot" is wrong. "shoot_half" is the right key!

Try this script:
Code: [Select]
@title test
@param a Lock AF
@default a 1

if a=1 then
    press "shoot_half"
    do
        sleep 50
    until get_shooting=1
    release "shoot_half"
    set_aflock(1)
endif

b = 0
while b = 0
    wait_click 0
    if is_key "shoot_half" then
        shoot
    endif
    if is_key "set" then b = 1
    sleep 1000
wend

if a=1 then set_aflock(0)

end

For AF lock you should focus.

msl


CHDK-DE:  CHDK-DE links

 

Related Topics