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!

if then print 1

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hallo All (again)

In a previous thread I had the following:

/^langue/ { pr(); $0 = "<preferred_lang>"$2"</preferred_lang>"
print;next}

the pr function is not related to this question. I have changed this to:

/^langue/ { pr(); language = $2; $0 = "<preferred_lang>"language"</preferred_lang>"
print; next}

Now the question. How would I go about
1) if the language variable = en, then print <Country>UK</country> on a seperate line
2) else if the language variable = fr, then print <Country>FR</Country> on a seperate line

Any ideas?
 
A starting point (brute force method):
/^langue/ { pr(); language = $2; $0 = "<preferred_lang>"language"</preferred_lang>"
print
if(language=="en")print "<Country>UK</country>"
if(language=="fr")print "<Country>FR</Country>"
next
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
The if(language=="en") construct was what I was looking for, the == was what caught me.
Twice on one day you help me. This is perfect for now.
Let me just state how much your help is appreciated.
Many many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top