Where in the memory I should search for displayed informations? - page 2 - Script Writing - CHDK Forum supplierdeeply

Where in the memory I should search for displayed informations?

  • 12 Replies
  • 2590 Views
*

Online reyalp

  • ******
  • 11923
Re: Where in the memory I should search for displayed informations?
« Reply #10 on: 05 / May / 2012, 15:36:22 »
Advertisements
For me stat on non-existing file broke the script and an error was displayed. Something like bad pointer to a table - I don't remember ('stat' is the element of the table 'os'). Fopen method works well ;)
Then you did something wrong, or the port you are using is horribly broken. My guess would be you tried to use the return value of stat as a table without checking whether it was nil or not first.

To check if something exists called 'A/FOO' you can just use
Code: (lua) [Select]
if os.stat('A/FOO') then
...--  foo exists, might be a file or directory or volume label!
If you want to check that it's a file, then you'd do something like
Code: (lua) [Select]
st = os.stat('A/FOO')
if st and st.is_file then
... -- foo is a file
If you leave out the st before the and, you will be trying to use nil as a table and generate an error.

FWIW, for things like get_input(), you might find using ipairs clearer (and less typing)

Code: (lua) [Select]
for i,key in ipairs(REPEATABLE_KEYS_TABLE) do
        if is_pressed(key) then
            PRESSED_KEY=key
        end
end
Sorry for the OT, and nice work on the script :)
Don't forget what the H stands for.

Re: Where in the memory I should search for displayed informations?
« Reply #11 on: 06 / May / 2012, 04:08:22 »
A... yes, I did it wrong, I have used is_file without checking the stat itself. Thank you for pointing this, now it's clearer. Also ipars are good idea and I'll use them. Maybe also in the next release of the EDI.

Regards!
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline msl

  • *****
  • 1262
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Where in the memory I should search for displayed informations?
« Reply #12 on: 07 / May / 2012, 06:02:38 »
SX220 (1.01a)  current file path: 0xC6878

SX230 current file path: 0xCA818 (see function camera_jpeg_current_filename() for GPS in platform/sub/lib.c)

msl
CHDK-DE:  CHDK-DE links

 

Related Topics