Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem with simple script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,864
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with simple script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Problem with simple script - 7/3/2003 7:43:55 AM   
  Newwbie

 

Posts: 3
Score: 0
Joined: 7/3/2003
From:
Status: offline
I need help writing a macro which will search an opened .wrl document and eliminate all symbols like " / , : from the variable names and make sure the first letter of each name is a capital. The script I am using gives me an error: WScript undefined.


'----------

Option Explicit

say ""
say "ScanFile - simple example of scanning a text file"
say "-------------------------------------------------="

dim fso
set fso = CreateObject( "Scripting.FileSystemObject" )

dim sName
sName = "ScanFile.vbs"

dim fFile, sFile, aFile, iLine, iLines, sLine, sWord

say "loading file " & sName & " into a string"
set fFile = fso.OpenTextFile( sName, 1 ) ' 1 = ForReading
sFile = fFile.ReadAll
fFile.Close

say "splitting string into an array"
aFile = Split( sFile, vbCrLf )

say "scanning lines"
iLines = UBound( aFile ) + 1
iLine = 0
do while iLine < iLines
sLine = aFile( iLine )

statements
sLine = CleanString( sLine, Chr(34) & "/,:" )


sWord = left( sLine, 3 )
if ( sWord = "dim" ) or ( sWord = "say" ) then
say "line " & iLine + 1 & ": " & sLine
sLine = "' " & sLine
end if

'- put it back in array with
aFile( iLine ) = sLine

iLine = iLine + 1
loop

say "rejoining array items into a string, writing to output file"
sFile = Join( aFile, vbCrLf )

set fFile = fso.CreateTextFile( "ScanFileOutput.txt", True )
fFile.Write sFile
fFile.Close

say ""
say "done"

function CleanString( sInput, sSymbols )
dim sClean
sClean = ""

dim l, i, c
l = len( sInput )
i = 1

'- while more input string
do while i <= l

'- snip out a character
c = mid( sInput, i, 1 )

'- if not a symbol, add to cleaned string
if InStr( sSymbols, c ) = 0 then
sClean = sClean & c
end if

i = i + 1
loop

CleanString = sClean
end function

WScript.Quit

'----------

sub Say( s )
WScript.Echo s
end sub

'----------


Thanks in advance
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with simple script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts