Run script file from CHDK - page 2 - General Discussion and Assistance - CHDK Forum

Run script file from CHDK

  • 21 Replies
  • 3968 Views
Re: Run script file from CHDK
« Reply #10 on: 07 / December / 2011, 09:12:18 »
Advertisements
Well, in fact the problem of incorrectly finished script was there before. Since file_browser() function is used something is wrong. The best way what is wrong is to describe the problem, so:
Nice to hear that this is not mine bug. :)

BTW I found that I did broke last patch and it is not finish because malformed. In attach workable version.
« Last Edit: 07 / December / 2011, 10:13:29 by tsvstar »

*

Offline philmoz

  • *****
  • 3116
    • Photos
Re: Run script file from CHDK
« Reply #11 on: 07 / December / 2011, 14:02:56 »
Well, in fact the problem of incorrectly finished script was there before. Since file_browser() function is used something is wrong. The best way what is wrong is to describe the problem, so:

- you run script
- this script calls file_browser(), you select a file and then script do what it's designed to
- then you end the script (shoot_full or just end)
and then you like to call another script, maybe change params or something. So you press FUNC key. But instead of scripts menu, the file browser is immetiately run.

This problem appears only if you use file_browser() in a script.

This should have been fixed in changeset 1452.
Please let me know if it is still happening.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)

Re: Run script file from CHDK
« Reply #12 on: 07 / December / 2011, 15:33:41 »
Quote
This should have been fixed in changeset 1452.
Please let me know if it is still happening.

Phil.

Tested - You're right, the problem doesn't exist in official builds. I had to miss it. So many news!
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: Run script file from CHDK
« Reply #13 on: 07 / December / 2011, 17:04:18 »
Well, there is already another bug (I mean official release without tvstar patch - had not yet found time to compile...).

When you run editor and want to turn it off when file browser is still open you just press shoot_full. Then file browser dissappear, as it should be. In console you can read an error message, but it's just a edi bug.

Nevertheless - now try to do enything! You can leave ALT and back into ALT mode, but you are not able to run menu! WTF?!
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


*

Offline reyalp

  • ******
  • 11992
Re: Run script file from CHDK
« Reply #14 on: 07 / December / 2011, 22:10:41 »
Is this that you mean in "The script param stuff is already a mess, and this takes it in the wrong direction"?
No, I mean the stuff that loads the parses / loads the params (a, b c ... etc variables that would get set in the script menu script.c) is mess. Your code adds more special cases to this (paramset.old etc), but when load a script from the file browser, there's no menu so there's no a,b,c params. So why not just run it like a PTP script without any of that ?

From the file browser, what you really want the current file name, or an array of selected file names. So this is a different kind of script than one you run from the menu. My suggestion, there should be separate directory for these kind of script. You could scan it for scripts and add to the menu, instead of hardcoding editor.lua in the C code. If you still want to be able to run it as a regular script, you can put most of the code in a module and require() it from either.

That said, I'm not sure running scripts from the file selector is really an important feature. Yes, it's a little bit of a hassle to switch between editor and some script you are editing, but editing on the camera at all is a much bigger hassle. I don't think most people will do this a lot, so is it worth the trouble and extra code to make it work ?

I can see other cases where running a script directly from code would be useful, e.g. an autoexec script that runs at startup, but unlike autostart, doesn't affect your currently selected script. Maybe other events as well, but you have to be careful because only one script can run at a time.
Don't forget what the H stands for.

Re: Run script file from CHDK
« Reply #15 on: 07 / December / 2011, 22:31:10 »
an autoexec script that runs at startup, but unlike autostart, doesn't affect your currently selected script.
Now that idea is one I really "like" a lot.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Run script file from CHDK
« Reply #16 on: 08 / December / 2011, 03:35:42 »
reyalp,
Runing something from fselector is just one sample. You give another sample.
Both of them really could be implemented without input values (with hardcoded in script configurations).

My changes really are well documented and touch existed script loading process a little. They allow to give much more variation. I could give parameters which could be calculated in some way in CHDK.

And this changes are step to my planed "configurable by text menu" feature. Most actions there are described by scripts with parameters. This will allow use same scripts for different items. And so I need to give parameters and store existed parameters somewhere.

PS - I do agree that param loading code could be rewrited in more simple way(or at least more clean). But I keep policy of minimal intrusion into system.

waterwingz
such autoexec is one of planed feature of this future changes. :)
« Last Edit: 08 / December / 2011, 03:45:30 by tsvstar »

Re: Run script file from CHDK
« Reply #17 on: 08 / December / 2011, 06:16:20 »

Now that idea is one I really "like" a lot.

Good, because that is what SDM uses.


*

Offline philmoz

  • *****
  • 3116
    • Photos
Re: Run script file from CHDK
« Reply #18 on: 09 / December / 2011, 15:53:42 »
Well, there is already another bug (I mean official release without tvstar patch - had not yet found time to compile...).

When you run editor and want to turn it off when file browser is still open you just press shoot_full. Then file browser dissappear, as it should be. In console you can read an error message, but it's just a edi bug.

Nevertheless - now try to do enything! You can leave ALT and back into ALT mode, but you are not able to run menu! WTF?!

I've added a fix in changeset 1461 to block the shutter button from starting/stopping a script if the file selector is open.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)

Re: Run script file from CHDK
« Reply #19 on: 12 / December / 2011, 02:03:09 »
What about this solution:
- rewrite script.c to make param loading more clean to understanding (possible not simplier but cleaner)
- make them more documented
- then include changes to store/restore changes of temporary runed script.

I see no problem to temporary run scripts without param loading, but I would like to give larger area of usage to this feature(sample of usage is above). And merge both way will increase complexity both of them. So I prefer just go the way with larger possibilities.

BTW: In my opinion "default script" (built-in and A/default.bas) is not useful and obsolete. Just "no script loaded" message should be enough. And this will simplify loading process even more. Any other opinion?

 

Related Topics