![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Using Cognos Impromptu (Version 7) Script Editor, I'm trying to create a Sub so that it can be re-used - macro code at the bottom of the post. The Sub takes three arguments to copy a file from one location and dump it to another location, appending the date to the filename along the way. A further parameter is the intended file extension of the file being moved - to give some flexibility if this sub is called multiple times. When I run it in the CognosScript Editor window, it highlights in red, the single line in the Sub Main and saying '1 Error .... etc etc" - it doesn't even compile, let alone run & fail!!! ![]() If I hardcode the parameters into the Sub ArchiveDataFiles it works fine, but is not what I want as I intend to call it numerous times, passing in various parameters. Can anyone point me off with what I'm doing wrong! It must be me - I can't beleive that a routine can't take variable/parameters!!! Thanks in advance Phil ================================================== ============== Sub Main() Call ArchiveDataFiles("C:\Test.txt", "C:\Test2", "csv") End Sub Sub ArchiveDataFiles (strFile As String, strDest As String, strExt As String) Dim strFileToCopy as String Dim strDestination as String Dim strFileTag as String On Error Resume Next strFileTag = "_" & Format(Date,"YYYYMMDD") strFileToCopy = strFile strDestination = strDest & strFileTag & "." & strExt FileCopy strFileToCopy, strDestination End Sub |
#3
| |||
| |||
|
|
I forgot to mention that I did add a Declare statement at the top of the macro code. thanks phil Phil Latio wrote: Using Cognos Impromptu (Version 7) Script Editor, I'm trying to create a Sub so that it can be re-used - macro code at the bottom of the post. The Sub takes three arguments to copy a file from one location and dump it to another location, appending the date to the filename along the way. A further parameter is the intended file extension of the file being moved - to give some flexibility if this sub is called multiple times. When I run it in the CognosScript Editor window, it highlights in red, the single line in the Sub Main and saying '1 Error .... etc etc" - it doesn't even compile, let alone run & fail!!! ![]() If I hardcode the parameters into the Sub ArchiveDataFiles it works fine, but is not what I want as I intend to call it numerous times, passing in various parameters. Can anyone point me off with what I'm doing wrong! It must be me - I can't beleive that a routine can't take variable/parameters!!! Thanks in advance Phil ================================================== ============== Sub Main() Call ArchiveDataFiles("C:\Test.txt", "C:\Test2", "csv") End Sub Sub ArchiveDataFiles (strFile As String, strDest As String, strExt As String) Dim strFileToCopy as String Dim strDestination as String Dim strFileTag as String On Error Resume Next strFileTag = "_" & Format(Date,"YYYYMMDD") strFileToCopy = strFile strDestination = strDest & strFileTag & "." & strExt FileCopy strFileToCopy, strDestination End Sub |
#4
| |||
| |||
|
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |