Solved

Delete an external file

Posted on 2011-02-16
3
548 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now