Proposed changes to script parameters - page 6 - General Discussion and Assistance - CHDK Forum

Proposed changes to script parameters

  • 52 Replies
  • 10067 Views
*

Offline msl

  • *****
  • 1269
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Proposed changes to script parameters
« Reply #50 on: 08 / November / 2015, 04:28:03 »
Advertisements
Now the script header documentation is all in one place.
Great work. The summarized infos are very helpful. Thanks for that.

msl
CHDK-DE:  CHDK-DE links

Re: Proposed changes to script parameters
« Reply #51 on: 08 / November / 2015, 12:36:18 »
Looks like the addition of @subtitle introduced a new bug?

I'm having trouble with saving & restoring parameters and I think narrowed the issue down to the use of @subtitle.   Pasted below are two simple scripts.  The first saves & restores parameters correctly and the second does not.  The only difference between the two is the addition of @subtitle to the second.

Code: [Select]
--[[
@title No Subtitle
@chdk_version 1.3
@param a Test Value 1
@default a 2
@param b Test Value 1
@default b 2
--]]
print(a,b)

Code: [Select]
--[[
@title With Subtitle
@chdk_version 1.3
@param a Test Value 1
@subtitle BLAH
@default a 2
@param b Test Value 1
@default b 2
--]]
print(a,b)

I also tested with the new shorthand notation and saw the same result when @subtitle was present.

Update :  it looks like it tries to save the @subtitle line in the script's saved parameter file  as  #(null)=0.  which confuses things when the script tries to restore from that file.  The attached patch file fixes that, although it may not be the best way to do so.
« Last Edit: 08 / November / 2015, 14:16:57 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online philmoz

  • *****
  • 3155
    • Photos
Re: Proposed changes to script parameters
« Reply #52 on: 08 / November / 2015, 15:24:59 »
Looks like the addition of @subtitle introduced a new bug?

...

Update :  it looks like it tries to save the @subtitle line in the script's saved parameter file  as  #(null)=0.  which confuses things when the script tries to restore from that file.  The attached patch file fixes that, although it may not be the best way to do so.

That should work.
Alternatively you could use this:
Code: [Select]
            if ( p->name != 0 )
            {
                // Only need to save name and value - saved as #name=value
                sprintf(buf,"#%s=%d\n",p->name,p->val);
                write(fd, buf, strlen(buf));
            }

Phil.

Edit: Added in revision 4284.
« Last Edit: 08 / November / 2015, 16:46:33 by philmoz »
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)
  g5x (1.00c, 1.01a, 1.01b)

 

Related Topics