?
Solved

Delete an external file

Posted on 2011-02-16
3
Medium Priority
?
583 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 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