wbph1
buasuwan is right, it's is a matter of what your current directory is. However, if you are using PB 8 or 9 there is a function called ChangeDirectory(). No need for an external function anymore.
Main Topics
Browse All Topicshey,
I was wondering if it´s possible to define wich directory the open dialog most use...
for example i wnat it to open in c:\prefab but my current is c:\powerbuilder
how do i do that using the GetFileOpenName statement...
thanks,
willem
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
How does an external function exectly work?! I have never worked with this...:S
I put it in the main window and i used declare, external local functions.
this is the place where i put this script:
Function long SetCurrentDirectory(string
Function long GetCurrentDirectory(long nBufferLength, ref string lpBuffer) Library "kernel32" Alias for "GetCurrentDirectory"
however, when I execute the program i get an arror calling the external function GetCurrentDirectory.
what do i do wrong?!
thanks,
wbph1
wbph1
Well if you are using the PFC, the file service has an of_ChangeDirectory function which makes the external call for you. If not, here's the external function declaration. The external function declaration is a little different from what buasuwan gave you. In particular the use of the keyword "ref" is important otherwise the SetCurrentDirectoryA function won't be able to read the value you pass it.
Function boolean SetCurrentDirectoryA (ref string directoryname ) library "KERNEL32.DLL"
Then you can just call the function...
String ls_dir
ls_dir = //your value
SetCurrentDirectoryA(ls_di
Hi wbph1,
my code works on XP,2000 and 98. And I see the only problem you've found is that you have no directory c:\prefab. Then you still get the default directory in GetFileOpenName dialog.
EAServer,
the string parameter in external function always be reference pointer.
Function boolean SetCurrentDirectoryA (string directoryname ) library "KERNEL32.DLL"
Function boolean SetCurrentDirectoryA (ref string directoryname ) library "KERNEL32.DLL"
those are the same.
'ref string' is only need when you want to get data back from external function. you will see in this function GetCurrenctDirectory(). that's why i don't put ref in SetXXX function. and another reason is you can use value "c:\prefab" instead of ls_dir.
Business Accounts
Answer for Membership
by: buasuwanPosted on 2003-04-02 at 08:47:29ID: 8254798
you have to change current directory to c:\prefab and then call function GetFileOpenName(...)
lpPathName) Library "kernel32" Alias for "SetCurrentDirectoryA"
h)
path)
here is the declaration of External Functions to be used.
Function long SetCurrentDirectory(string
Function long GetCurrentDirectory(long nBufferLength, ref string lpBuffer) Library "kernel32" Alias for "GetCurrentDirectory"
and script will be.
string ls_oldpath
// prepare the buffer of the last current directory and set back later
ls_oldpath = space(512)
GetCurrentDirectory(511, ls_oldpath)
string ls_path, ls_named
ls_path = "c:\prefab"
// change to your directory
SetCurrentDirectory(ls_pat
integer value
value = GetFileOpenName("Select File", &
+ ls_path, ls_named, "DOC", &
+ "Text Files (*.TXT),*.TXT," &
+ "Doc Files (*.DOC),*.DOC")
IF value = 1 THEN
// FileOpen(docname)
end if
// set currenct directory back to the old path
SetCurrentDirectory(ls_old