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

Is there a better way to do this? 1

Status
Not open for further replies.

bangarmundo

Programmer
Feb 26, 2004
2
CH
I have a file ipsec.list like this:

Otherinfo
Nextinfo
IPSEC
IPSECRULE xxx.xxx.xxx.xxx * log proto *
IPSECRULE yyy.yyy.yyy.yyy * log proto *
ENDIPSEC
;comment
;comment
New INfo
IPSEC
IPSECRULE yyy.yyy.zzz.yyy * log proto *
ENDIPSEC

-----------------------
I want the portion ipsec --endipsec .
I have programmed as follows:
-----------------------
"EXECIO * DISKR T1 (STEM LINE. FINIS"
Do j = 1 to line.0
if Word(line.j,1) = 'IPSEC' then
Do i = j to line.0
QUEUE line.i
if word(line.i,1) = 'ENDIPSEC' then leave
End
End
"EXECIO * DISKW T2 (FINIS ";
EXIT
-------------------------
Is there a better way?
Thanks
 
The only thing I would add is to terminate the outer loop if you LEAVE the inner loop:
Code:
Do j = 1 to line.0                             
if   Word(line.j,1) = 'IPSEC' then             
  Do i = j to line.0                           
     QUEUE line.i                              
     if word(line.i,1) = 'ENDIPSEC' then [b]sw.0end = 1
     if sw.0end then [/b]leave
End                       
[b]if sw.0end then leave    [/b]                 
End
It's possible that you might have many lines after the ENDIPSEC and you would want to avoid looking at each one.

Frank Clarke
--Now officially with no one I can vote for in '08...
 
It looks like your input file has more than one set of ipsec --endipsec data. Do you want only the first set or all sets in your output file?
 
Try this for your do loop

Qit = 0
do i = 1 to line.0
if Word(line.i,1) = 'IPSEC' then Qit = 1
if Qit then QUEUE line.i
if word(line.i,1) = 'ENDIPSEC' then Qit = 0
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top