Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I conver below to this T1T

Status
Not open for further replies.

Kryolla

Technical User
Dec 6, 2001
35
how can I conver below to this
T1T0-1517-2&&-12,T3T0-13-13-20&&-22.

Thanks

T1T0-1517-2,T3T0-13-13-20:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-3,T3T0-13-13-21:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-4,T3T0-13-13-22:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-5,T3T0-13-13-23:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-6,T3T0-13-13-24:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-7,T3T0-13-16-17:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-8,T3T0-13-16-18:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-9,T3T0-13-16-19:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-10,T3T0-13-16-20:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-11,T3T0-13-16-21:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
"T1T0-1517-12,T3T0-13-16-22:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
 
Hello,

Explain which fields again Please.. Do you want just the Following from the First Line ?
And follow the same Pattern to the End of File ??

T1T0-1517-2 T3T0-13-13-20

Hank camphm@bellsouth.net
 
Kryolla,

This should get you started, assuming this is what you're asking.

Proc Main
string sLine
string sTok1
fopen 1 "C:\FILES\Kryolla.TXT" Read text
fopen 2 "C:\FILES\Kryolla_OUT.TXT" Create Text
while not feof 1
fgets 1 sLine
strreplace sLine "`"" ""
strtok sTok1 sLine ":" 1
fputs 2 sTok1
endwhile
fclose 1
fclose 2
endproc

Let me know if you need any more formatting Tips or if this is incorrect.

Hank camphm@bellsouth.net
 
how can I combine lines 1-5 to say this
T1T0-1517-2&&-6,T3T0-13-13-20&&-24
If you noticed each line increments by 1 i.e 1517-2, 1517-3 also 13-13-20, 13-13-21 etc. Thanks Again

1. "T1T0-1517-2,T3T0-13-13-20:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
2. "T1T0-1517-3,T3T0-13-13-21:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
3. "T1T0-1517-4,T3T0-13-13-22:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
4. "T1T0-1517-5,T3T0-13-13-23:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"
5. "T1T0-1517-6,T3T0-13-13-24:2WAY:IW=TRSP,TC=TRSP-TRSP,,,:IS-NR,BUSY"



 
Kryolla,

Is this output always the Same ?? Or do the Number Fields Change ?? Also, if I understand you correctly, you only want 1 Line of Output..

Hank camphm@bellsouth.net
 
Yes the output is always the same. But I will store it in a variable. Thanks
 
Here's the script I was able to come up with, hope it makes sense!

proc main
string sLine ;Input from data source
string sTemp1, sTemp2, sFirst1, sFirst2 ;Temporary data-shuffling strings
string sOutput ;Final output data

fopen 0 "c:\data.txt" READ TEXT
while not feof 0
fgets 0 sLine
strreplace sLine "`"" ""
strtok sTemp1 sLine ","
strtok sTemp2 sLine ":"
strreplace sTemp2 "," ""
if nullstr sFirst1
sFirst1 = sTemp1
endif
if nullstr sFirst2
sFirst2 = sTemp2
endif
endwhile
fclose 0
sOutput = sFirst1
strcat sOutput "&&"
strtok sTemp1 sTemp1 "-" 2
strcat sOutput sTemp1
strcat sOutput ","
strcat sOutput sFirst2
strcat sOutput "&&"
strtok sTemp2 sTemp2 "-" 3
strcat sOutput sTemp2
endproc aspect@aspectscripting.com
 
Kyrolla,

Here is what I came up with this afternoon. Let Me Know. The Kryolla.txt is your Data File.

Proc Main
string sLine
string sTok1,sTok2,sTok3
string sToka,sTokb,sTokc,sTokd
string sField1,sField2,sField3,sField4
string sLine1, sLine2,sOut1,sOut2,sResult

fopen 1 "C:\FILES\Kryolla.TXT" Read text
fopen 2 "C:\FILES\Kryolla_TMP.TXT" Create Text
while not feof 1
fgets 1 sLine
strreplace sLine "`"" ""
strtok sTok1 sLine ":" 1
fputs 2 sTok1
endwhile
fclose 1
rewind 2
fgets 2 sLine1
while not feof 2
fgets 2 sLine
if strfind sLine "T1T"
sLine2 = sLine
endif
endwhile
fclose 2
strtok sField1 sLine1 "," 1 ;* T1T0-1517-2
strtok sField2 sLine1 "," 1 ;* T3T0-13-13-20
strtok sField3 sLine2 "," 1 ;* T1T0-1517-12
strtok sField4 sLine2 "," 1 ;* T3T0-13-16-22
strtok sTok1 sField3 "-" 1 ;* T1T0
strtok sTok2 sField3 "-" 1 ;* 1517
strtok sTok3 sField3 "-" 1 ;* 12
strfmt sOut1 "%s&&-%s" sField1 sTok3
strtok sToka sField4 "-" 1 ;* T3T0
strtok sTokb sField4 "-" 1 ;* 13
strtok sTokc sField4 "-" 1 ;* 16
strtok sTokd sField4 "-" 1 ;* 22
strfmt sOut2 "%s&&-%s" sField2 sTokd
strfmt sResult "%s,%s" sOut1 sOut2
Termwrites sResult
Termwrites "`n`r"
;* delfile "C:\FILES\Kryolla_TMP.TXT"
Endproc

Hank camphm@bellsouth.net
 
Thanks Alot fellas it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top