BookmarkSubscribeRSS Feed
mccake
Calcite | Level 5

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.

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

mccake
Calcite | Level 5

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1152 views
  • 2 likes
  • 3 in conversation