Scripting Noob Question

Scooby_Doo

Executive Member
Joined
Sep 4, 2005
Messages
9,081
Hey all,

I need to create a script that will be called by a report to change some characters into other characters.
This is what i have so far and it works, PS this is VBS. Be gentle i am a coding noob.

Const ForReading1 = 1
Const ForWriting2 = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForReading1)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "**123**", "{")

Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForWriting2)
objFile.WriteLine strNewText

objFile.Close

Const ForReading3 = 1
Const ForWriting4 = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForReading3)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "**125**", "}")

Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForWriting4)
objFile.WriteLine strNewText

objFile.Close


In my report I will be using the SHELL command to pass some variables, in particular the file name and path which are created when the report is run. The next step is declaring variables that can accept the variables from the SHELL command.

Would anyone have any idea on how I can go about doing this.

Thanks
 

Raithlin

Executive Member
Joined
Jan 4, 2005
Messages
5,049
http://leereid.wordpress.com/2008/01/10/sweet-vbscript-command-line-parameters/
...
Code:
If Wscript.Arguments.Count = 0 Then
    ‘ Do Proceed as Normal
Else
    For i = 0 to Wscript.Arguments.Count – 1
        If Wscript.Arguments(i) = “/reset” Then
         resetflag=1 ’Turn on the reset flag 
       ElseIf Wscript.Arguments(i) = “/nolog” Then
         loggingflag = 0 ‘Turn off the logging flag 
  End If
    Next
End If

If loggingFlag =0 Then
  ‘Don’t log
Else
 LogMyStuff ‘ Call the function you want
End If

‘==========================================================================
‘If reset command line parameter is detected, run the reset function only, then quit
‘==========================================================================
If resetFlag Then
 Reset
 WScript.Quit
End If

EDIT: This blog explains it nicely: http://blogs.technet.com/heyscripti...mmand-line-arguments-and-a-default-value.aspx
 

Scooby_Doo

Executive Member
Joined
Sep 4, 2005
Messages
9,081
Cool,

i'll give that a bash, thanks.

:confused: Are you using Reporting Services?

Not that i know of, the report will be created in a big ERP system on a server in the US, wouldn't know the specifics. The problem is that the system cannot print brackets to text file, so i want to create a script that will edit a series of characters in the text file into a bracket after the report has created the file.
 
Last edited:
Top