Page 1 of 1 1
Topic Options
#125259 - 2004-08-18 05:05 PM ReadLine Question
Trox Offline
Fresh Scripter

Registered: 2002-09-17
Posts: 34
Loc: St. Petersburg, FL
I am stuck on a problem of wanting to read 2 variables from one text file. I have on the first line of the UID.TXT file "USERNAME ~ USRNAME" and want to pull USERNAME as VAR1 and USRNAME as VAR2 but am not sure how to tackle this one. After I make the folder based on VAR2, I want to move the files from the old folder based on VAR1.

Code:
If NOT Open(1,"\\spghmbrsrv02\soft$\UID.txt")
If NOT Open(2,"\\spghmbrsrv02\soft$\UIDFail.txt",5) ;1 for Create file and 4 for open in write mode = 5
$UID=ReadLine(1)
While $UID
Color w+/n
?" Creating UID folder for:"Color y+/n" " +$UID
?" "
MD "\\spghmbrsrv01\Private$\1_UID\"+$UID
If @ERROR > 0
Color r+/n
?"Failed!"
WriteLine (2,$UID+Chr(13)+Chr(10)) ;writes the failed pc to the pcfaillist.txt
Else
Color g+/n
?"Done!"
EndIf
$UID=ReadLine(1)
Loop
$=Close(1)
$=Close(2)
EndIf

_________________________
Thanks ~ Trox John Wayne's not dead - he's frozen. And as soon as we find the cure for cancer we're gonna thaw out the duke and he's gonna be pretty pissed off! ~Dennis Leary~

Top
#125260 - 2004-08-18 05:24 PM Re: ReadLine Question
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Depending on your version of KiXtart, use Split() to split the line into an array, then address the fields individually.

Also, use @CRLF rather than Chr(10)+Chr(13)

Top
#125261 - 2004-08-18 05:27 PM Re: ReadLine Question
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Code:
$UID=Split(ReadLine(1),"~")

$USERNAME=$UID[0]
$USRNAME=$UID[1]


Top
#125262 - 2004-08-18 06:19 PM Re: ReadLine Question
Trox Offline
Fresh Scripter

Registered: 2002-09-17
Posts: 34
Loc: St. Petersburg, FL
Thanks much for the response. Worked great and makes my life much easier!!
_________________________
Thanks ~ Trox John Wayne's not dead - he's frozen. And as soon as we find the cure for cancer we're gonna thaw out the duke and he's gonna be pretty pissed off! ~Dennis Leary~

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.08 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org