![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | read strings to variable I have a text file like this: 1234 45566, 78923 10/02, 10/03, 10/04 6543 46765, 35643 23/03 I want the script to look at each line and read the first string to a variable(e.g. 1234), then read all strings after and including the fourth string to another variable (eg. 10/02 to variable, 10/03 to another variable etc) and then write those variables to a line in another text file. It would do this for each line in the text file. The fourth string and after dates and I would like to write it as 2009/10/02 for example. Basically I want to grab specific text from each line of the text file and add them to commands. Can anyone help? Thanks, James |
My System Specs![]() |
| | #2 (permalink) |
| | Re: read strings to variable "James" <jwanders@xxxxxx> wrote in message news:Tznom.137737$cf6.136849@xxxxxx Quote: >I have a text file like this: > > > 1234 45566, 78923 10/02, 10/03, 10/04 > 6543 46765, 35643 23/03 > > I want the script to look at each line and read the first string to a > variable(e.g. 1234), then read all strings after and including the fourth > string to another variable (eg. 10/02 to variable, 10/03 to another > variable etc) and then write those variables to a line in another text > file. It would do this for each line in the text file. The fourth string > and after dates and I would like to write it as 2009/10/02 for example. > > Basically I want to grab specific text from each line of the text file and > add them to commands. Can anyone help? > > Thanks, > > James Object. You then split each line into its components like so: aComponents = split(sLine) This will allow you to access each component separately: wscript.echo "String 1 = " & aComponents(0) wscript.echo "String 2 = " & aComponents(1) etc. All of the above is covered extensively, with examples, in the help file script56.chm which you can download from the Microsoft site. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Has anyone sucessfully read the value of the $OFS variable? | PowerShell | |||
| Read-Host issue, won't store to variable when using multiple read-host lines | PowerShell | |||
| Variable expansion in strings | PowerShell | |||