Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#68 FILENAMEDIALOG changes directory

closed
Mark Miesfeld
None
5
2012-08-14
2007-12-21
Anonymous
No

After invoking FileNameDialog function, the current directory is changed to the directory selected in the dialog. There is no statement of this action in the documentation.

Discussion

  • Lee Peedin
    Lee Peedin
    2007-12-21

    Logged In: YES
    user_id=1223125
    Originator: NO

    The FileNameDialog uses a Windows API. This is the case even if the same API is used in a program written in any other language. In fact if you do not specify a starting directory, it will default to the last directory it was used to load a file from - even if that last occurrence was in a "canned program".

    Lee

     
  • Mark Miesfeld
    Mark Miesfeld
    2007-12-22

    Logged In: YES
    user_id=191588
    Originator: NO

    I think the problem here is this:

    In a Rexx program you are doing stuff and the current working directory is say, C:\Program Files. Then you use the fileNameDialog() function and in the file dialog change the directory to say D:\Word.docs. When you return from the fileNameDialog() call, your current working directory will be D:\Word.docs, rather than the directory you started in.

    This is somewhat unexpected behavior to me and I think that it is correct to expect that your current working directory, in the Rexx program, remain unchanged.

    This is relatively simple to fix, at least if the user is running XP, Server 2003, or later. The docs are a little unclear and suggest that it might not work on earlier versions of Windows. However, most people are going to be on XP.

    I vote that I put in the fix. I guess no one will object unless I bring this up outside of the bug report.

     
  • rffrexx
    rffrexx
    2007-12-29

    Logged In: YES
    user_id=1209735
    Originator: NO

    Mark,
    Lee is correct, this behavior is "functions as designed" and can actually serve a purpose to the user. Lets say, the user is working in an application and needs to upload some files, these files that need to be uploaded all exist in the same folder (not the same folder as the script) but, have to be uploaded one at a time. The user would have to keep browsing to that folder each time to select a file.

    Here is an example, of how I have been dealing with this:

    curdir = directory()
    file = FileNameDialog('.pdf',,"Adobe PDF Files"'0'x".pdf"'0'x)
    call directory curdir
    / Now, you can process file or end if file = 0 /


    In closing, this example doesn't hinder the user as in the scenario I described above and allows the rexx application to continue functioning in it's folder.

    Robert

     
  • Mark Miesfeld
    Mark Miesfeld
    2007-12-29

    Logged In: YES
    user_id=191588
    Originator: NO

    Robert,

    It turns out I agree with both you and Lee. Lee and I already discussed this in e-mail and I'm definitely not going to change the behavior.

    I'm leaving the bug open at this time to remind myself to update the documentation to make it clear to the user what the behavior is. I'll put your example, or something similar, into the documentation as to how to deal with the directory change if it is needed.

    I'm also toying with adding an optional argument that could be used to set the behavior.

     
  • Mark Miesfeld
    Mark Miesfeld
    2008-07-18

    Logged In: YES
    user_id=191588
    Originator: NO

    As several people pointed out, the directory change is due to the, purposefull, behavior of the underlying Windows dialog.

    I've updated the documentation for the FileNameDialog routine to alert programmers to this behavior if they are not aware of it.

     


Anonymous


Cancel   Add attachments