Passing Value to VB Script 
Author Message
 Passing Value to VB Script

Hi Gurus,

I am quite new to VBScript and need  some help regarding a VBScript I
am writing.

Problem.

I have a file that contains only one line in it which is the date
passed from anothe sources (Unix Box). the file contains the following
20020621

How can I pass this value to a variable in the script so I can use it
to create a folder with that value ?



Sun, 12 Dec 2004 07:29:49 GMT  
 Passing Value to VB Script
If you just want to read the data, you can read the first line of the file
(reading "by line" ensures that any odd linefeed characters are left out).

I have a function which acts like a clone of the "head" command to do things
like this; if you specify reading only 1 line, it returns it without a final
line feed.

sData = Head("C:\temp\rg3.reg", 1)
WScript.Echo sData

Function Head(fil, nlines)
'Given the path to a file, will return
 ' count nlines # of lines
 ' lines will be separated with vbCrLF if more than
 ' one is specified
 ' works with either ANSI or Unicode
 Const ForReading = 1, TristateUseDefault = -2, _
  DoNotCreateFile = False
 With CreateObject("Scripting.FileSystemObject")._
  OpenTextFile(fil, ForReading, _
  False, TristateUseDefault)
  for i = 1 to nlines
  Head = Head & .ReadLine
  if i < nlines then Head = Head & vbCrLf
  Next
  .Close
 End With
End Function


Quote:
> Hi Gurus,

> I am quite new to VBScript and need  some help regarding a VBScript I
> am writing.

> Problem.

> I have a file that contains only one line in it which is the date
> passed from anothe sources (Unix Box). the file contains the following
> 20020621

> How can I pass this value to a variable in the script so I can use it
> to create a folder with that value ?



Sun, 12 Dec 2004 10:08:36 GMT  
 Passing Value to VB Script
Whoops; more robust version here...

sData = Head("C:\temp\rg3.reg", 1)
WScript.Echo sData

Function Head(fil, nlines)
'Given the path to a file, will return
 ' count nlines # of lines
 ' lines will be separated with vbCrLF if more than
 ' one is specified
 ' works with either ANSI or Unicode
 Const ForReading = 1, TristateUseDefault = -2, _
  DoNotCreateFile = False
 With CreateObject("Scripting.FileSystemObject")._
  OpenTextFile(fil, ForReading, _
  False, TristateUseDefault)
  for i = 1 to nlines
  if not .AtEndOfStream then
   Head = Head & .ReadLine
   if i < nlines then Head = Head & vbCrLf
  Else Exit For
  End If
  Next
  .Close
 End With
End Function

Quote:



> > Hi Gurus,

> > I am quite new to VBScript and need  some help regarding a VBScript I
> > am writing.

> > Problem.

> > I have a file that contains only one line in it which is the date
> > passed from anothe sources (Unix Box). the file contains the following
> > 20020621

> > How can I pass this value to a variable in the script so I can use it
> > to create a folder with that value ?



Sun, 12 Dec 2004 10:36:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How can pass a value from Vb script to java script

2. Passing values by reference from java / vb script to ActiveX object

3. Passing values by reference from java / vb script to ActiveX object

4. vb passing values to html

5. Pass Session value to a VB Sub

6. Passing a Wsh value to VB

7. Passing WHS value to VB

8. Passing value from Server script to client script.

9. Passing values from client vars to Server script

10. Passing a value from ASP to the script

11. passing date value as arg to script

12. pass values to script?

 

 
Powered by phpBB® Forum Software