DATA Step, Macro, Functions and more

File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

Reply
Occasional Contributor
Posts: 5

File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

Hi to whom it may concern,

 

  I'm trying to initiate an 'open file/folder dialog' window when either a defaulted path or file name is no longer found/valid, in that I would like to be able to prompt the user that had initiated the SAS script to select the approrpate 'folder' or file(s) 'multi file select' via a 'open file/folder dialog' window, since this is Windows based I'm try to use the standard Windows/Office FileOpenDialog box.

 

  I've searched over the internet for prior examples, and i've come across numerous examples but none of them seem to work as of yet, in that I've looked at 'FILEOPEN' command, 'DLGOPEN' command and I've also looked at using the Windows DLL comdlg32.dll via the SASCBTBL reference. My preference is to use the Windows DLL comdlg32 as this user interface is most common.

 

  I would assume somebody has achieved this functionality before, hence could you share your result/experience?

 

 

TIA

mccake.

Super User
Super User
Posts: 7,997

Re: File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

Sorry, what software are you using as this isn't Base SAS?  Maybe you mean SAS/AF, if so I would advise to look at other solutions, haven't used that in 15 years.

Occasional Contributor
Posts: 5

Re: File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

Hi RW9,

 

  here, SAS/AF regretably doesn't give the look and feel of the typical windows office application fileopendialg box. Just because you haven't used it in 15 years, doesn't imply that no someone else in the world has or shouldn't try to. You don't have to reply or contribute if can't provide a useful suggestion, 'I would advise to look at other solutions' what other solutions do you suggest/examples would be appreciated that show how to be able to prompt a user to select a folder or select single/multiple files?

 

filename ofna catalog 'work.winapi.ofna.source';

data _null_;

file ofna;

input;

put _infile_;

cards4;

routine GetOpenFileNameA

module=COMDLG32

minarg=20

maxarg=20

stackpop=called

returns=short

;

arg 1 num input fdstart format=pib4. ; * DWORD lStructSize;

arg 2 num input format=pib4. ; * HWND hwndOwner;

arg 3 num input format=pib4. ; * HINSTANCE hInstance;

arg 4 num input format=pib4. ; * LPCSTR lpstrFilter;

arg 5 num input format=pib4. ; * LPSTR lpstrCustomFilter;

arg 6 num input format=pib4. ; * DWORD nMaxCustFilter;

arg 7 num update format=pib4. ; * DWORD nFilterIndex;

arg 8 num input format=pib4. ; * LPSTR lpstrFile;

arg 9 num input format=pib4. ; * DWORD nMaxFile;

arg 10 num input format=pib4. ; * LPSTR lpstrFileTitle;

arg 11 num input format=pib4. ; * DWORD nMaxFileTitle;

arg 12 num input format=pib4. ; * LPCSTR lpstrInitialDir;

arg 13 num input format=pib4. ; * LPCSTR lpstrTitle;

arg 14 num input format=pib4. ; * DWORD Flags;

arg 15 num update format=pib2. ; * WORD nFileOffset;

arg 16 num update format=pib2. ; * WORD nFileExtension;

arg 17 num input format=pib4. ; * LPCSTR lpstrDefExt;

arg 18 num input format=pib4. ; * LPARAM lCustData;

arg 19 num input format=pib4. ; * LPOFNHOOKPROC lpfnHook;

arg 20 num input format=pib4. ; * LPCSTR lpTemplateName;

;;;;

run;

filename sascbtbl catalog 'work.winapi.ofna.source' ;

data _null_;

strFilter = "Text Files (*.txt)" || byte(0) || "*.txt" || byte(0) || "SAS Files (*.sas)" || byte(0) ||"*.sas" || byte(0) || byte(0);

nFilterIndex = 1;

length strFile $2048;

strFile = byte(0);

strInitialDir = "C:\data\" || byte(0);

strDialogTitleBarText = "Select Folder or File" || byte(0);

OFN_ALLOWMULTISELECT = 00000200x;

OFN_EXPLORER = 00080000x;

nFileOffset = 0;

nFileExtension = 0;

rc = modulen('GetOpenFileNameA'

, 76 %* 20*4 - 2 - 2;

, 0

, 0

, addrlong(strFilter)

, 0

, 0

, nFilterIndex

, addrlong(strFile)

, 2048

, 0

, 0

, addrlong(strInitialDir)

, addrlong(strDialogTitleBarText)

, bor(OFN_ALLOWMULTISELECT, OFN_EXPLORER)

, nFileOffset

, nFileExtension

, 0

, 0

, 0

, 0

);

put rc=;

put nFilterIndex=;

length file1-file5 $200;

array f file1-file5;

path = scan (strFile,1, byte(0));

do i = 1 to 5;

f[i] = scan (strFile, i+1, byte(0));

end;

put _all_;

run;

 

  In the meantime I'll persevere and I'll eventually find a solution that works for me. I'm now taking a quick look at the SCL OPENSASFILEDIALOG, but this as I skip through several web articles doesn't look like it's going to give me the flexibility that I'm after, but thanks anyway for .

 

TIA

mccake.

Super User
Super User
Posts: 7,997

Re: File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

Examples: stored proces, Enterprise Guide, Web Front Ends, any one of the mainstream development languages - .net, Java all which can interact with SAS .  

As for the rest, hope you find a solution.

Super User
Posts: 11,343

Re: File/Folder Dialog box: FILEOPEN, DLGOPEN, SASCBTBL

[ Edited ]

Maybe you want the DLGCDIR command. That brings up a Change directory window.

 

I don't know about later versions but:

 

dm "DLGCDIR";

 

executed from the editor may a starting place.

 

It may well be worth not spending a lot of time on the specific windows dlls as 1) they are know to change without warning and 2) portability if your shop changes OS for some reason.

Ask a Question
Discussion stats
  • 4 replies
  • 144 views
  • 2 likes
  • 3 in conversation