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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fgets and strcat problem

Status
Not open for further replies.

MTSOtech

Technical User
Jul 18, 2005
2
US
I am trying to load Global Title translations into a Tekelec Eagle STP using a KeyBoard Send & Rx(KSR) connection. I am reading my line ranges in from a text file and then concatenating the begining and the end of the command to the line being read in. If I just read the line in and then just termwrites it back out then I have no problem, it runs through the entire list. When I use strcat to add the rest of the command to the string, the script just repeates the same string over and over. See code below..

proc main
string fname = "verizon.gtt.txt"
; example string "345675"
string LineBuffer
string firsthalf="ent-gtt:type=12:gta="
string
secondhalf=":ri=ssn:ssn=11:xlat=dpcssn:pc=238-013-012^M"
if fopen 0 fname READ TEXT
while not feof 0
fgets 0 LineBuffer
strcat firsthalf LineBuffer
strcat firsthalf secondhalf
transmit "^A"
waitfor "> "
transmit firsthalf
waitfor "ENT-GTT: PSM B - COMPLTD"
endwhile
else
errormsg "Couldn't open file `"%s`"." Fname
endif

fclose 0
endproc

;I endup with...
;ent-gtt:type=12:gta=345675:ri=ssn:ssn=11:xlat=dpcssn:pc=238-013-012^M
;over and over and over

Thanks MTSOtech
 
What is happening is that the first time through your while loop, the original value of firsthalf is lost so on subsequent attempts you are just appending to the string that was created the previous pass through the loop. One way to eliminate this is to assign firsthalf the value again either at the beginning or end of the while loop so it has the correcting starting value for the next pass.


 
Its so obvious once someone has given you the answer. Thanks knob. -MTSOtech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top