Arcade Posted November 27, 2009 Posted November 27, 2009 Hi, i need to convert the information in a variable to a vector, for example: In the .txt the line has things like this: Time in | Time out | Subject | Something I need to convert this in: $Var[1] [0] = time in $Var[1] [1] = time out $Var[1] [2] = subject $Var[1] [3] = something References: Var = variable 1 = number of the line in the .txt If anyone can help me i will be very gratefull.
enaiman Posted November 27, 2009 Posted November 27, 2009 FileRead -> read the file content in a variable$myVar = FileRead($file)StringSplit -> to split the above variable in lines (@CRLF delimiter) -> an array of lines$myLineARRAY = StringSplit($myVar, @CRLF, 1)StringSplit every line of the above array ( "|" delimiter) -> every line of the text file will become an array of valuesFor $i=1 To $myLineARRAY[0] $myLineContent = StringSplit($myLineARRAY[$i], "|")NextGood luck, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Arcade Posted November 27, 2009 Author Posted November 27, 2009 FileRead -> read the file content in a variable $myVar = FileRead($file) StringSplit -> to split the above variable in lines (@CRLF delimiter) -> an array of lines $myLineARRAY = StringSplit($myVar, @CRLF, 1) StringSplit every line of the above array ( "|" delimiter) -> every line of the text file will become an array of values For $i=1 To $myLineARRAY[0] $myLineContent = StringSplit($myLineARRAY[$i], "|") Next Good luck, Sorry but how i get the data that i have to put in the $myLineContent My problem is that i can find all the table but not a single celd For example: |word1...word2...word3| |word4...word5...word6| |word7...word8...word9| How i get the word5 for example? And also can i use $Array[0][0]="Upper-Left" to find the celd? Thank you soo much for your time
enaiman Posted November 27, 2009 Posted November 27, 2009 Read the help for StringSplit and have a look at the example there - you will get an idea for sure. Read also about arrays because that is needed too. This example will help too - try to understand it and you'll be able to do your homework: #include <array.au3> $data = StringSplit("Time in | Time out | Subject | Something", "|") _ArrayDisplay($data) For $i = 0 To $data[0] MsgBox(0, "array elements", $data[$i]) Next SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now