Hi again,

After reading all of the various comments, I'd like to suggest a future for
the directory function, which will (hopefully) satisfy everyone.

I think this is the best direction especially when it both matches the
opening sentence of the current documentation and provides a wide choice of
useful results.  What I mean is having the directory function also return
the Current Directory makes sense, as it returns information the program
may not have at the present time.  Allowing the directory function to
return the Current Directory is efficient over coding two lines (e.g. one
to get the current directory and then to change).


I propose the addition of a new parameter (second parameter) to set the
desired return value.  This new parameter would be "C" for Current
Directory and "N" for New Directory.  The default would be "N" thus keeping
the current ooRexx behavior.

I hope the following clarifies my thoughts:


Current_Directory = directory(New_Directory,'c')
New_Directory_Result = directory(New_Directory('n')  also
New_Directory_Result = directory(New_Directory) would give the same result.



The documentation would read:

The directory function returns the current directory or changes the
directory of the current process depending upon the first argument.  The
return value is one of three possible values depending upon the value of
the first argument, result of the change directory, and the value of the
second argument.  The possible values are the current directory, new
directory, or null.

If the first argument is null, the function will return the current
directory.  An example is Current_Directory = directory().

If there is first argument, the function will attempt to change to the
directory location and if successful will return a value depending upon the
second argument.  If the directory change is NOT successful the directory
function will return a null value.

The second argument returns the current directory, when set to 'C', the new
directory when set to 'N' or not specified (the default).  Using the 'c'
value for the second argument allows the program to obtain the current
directory and change the directory in one statement.



Usage Example:

Current_Directory = directory();

New_Directory = 'C:\users\public\'
New_Directory_Result = directory(New_Directory,'n')  /* OR you can use
New_Directory_Result = directory(New_Directory) */
if New_Directory_Result = '' then do
  say 'Directory change was not successful.  Most likely' New_Directory
'does not exist.'
  exit 1001
  end

New_Directory = 'C:\Temp\MyProgramWorkSpace'
if directory() = directory(New_Directory,'C') then do
  say New_Directory 'exists and this program changed to it.'
  end
 otherwise do
   'mkdir' New_Directory
    call directory New_Directory
    if result = '' then do
      say 'Unable to make and change to' New_Directory'.'
      exit 1002
      end
   end
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to