Solved

Delete an external file

Posted on 2011-02-16
3
557 Views
Last Modified: 2013-11-16
Hi,

Code below will not work. Can't find the problem.

Tx
DATA _NULL_ ;
    %LET XX1 = c:\Data\xx1.xls ;
    %LET XX2 = c:\Data\xx2.xls ;
    %LET XX3 = c:\Data\xx3.xls ;
RUN ;

%MACRO checkFile (bestand = ) ;
    %IF %SYSFUNC(fileexist(&bestand)) = 0 %THEN %DO ;
	%END ;
    %ELSE %DO ; 
    	FILENAME MFile &bestand  ;
         DATA _NULL_ ;
	   rc = FDELETE(&bestand) ;
	RUN ;

	FILENAME &bestand CLEAR ;
	%END ;
%MEND checkFile ;

%checkFile(bestand = &xx1) ;
%checkFile(bestand = &xx2) ;
%checkFile(bestand = &xx3) ;

Open in new window

0
Comment
Question by:sonmic
  • 2
3 Comments
 
LVL 11

Expert Comment

by:theartfuldazzler
ID: 34906607
Hi

A few problems, mostly linked to quotation marks.
 
%Let work = %SYSFUNC(PATHNAME(WORK));
%put &work;

DATA _NULL_ ;
    %LET XX1 = "&work\xx1.xls" ;
    %LET XX2 = "&work\xx2.xls" ;
    %LET XX3 = "&work\xx3.xls" ;
RUN ;

%MACRO checkFile (bestand = ) ;
    %IF %SYSFUNC(fileexist(&bestand)) = 0 %THEN %DO ;
	%END ;
    %ELSE %DO ; 
	    
    	FILENAME MFile &bestand  ;
         DATA _NULL_ ;
	   rc = FDELETE("MFILE") ;
	RUN ;

	FILENAME MFILE CLEAR ;
	%END ;
%MEND checkFile ;
options mprint;
%checkFile(bestand = &xx1) ;
%checkFile(bestand = &xx2) ;
%checkFile(bestand = &xx3) ;

Open in new window

0
 
LVL 11

Accepted Solution

by:
theartfuldazzler earned 500 total points
ID: 34906619
PS - if you change the first line to:

%l;et work = c:\Data;

then you should have the equivalent code.
0
 
LVL 14

Expert Comment

by:Aloysius Low
ID: 34906771
if after trying what theartfuldazzler has said and is still not working, please post the log.

it's always easier to look at the log and help
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle query help 18 113
MySQL ERROR 1045 (28000) 2 79
Question about consuming GB from Comcast 5 55
Update from TABLE-A to TABLE-B 5 48
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question