#382 FileNameDialog loadorsave

3.2.0
closed
5
2012-08-14
2007-08-10
Lee Peedin
No

When setting the value of "loadorsave" if the user sets this to only the letter 'L' (thinking that would work for "LOAD"), the dialog that opens is a "SAVE" dialog.

Use of the just the letter "L" should either produce an error OR should be short for LOAD.

selfile       = path||'*.*'
parent        = ''                      -- don't need this in this example - just a place holder
filemask      = 'All Files'
loadorsave    = 'L'                     -- Load is the default
title         = 'My ooRexx Save Dialog' -- See documentation for default
defExtenstion = ''                      -- don't need this in this example - just a place holder
multiSelect   = ''                      -- don't need this in this example - just a place holder
sepChar       = ''                      -- don't need this in this example - just a place holder

a_file = FileNameDialog(selfile,parent,filemask,loadorsave,title,defExtension,multiSelect,sepChar)
if a_file = 0 then
    call errorMessage('You Did Not Select A File')
else
    call infoMessage('You Selected' a_file)

Discussion

  • Lee Peedin

    Lee Peedin - 2007-08-10

    Logged In: YES
    user_id=1223125
    Originator: YES

    Sorry - Watch for line wraps!

     
  • Mark Miesfeld

    Mark Miesfeld - 2007-08-10

    Logged In: YES
    user_id=191588
    Originator: NO

    Well, yes the code has a logic error.

    If you omit the argument all together, you get the default LOAD. However, if you do not omit the argument, the code assumes you used either, exactly "SAVE" or exactly "LOAD". So, if you were to use "L" or "T" or 15 what gets sent to the underlying C function is ambiguous and always gets translated to 0. Where 1 is to use the Open dialog and 0 is use the Save dialog.

    The question is how to fix this. In general ooDialog is very forgiving of errors on the ooRexx programmer's part. Quite often it just goes its merry way and does nothing. (Something I'm not fond of because then things don't work and the programmer has no clus as to why.)

    The doc says:

    loadorsave

    Specifies which dialog should be displayed.

    LOAD
    Display the File Open Dialog (default).

    SAVE
    Display the File Save Dialog.

    I'm hesitant to change the code to produce an error, (although that may be the right thing to do,) because most of ooDialog is lenient of errors. Producing an error here then would be inconsistent to the overall behavior.

    Probably the best approach would be to fix the code so that if you used 'S' or "save", case insignificant, you get the Save dialog. Anything else you get the default Open dialog. Then alter the documentation to explicitly state that.

     
  • Lee Peedin

    Lee Peedin - 2007-08-10

    Logged In: YES
    user_id=1223125
    Originator: YES

    Well the reason I was certain this was an error, if you use just the letter "S", it appears to be short for "SAVE" and opens a save dialog.

    I think the old documentation instructed to use either 0 or 1. Maybe the new documentation should specify to use exactly "LOAD" or "SAVE"; however, practically all other ooRexx parameters can be shortened to only the first letter, so I'm not sure what if anything should be done.

    <quote>
    Probably the best approach would be to fix the code so that if you used
    'S' or "save", case insignificant, you get the Save dialog. Anything
    else you get the default Open dialog. Then alter the documentation to
    explicitly state that.
    <\quote>

    I like the idea of "S" or "save" and anything else default to "LOAD". I'll let you decide what if anything needs to be done, and "trust me", I'll be happy with it. :-)

    BTW: Just curious why you chose the word "LOAD" when everything else uses the term "OPEN"?

    Lee

     
  • Mark Miesfeld

    Mark Miesfeld - 2007-08-11

    Logged In: YES
    user_id=191588
    Originator: NO

    Committed revision 667.

    This commit fixes the code so that the documented default (LOAD) is always used if the caller does not explicitly specify SAVE. Note that this function has always accepted either 0 (SAVE) or 1 (LOAD) for this argument. That prior behavior is preserved.

    Committed revision 668.

    This commit clarifies the ooDialog documentation in relation to this argument.

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks