You can open ASCII files from DataStage with OpenSeq, write to them, close them. But is there also a function to delete files from within a BASIC program? I haven't found any so far.
Ogmios
DeleteSeq???
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
And the easiest way to do this from DataStage BASIC is via the DSExecute() function.
If System(91) = 0
Then
Shell = "UNIX"
RmCmd = "rm "
End
Else
Shell = "DOS"
RmCmd = "DEL /S "
End
Command = RmCmd : PathnameOfFile
Call DSExecute(Shell, Command, Output, ExitStatus)
Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
If System(91) = 0
Then
Shell = "UNIX"
RmCmd = "rm "
End
Else
Shell = "DOS"
RmCmd = "DEL /S "
End
Command = RmCmd : PathnameOfFile
Call DSExecute(Shell, Command, Output, ExitStatus)
Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Ray
I turned this into a function. Very dangerous.
Also MakeDir
I am using these to automate documentation. I have a function documentor like JobReport on ADN. I will post it soon. I think the KgdMakeDir(DirName) is very useful.
I turned this into a function. Very dangerous.
Code: Select all
* ------------------------------------------------------------
* KgdRemoveDir(DirName)
* Decription: This routine will remove DirName
* Written by: Kim Duke
* Notes:
* ------------------------------------------------------------
* $INCLUDE DSINCLUDE JOBCONTROL.H
Ans = @FALSE
If System(91) = 0 Then
Shell = "UNIX"
Sep = '/'
RmCmd = 'rm -rf '
End Else
Shell = "DOS"
Sep = '\'
RmCmd = 'DEL /S '
End
print "Shell = ":Shell
print "Sep = ":Sep
* ------------------------------------------------------------
OpenPath DirName To FileVariable Then
Close FileVariable
Command = RmCmd:DirName
print Command
* ------------------------------------------------------------
* Call DSExecute(Shell, Command, Output, ErrorCode)
If ErrorCode > 0 Then
Ans = @FALSE
print "ErrorCode = ":ErrorCode
goto TheEnd
End Else
Ans = @TRUE
End
End
* ------------------------------------------------------------
TheEnd:
print "Ans = ":Ans
Code: Select all
* ------------------------------------------------------------
* KgdMakeDir(DirName)
* Decription: This routine will make all the dirs in DirName
* Written by: Kim Duke
* Notes:
* ------------------------------------------------------------
* $INCLUDE DSINCLUDE JOBCONTROL.H
Ans = @FALSE
If System(91) = 0 Then
Shell = "UNIX"
sep = '/'
End Else
Shell = "DOS"
sep = '\'
End
print "Shell = ":Shell
print "sep = ":sep
* ------------------------------------------------------------
NoOfDirs = dcount(DirName, sep)
for i=1 to NoOfDirs
tmpDir = field(DirName, sep, 1, i)
OpenPath tmpDir To FileVariable On Error
cmd = "mkdir ":tmpDir
print cmd
* ------------------------------------------------------------
Call DSExecute(Shell, cmd, output, ErrorCode)
If ErrorCode > 0 Then
Ans = @FALSE
print "ErrorCode = ":ErrorCode
goto TheEnd
End Else
Ans = @TRUE
End
End Then
Ans = @TRUE
Close FileVariable
End Else
cmd = "mkdir ":tmpDir
print cmd
* ------------------------------------------------------------
Call DSExecute(Shell, cmd, output, ErrorCode)
If ErrorCode > 0 Then
Ans = @FALSE
print "ErrorCode = ":ErrorCode
goto TheEnd
End Else
Ans = @TRUE
End
End
next i
* ------------------------------------------------------------
TheEnd:
print "Ans = ":Ans
Mamu Kim