Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How to

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to
  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 >>
 How to - 5/30/2001 1:36:40 AM   
  leclercqrowan59

 

Posts: 1
Score: 0
Joined: 5/30/2001
From:
Status: offline
I want to read a text file line by line and put each word/phase into a variable. Each line has a series of words/phrases which are each separated by a comma(,). How do I do this.
eg. line1=h,o,w,t,o
line2=o,t,w,t,o
after reading line 1:
var1=h
var2=o
var3=w
var4=t
var5=o
after reading line 2:
var1=o
var1=t
var1=w
var1=o
var1=h

if you know how to do this please answer this topic or send the code to nimbus59@one.net.au

Thankyou
 
 
Post #: 1
 
 Re: How to - 2/15/2005 7:07:26 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I'm still working on getting the array items broken out into variables. You can at least see how you can put the different letters in an array. My test.txt file had the following line: h,o,w,t,o.

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\temp\test.txt", ForReading)

arrTest = Split(objFile.ReadLine, ",")
i = 0

For Each Letter In arrTest
Wscript.Echo arrTest(i)
i = i + 1
Next
objFile.Close

You can assign the array items to variables as is but you would need to know how many Index Numbers the array is going to have ahead of time. This is done as so:
Var1 = arrTest(0)
Var2 = arrTest(1)
etc.

(in reply to leclercqrowan59)
 
 
Post #: 2
 
 Re: How to - 2/15/2005 9:03:05 AM   
  CaffeineAddiction

 

Posts: 144
Score: 0
Joined: 2/9/2005
From:
Status: offline
Ok, I under stand the part about it being split up by commas ... but, why on earth would you want these words/phrases stored under static variables instead of doing something like putting it in a dynamic array?

I mean ... it can be done ... but inorder to have a diffrent variable for each word/phrase you would either have to know before hand how many words/phrases there where ... or you would have to write some totaly bogus script that writes another script based on how many words/phrases there are

here is a Basic FreeSyntax example

      

The code above follows no syntax and is just for short hand demonstration purposes ... but it shows that you can make a script that will take all the words/phrases and give the unique and static variable ... but why? Why would you want them all to be static variables ... you cant use them as static variables ... your best bet is putting them in an array and using them from there.

(in reply to leclercqrowan59)
 
 
Post #: 3
 
 Re: How to - 2/15/2005 2:17:03 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
What exactly do you intend to do with the comma separated list of words/phrases/characters ?

(in reply to leclercqrowan59)
 
 
Post #: 4
 
 
 
  

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 >> How to 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